diff --git a/scripts/functions.sh b/scripts/functions.sh index 843cc431..b7a3f0fc 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -340,12 +340,12 @@ function geoserver_logging() { } # Function to read env variables from secrets -function file_env { +function file_env() { local var="$1" local fileVar="${var}_FILE" - local def="${1:-}" + local def="${2:-}" if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then - echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + printf >&2 'error: both %s and %s are set (but are exclusive)\n' "$var" "$fileVar" exit 1 fi local val="$def" @@ -357,7 +357,6 @@ function file_env { export "$var"="$val" unset "$fileVar" } - # Credits to https://github.com/korkin25 from https://github.com/kartoza/docker-geoserver/pull/371 function set_vars() { if [ -z "${INSTANCE_STRING}" ];then diff --git a/scripts/update_passwords.sh b/scripts/update_passwords.sh index a9d20e21..97ff72c0 100644 --- a/scripts/update_passwords.sh +++ b/scripts/update_passwords.sh @@ -36,6 +36,7 @@ if [[ "${USE_DEFAULT_CREDENTIALS}" =~ [Ff][Aa][Ll][Ss][Ee] ]]; then fi # Set random password if none provided + file_env 'GEOSERVER_ADMIN_PASSWORD' if [[ -z ${GEOSERVER_ADMIN_PASSWORD} ]]; then generate_random_string 15 GEOSERVER_ADMIN_PASSWORD=${RAND}