This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstartrstudio.in
executable file
·58 lines (51 loc) · 1.64 KB
/
startrstudio.in
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
#!/bin/bash
while getopts s: opt
do
case $opt in
s) SOCKET_PATH="$OPTARG";;
esac
done
# Data directory for rserver. Do not persist to $HOME, it does not contain any
# useful data.
datadir=/tmp/rstudio-server-data
rsessionconfig="$datadir/rsession.conf"
rdbconfig="$datadir/database.conf"
mkdir -p "$datadir"
# Do not restore variables, which reference the store. They might be different
# when the profile changes and this breaks session resumption.
blacklisted=$(env | grep /gnu/store/ | cut -d = -f 1 | paste -s -d :)
# Cannot pass options to rsession directly, write config file. Need dynamic
# file to account for blacklisted variables.
cat <<EOF > "$rsessionconfig"
# XXX: Not sure if required
allow-terminal-websockets=0
# Verbose logging
log-stderr=1
# Session timeouts
session-timeout-minutes=120
session-disconnected-timeout-minutes=120
# Do not restore variables.
session-ephemeral-env-vars=$blacklisted
# Do not show (bogus, due to container) user identity
show-user-identity=0
# Discourage custom package installation, managed by Guix.
allow-package-installation=0
# RStudio ignores R_LIBS_SITE, so forward it. There is no way to set site
# libraries.
r-libs-user=${R_LIBS_SITE}
EOF
cat <<EOF > "$rdbconfig"
provider=sqlite
# As of 1.4 the database only contains revoked cookies. See src/cpp/server/db/
# in the RStudio source tree.
directory=$datadir/database
EOF
exec RSTUDIO_PREFIX/bin/rserver \
--server-data-dir="$datadir" \
--server-user=$USER \
--server-daemonize=0 \
--www-socket=${SOCKET_PATH:-.rstudio-socket} \
--auth-none=1 \
--server-oneshot=1 \
--rsession-config-file="$rsessionconfig" \
--database-config-file="$rdbconfig"