rstudio/entrypoint.sh.tmpl

86 lines
2.4 KiB
Cheetah
Raw Normal View History

2021-05-17 13:54:59 +00:00
#!/bin/bash
set -eu
2021-05-17 13:54:59 +00:00
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
2024-03-07 14:44:21 +00:00
{{ if eq (env "COPY_USERS") "1" }}
cp /opt/users/passwd /etc/passwd || true
cp /opt/users/shadow /etc/shadow || true
cp /opt/users/group /etc/group || true
copy_users() {
while true; do
if [ /etc/passwd -nt /opt/users/passwd ]; then
cp -uv /etc/passwd /opt/users/passwd
else
cp -uv /opt/users/passwd /etc/passwd
fi
if [ /etc/shadow -nt /opt/users/shadow ]; then
cp -uv /etc/shadow /opt/users/shadow
else
cp -uv /opt/users/shadow /etc/shadow
fi
if [ /etc/group -nt /opt/users/group ]; then
cp -uv /etc/group /opt/users/group
else
cp -uv /opt/users/group /etc/group
fi
2024-03-07 14:44:21 +00:00
sleep 60
done
}
copy_users &
{{ end }}
2021-05-17 13:54:59 +00:00
file_env "PASSWORD"
{{ if eq (env "OIDC_ENABLED") "1" }}
echo 'auth-openid=1' >> /etc/rstudio/rserver.conf
echo 'auth-openid-issuer={{ env "OIDC_ISSUER_URL"}}' >> /etc/rstudio/rserver.conf
echo 'auth-openid-base-uri=https://{{ env "DOMAIN" }}' >> /etc/rstudio/rserver.conf
{{ end }}
2021-09-21 10:50:40 +00:00
{{ if eq (env "KEYCLOAK_ENABLED") "1" }}
apt update --allow-releaseinfo-change
2021-09-21 10:50:40 +00:00
apt install -y libpam-script
mkdir -p /opt/pam-exec-oauth2/
wget https://github.com/WASHNote/pam-exec-oauth2/releases/download/v0.0.1/pam-exec-oauth2 -O /opt/pam-exec-oauth2/pam-exec-oauth2
chmod +x /opt/pam-exec-oauth2/pam-exec-oauth2
echo 'auth requisite pam_exec.so log=/tmp/pam_exec.log expose_authtok /opt/pam-exec-oauth2/pam-exec-oauth2 --verbose' > /etc/pam.d/common-auth
echo 'auth requisite pam_script.so' >> /etc/pam.d/common-auth
2021-09-21 10:50:40 +00:00
{{ end }}
{{ if eq (env "MSSQL_ENABLED") "1" }}
export ACCEPT_EULA=Y
apt --allow-releaseinfo-change update && apt install -yq curl gpg libglpk40
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
2023-11-14 14:11:33 +00:00
apt update && apt -o Dpkg::Options::="--force-overwrite" install -yq msodbcsql17 mssql-tools
{{ end }}
2021-10-26 08:57:20 +00:00
locale-gen {{ env "DEFAULT_LOCALES" }}
exec "$@"