-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart
More file actions
59 lines (53 loc) · 2.04 KB
/
start
File metadata and controls
59 lines (53 loc) · 2.04 KB
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
#!/bin/bash
set -euo pipefail
# Start - Set any environment variables here
# These are inherited by all processes, *except* RStudio
# USE export <parname>=value
# source this file to get the variables defined in the rocker Dockerfile
# this is a series of export cmds
if [ -f "${REPO_DIR}/env.txt" ]; then
source "${REPO_DIR}/env.txt"
fi
# End - Set any environment variables here
# check for gh-scoped-creds needed variables so that can use this in RStudio
# These are based on Jupyter Hub config so will not know before server starts what these are.
for var in GH_SCOPED_CREDS_CLIENT_ID GH_SCOPED_CREDS_APP_URL; do
if [[ -n "${!var:-}" ]]; then
echo "${var}=\"${!var}\"" >> "${R_HOME}/etc/Renviron.site"
echo "Added ${var} to Renviron.site"
fi
done
# Run child start scripts in a subshell to contain its environment
# ${REPO_DIR}/childstart/ is created by setup-start.sh
if [ -d "${REPO_DIR}/childstart/" ]; then
for script in ${REPO_DIR}/childstart/*; do
if [ -f "$script" ]; then
echo "Sourcing script: $script"
source "$script" || {
echo "Error: Failed to source $script. Moving on to the next script."
}
fi
done
fi
# --- Set default VSCode code-server settings if missing ---
DEFAULT_SETTINGS_DIR="/usr/local/share/code-server/User"
USER_SETTINGS_DIR="/home/jovyan/.local/share/code-server/User"
# Ensure User settings directory exists
mkdir -p "${USER_SETTINGS_DIR}"
# Ensure directory to start vscode in exists; starting in $HOME is bad since vscode tries to index all the files
mkdir -p "${HOME}/vscode"
chown -R jovyan:jovyan "${HOME}/vscode"
if [ ! -f "${USER_SETTINGS_DIR}/settings.json" ]; then
echo "Creating default VSCode settings.json..."
cat > "${USER_SETTINGS_DIR}/settings.json" <<'EOF'
{
"remote.autoForwardPorts": true,
"remote.autoForwardPortsSource": "process",
"remote.restoreForwardedPorts": false
}
EOF
chown -R jovyan:jovyan "${USER_SETTINGS_DIR}"
else
echo "User already has VSCode settings.json, not overwriting."
fi
exec "$@"