From 64892423b670f4631303234a137fb32abd067a09 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 26 Feb 2020 12:27:42 -0500 Subject: [PATCH] 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 --- bash_functions.sh | 8 ++++++++ start.sh | 1 + 2 files changed, 9 insertions(+) diff --git a/bash_functions.sh b/bash_functions.sh index 89de84a..f09db8e 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -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 diff --git a/start.sh b/start.sh index 9802985..815da70 100755 --- a/start.sh +++ b/start.sh @@ -42,6 +42,7 @@ docker_checks #fi fix_capabilities +load_web_password_secret generate_password validate_env || exit 1 prepare_configs