Add entrypoint file

This commit is contained in:
decentral1se 2021-06-16 11:21:29 +02:00
parent 49597980cc
commit 1aa3187212
Signed by: decentral1se
GPG Key ID: 92DAD76BD9567B8A

29
entrypoint.sh.tmpl Normal file
View File

@ -0,0 +1,29 @@
#! /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 "MASTODON_ACCESS_TOKEN"
echo "Passing it back to the upstream ENTRYPOINT/CMD..."
exec "$@"