78a1b549fc
Necessary to support more that one SATOSA worker.
50 lines
1.8 KiB
Bash
Executable File
50 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# The container user (see USER in the Dockerfile) is an un-privileged user that
|
|
# does not exists and is not created during the build phase (see Dockerfile).
|
|
# Hence, we use this entrypoint to wrap commands that will be run in the
|
|
# container to create an entry for this user in the /etc/passwd file.
|
|
#
|
|
# The following environment variables may be passed to the container to
|
|
# customize running user account:
|
|
#
|
|
# * USER_NAME: container user name (default: default)
|
|
# * HOME : container user home directory (default: none)
|
|
#
|
|
# To pass environment variables, you can either use the -e option of the docker run command:
|
|
#
|
|
# docker run --rm -e USER_NAME=foo -e HOME='/home/foo' oidc2fer:latest python manage.py migrate
|
|
#
|
|
# or define new variables in an environment file to use with docker or docker compose:
|
|
#
|
|
# # env.d/production
|
|
# USER_NAME=foo
|
|
# HOME=/home/foo
|
|
#
|
|
# docker run --rm --env-file env.d/production oidc2fer:latest python manage.py migrate
|
|
#
|
|
|
|
echo "🐳(entrypoint) creating user running in the container..."
|
|
if ! whoami > /dev/null 2>&1; then
|
|
if [ -w /etc/passwd ]; then
|
|
echo "${USER_NAME:-default}:x:$(id -u):$(id -g):${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
|
|
fi
|
|
fi
|
|
|
|
echo "🐳(entrypoint) creating config files from environment..."
|
|
mkdir -p /tmp
|
|
# These files are referenced by the Satosa config files
|
|
printenv SAML2_BACKEND_CERT > /tmp/backend.crt
|
|
printenv SAML2_BACKEND_KEY > /tmp/backend.key
|
|
printenv OIDC_FRONTEND_KEY > /tmp/frontend.key
|
|
printenv CLIENT_DB_JSON > /tmp/client_db.json
|
|
|
|
# Redis database number must be specified
|
|
if [[ ! $OIDC_DB_URI =~ /[0-9]+$ ]]; then
|
|
echo "🐳(entrypoint) adding db id to OIDC_DB_URI"
|
|
export OIDC_DB_URI=$OIDC_DB_URI/0
|
|
fi
|
|
|
|
echo "🐳(entrypoint) running your command: ${*}"
|
|
exec "$@"
|