41 lines
879 B
Bash
41 lines
879 B
Bash
#!/usr/bin/env bash
|
|
|
|
file_env() {
|
|
# 3wc: Load $VAR_FILE into $VAR - useful for secrets. See
|
|
# https://medium.com/@adrian.gheorghe.dev/using-docker-secrets-in-your-environment-variables-7a0609659aab
|
|
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"
|
|
}
|
|
|
|
load_vars() {
|
|
file_env "ADMIN_PASS"
|
|
file_env "OAUTH_KEY"
|
|
}
|
|
|
|
main() {
|
|
set -eu
|
|
|
|
load_vars
|
|
}
|
|
|
|
main
|
|
|
|
# 3wc: upstream ENTRYPOINT
|
|
# we need to use `env` here because bash won't fuck with variable names with
|
|
# hyphens, but both `env` and `node` seem fine..
|
|
env Accounts_OAuth_Custom-Keycloak-secret=$OAUTH_KEY "$@"
|