forked from nickjer/singularity-r
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser-launcher-rstudio
executable file
·100 lines (78 loc) · 3.34 KB
/
user-launcher-rstudio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
set -ue
thisdir="$(realpath -s "$(dirname "${BASH_SOURCE[0]}")")"
#
# Start the RStudio Server container where this folder is set as the
# project directory by executing this file.
#
# Use --help to print the help text.
#
# === Settings ===========================================================
# Edit this section to change the container options of this project. They
# are communicated to the container as environment variables. See the
# beginning of the scripts "rstudio" and "rstudio_adv" to see which
# environment variables are expected.
# PROJECT_DIR:
# Per default this is set to the directory where this script lies.
PROJECT_DIR="$thisdir"
# BIND_PROJECT_TO:
# On which path the current folder will be visible inside the container
BIND_PROJECT_TO="/proj"
# EXTERNAL_FILES:
# Files/directories that are available in the container besides the project
# directory.
# The follwing example makes the directory /home/user/datasets available
# inside the container as "/ext/input", read-only:
#
# "/home/user/datasets/:/ext/input:ro" (including quotes)
#
# The first path must exist. The second path can be freely chosen.
# Omit ":ro" to enable write access from within the container.
# Separate multiple entries by newlines.
#
EXTERNAL_FILES=(
# "/home/user/datasets/:/ext/input:ro"
)
# On which address and on which port range to start RStudio
ADDRESS="127.0.0.1"
PORT_MIN="8000"
PORT_MAX="8200"
# CONTAINER_DIR:
# Where the RStudio Server container is located (directory).
echo "Do not run this script directly, but use 'createproject-rstudio'" >&2; exit 1 ###REPLACE_HERE###
# ========= END OF SETTINGS ==================================================
# This section is for advanced modifications on how the container is started
# Find container no matter of $PWD and whether CONTAINER_DIR is relative or absolute
CONTAINER_DIR="$(cd "$thisdir"; realpath -s "$CONTAINER_DIR")"
# Path to the SIF file that is the container
CONTAINER="$CONTAINER_DIR/rstudio.sif"
# Path (host system) where the session data of different RStudio Server
# sessions is stored. Per session, a subfolder is created that is mounted to
# ~/.rstudio inside the container. Also, the .pid files are created here,
# holding information about network port, host machine and more.
DIR_RUN=".run"
# Further arguments to forward to "singularity instance start ..."
# When the container is started without an instance (./rstudio exec
# without '-i' argument), ARGS_INSTANCE is also given to
# singularity exec
ARGS_INSTANCE=(
-H "$PROJECT_DIR:$BIND_PROJECT_TO"
)
# Further arguments to forward to "singularity exec ..."
ARGS_EXEC=(
--cleanenv
)
# --cleanenv: Do not forward environment variables to the container.
# This is so that host variables like PYTHONPATH do not interfere
# with the container. To set environment variables, add them to
# .bash_profile. Or use --env-file or --env or prefix your environment
# variable name with APPTAINERENV_ (formerly SINGULARITYENV_, see
# Apptainer/Singularity help)
# forward the folders in EXTERNAL_FILES to Singularity
# idiom using "+" is necessary in case EXTERNAL_FILES is empty
for f in "${EXTERNAL_FILES[@]+"${EXTERNAL_FILES[@]}"}"; do
ARGS_INSTANCE+=("-B" "$f")
done
# Parse the user arguments and launch the container
# ========================================================
source "$CONTAINER_DIR/rstudio_adv"