forked from rocker-org/rocker-versioned2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_rstudio.sh
executable file
·130 lines (102 loc) · 4.11 KB
/
install_rstudio.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
## Download and install RStudio server & dependencies uses.
## Also symlinks pandoc, pandoc-citeproc so they are available system-wide.
##
## In order of preference, first argument of the script, the RSTUDIO_VERSION variable.
## ex. stable, preview, daily, 1.3.959, 2021.09.1+372, 2021.09.1-372, 2022.06.0-daily+11
set -e
RSTUDIO_VERSION=${1:-${RSTUDIO_VERSION:-"stable"}}
DEFAULT_USER=${DEFAULT_USER:-rstudio}
ARCH=$(dpkg --print-architecture)
apt-get update
apt-get install -y --no-install-recommends \
file \
git \
libapparmor1 \
libgc1c2 \
libclang-dev \
libcurl4-openssl-dev \
libedit2 \
libobjc4 \
libssl-dev \
libpq5 \
lsb-release \
psmisc \
procps \
python-setuptools \
pwgen \
sudo \
wget
rm -rf /var/lib/apt/lists/*
# install s6 supervisor
/rocker_scripts/install_s6init.sh
export PATH=/usr/lib/rstudio-server/bin:$PATH
## Download RStudio Server for Ubuntu 18+
DOWNLOAD_FILE=rstudio-server.deb
if [ "$RSTUDIO_VERSION" = "latest" ]; then
RSTUDIO_VERSION="stable"
fi
if [ "$RSTUDIO_VERSION" = "stable" ] || [ "$RSTUDIO_VERSION" = "preview" ] || [ "$RSTUDIO_VERSION" = "daily" ]; then
wget "https://rstudio.org/download/latest/${RSTUDIO_VERSION}/server/bionic/rstudio-server-latest-${ARCH}.deb" -O "$DOWNLOAD_FILE"
else
wget "https://download2.rstudio.org/server/bionic/${ARCH}/rstudio-server-${RSTUDIO_VERSION/"+"/"-"}-${ARCH}.deb" -O "$DOWNLOAD_FILE" \
|| wget "https://s3.amazonaws.com/rstudio-ide-build/server/bionic/${ARCH}/rstudio-server-${RSTUDIO_VERSION/"+"/"-"}-${ARCH}.deb" -O "$DOWNLOAD_FILE"
fi
dpkg -i "$DOWNLOAD_FILE"
rm "$DOWNLOAD_FILE"
# https://github.com/rocker-org/rocker-versioned2/issues/137
rm -f /var/lib/rstudio-server/secure-cookie-key
## RStudio wants an /etc/R, will populate from $R_HOME/etc
mkdir -p /etc/R
echo "PATH=${PATH}" >> ${R_HOME}/etc/Renviron.site
## Make RStudio compatible with case when R is built from source
## (and thus is at /usr/local/bin/R), because RStudio doesn't obey
## path if a user apt-get installs a package
R_BIN=$(which R)
echo "rsession-which-r=${R_BIN}" > /etc/rstudio/rserver.conf
## use more robust file locking to avoid errors when using shared volumes:
echo "lock-type=advisory" > /etc/rstudio/file-locks
## Prepare optional configuration file to disable authentication
## To de-activate authentication, `disable_auth_rserver.conf` script
## will just need to be overwrite /etc/rstudio/rserver.conf.
## This is triggered by an env var in the user config
cp /etc/rstudio/rserver.conf /etc/rstudio/disable_auth_rserver.conf
echo "auth-none=1" >> /etc/rstudio/disable_auth_rserver.conf
## Set up RStudio init scripts
mkdir -p /etc/services.d/rstudio
# shellcheck disable=SC2016
echo '#!/usr/bin/with-contenv bash
## load /etc/environment vars first:
for line in $( cat /etc/environment ) ; do export $line > /dev/null; done
exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0' \
> /etc/services.d/rstudio/run
echo '#!/bin/bash
rstudio-server stop' \
> /etc/services.d/rstudio/finish
# If CUDA enabled, make sure RStudio knows (config_cuda_R.sh handles this anyway)
if [ ! -z "$CUDA_HOME" ]; then
sed -i '/^rsession-ld-library-path/d' /etc/rstudio/rserver.conf
echo "rsession-ld-library-path=$LD_LIBRARY_PATH" >> /etc/rstudio/rserver.conf
fi
# Log to stderr
LOGGING="[*]
log-level=warn
logger-type=syslog
"
printf "%s" "$LOGGING" > /etc/rstudio/logging.conf
# set up default user
/rocker_scripts/default_user.sh
# install user config initiation script
cp /rocker_scripts/init_set_env.sh /etc/cont-init.d/01_set_env
cp /rocker_scripts/init_userconf.sh /etc/cont-init.d/02_userconf
cp /rocker_scripts/pam-helper.sh /usr/lib/rstudio-server/bin/pam-helper
## Rocker's default RStudio settings, for better reproducibility
USER_SETTINGS='alwaysSaveHistory="0"
loadRData="0"
saveAction="0"
'
mkdir -p /home/${DEFAULT_USER}/.rstudio/monitored/user-settings \
&& printf "%s" "$USER_SETTINGS" \
> /home/${DEFAULT_USER}/.rstudio/monitored/user-settings/user-settings \
&& chown -R ${DEFAULT_USER}:${DEFAULT_USER} /home/${DEFAULT_USER}/.rstudio
git config --system credential.helper 'cache --timeout=3600'