From 03bcce1e73c056da3b2d9fdc9e0b2e1f4f68b699 Mon Sep 17 00:00:00 2001 From: Robin van Boven <497556+Beanow@users.noreply.github.com> Date: Mon, 15 Apr 2019 04:41:59 +0200 Subject: [PATCH] Support reading a file for the SA_PASSWORD for swarm security. (#477) --- util/MsSql/entrypoint.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/util/MsSql/entrypoint.sh b/util/MsSql/entrypoint.sh index b136afe83b..e2e1c5cc2c 100644 --- a/util/MsSql/entrypoint.sh +++ b/util/MsSql/entrypoint.sh @@ -27,6 +27,17 @@ useradd -o -u $LUID -g $GROUPNAME -s /bin/false $USERNAME >/dev/null 2>&1 || usermod -o -u $LUID -g $GROUPNAME -s /bin/false $USERNAME >/dev/null 2>&1 mkhomedir_helper $USERNAME +# Read the SA_PASSWORD value from a file for swarm environments. +# See https://github.com/Microsoft/mssql-docker/issues/326 +if [ ! -z "$SA_PASSWORD" ] && [ ! -z "$SA_PASSWORD_FILE" ]; then + echo "Provided both SA_PASSWORD and SA_PASSWORD_FILE environment variables. Please only use one." + exit 1 +fi +if [ ! -z "$SA_PASSWORD_FILE" ]; then + # It should be exported, so it is available to the env command below. + export SA_PASSWORD=$(cat $SA_PASSWORD_FILE) +fi + # The rest... # ref: https://stackoverflow.com/a/38850273