-
Notifications
You must be signed in to change notification settings - Fork 2
/
launch_rserver.sh
executable file
·51 lines (43 loc) · 1.66 KB
/
launch_rserver.sh
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
#!/bin/sh -e
RSTUDIO_TEMP=$(mktemp -d -p ~)
trap "{ rm -rf $RSTUDIO_TEMP; }" EXIT
cat <<__DBCONF__ > $RSTUDIO_TEMP/dbconf
provider=sqlite
directory=$RSTUDIO_TEMP/db.sqlite3
__DBCONF__
export RSTUDIO_PASSWORD=${RSTUDIO_PASSWORD-`date -R | md5sum | cut -c-16`}
if [ -z "$RSTUDIO_PORT" ]
then
# Taken from https://gitlab.oit.duke.edu/chsi-informatics/containers/singularity-rstudio-base/-/blob/master/port_and_password_1_3.sh
LOWERPORT=50000
UPPERPORT=65535
for RSTUDIO_PORT in $(seq $LOWERPORT $UPPERPORT);
do
RSTUDIO_PORT="`shuf -i $LOWERPORT-$UPPERPORT -n 1`"
# echo "Testing port: $RSTUDIO_PORT"
ss -lpn | grep -q ":$RSTUDIO_PORT " || break
done
fi
RSTUDIO_HOST=$(hostname -A | cut -f1 -d' ')
RSTUDIO_HOST=${RSTUDIO_HOST:-localhost}
printf "\nRStudio URL:\t\thttp://${RSTUDIO_HOST}:${RSTUDIO_PORT}/\n"
printf "RStudio Username:\t$USER\n"
printf "RStudio Password:\t$RSTUDIO_PASSWORD\n"
if [ ! $RSTUDIO_HOST = "localhost" ]
then
printf "\nIf you remote work, you can forward the server to port 1664 on your computer with:\n"
printf "ssh ${USER}@${RSTUDIO_HOST} -J ${USER}@login.oist.jp,${USER}@deigo.oist.jp -L 1664:localhost:${RSTUDIO_PORT}\n"
fi
printf "\nYou may need to clean your temporary files by yourself:\n"
printf "RStudio temporary files:\t$RSTUDIO_TEMP\n"
printf "\nThis image will build its packages in the following directory if it exists:\n"
grep ^R_LIBS_USER /etc/R/Renviron.site
printf "\n"
/usr/lib/rstudio-server/bin/rserver \
--server-working-dir $RSTUDIO_TEMP \
--server-data-dir $RSTUDIO_TEMP \
--database-config-file $RSTUDIO_TEMP/dbconf \
--server-user=$USER \
--www-port=$RSTUDIO_PORT \
--auth-none 0 \
--auth-pam-helper rstudio_auth