rstudio/entrypoint.sh.tmpl

36 lines
719 B
Bash

#!/bin/bash
set -eu
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"
}
file_env "PASSWORD"
{{ if eq (env "OIDC_ENABLED") "1" }}
echo "auth-openid=1" >> /etc/rstudio/rserver.conf
echo "auth-openid-issuer=${OIDC_ISSUER_URL}" >> /etc/rstudio/rserver.conf
echo "auth-openid-base-uri=https://${DOMAIN}" >> /etc/rstudio/rserver.conf
{{ end }}
exec "$@"