Added 'WEBPASSWORD_FILE' environment variable to enable support for Docker Secrets.

If 'WEBPASSWORD' is set, 'WEBPASSWORD_FILE' is ignored. If 'WEBPASSWORD' is empty, and 'WEBPASSWORD_FILE' is set to a valid readable file, then 'WEBPASSWORD' will be set to the contents of 'WEBPASSWORD_FILE'.

Signed-off-by: Daniel <daniel@developerdan.com>
This commit is contained in:
Daniel 2020-02-26 12:27:42 -05:00
parent 76d2578b77
commit 64892423b6
No known key found for this signature in database
GPG Key ID: 4940B41048AF73EA
2 changed files with 9 additions and 0 deletions

View File

@ -290,6 +290,14 @@ setup_web_port() {
}
load_web_password_secret() {
# If WEBPASSWORD is not set at all, attempt to read password from WEBPASSWORD_FILE,
# allowing secrets to be passed via docker secrets
if [ -z "${WEBPASSWORD+x}" ] && [ -n "${WEBPASSWORD_FILE}" ] && [ -r "${WEBPASSWORD_FILE}" ]; then
WEBPASSWORD=$(<"${WEBPASSWORD_FILE}")
fi;
}
generate_password() {
if [ -z "${WEBPASSWORD+x}" ] ; then
# Not set at all, give the user a random pass

View File

@ -42,6 +42,7 @@ docker_checks
#fi
fix_capabilities
load_web_password_secret
generate_password
validate_env || exit 1
prepare_configs