-
Notifications
You must be signed in to change notification settings - Fork 181
/
default_user.sh
executable file
·36 lines (31 loc) · 1.11 KB
/
default_user.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
#!/bin/bash
set -e
DEFAULT_USER=${1:-${DEFAULT_USER:-"rstudio"}}
if id -u "${DEFAULT_USER}" >/dev/null 2>&1; then
echo "User ${DEFAULT_USER} already exists"
else
## Need to configure non-root user for RStudio
useradd -s /bin/bash -m "$DEFAULT_USER"
echo "${DEFAULT_USER}:${DEFAULT_USER}" | chpasswd
usermod -a -G staff "${DEFAULT_USER}"
## Rocker's default RStudio settings, for better reproducibility
mkdir -p "/home/${DEFAULT_USER}/.config/rstudio/"
cat <<EOF >"/home/${DEFAULT_USER}/.config/rstudio/rstudio-prefs.json"
{
"save_workspace": "never",
"always_save_history": false,
"reuse_sessions_for_project_links": true,
"posix_terminal_shell": "bash"
}
EOF
chown -R "${DEFAULT_USER}:${DEFAULT_USER}" "/home/${DEFAULT_USER}"
fi
# If shiny server installed, make the user part of the shiny group
if [ -x "$(command -v shiny-server)" ]; then
adduser "${DEFAULT_USER}" shiny
fi
## configure git not to request password each time
if [ -x "$(command -v git)" ]; then
git config --system credential.helper 'cache --timeout=3600'
git config --system push.default simple
fi