diff --git a/nginx-pwa/etc/nginx/entrypoint.d/90-envsubst-on-config-js.sh b/nginx-pwa/etc/nginx/entrypoint.d/90-envsubst-on-config-js.sh index d54d37f..6848fad 100755 --- a/nginx-pwa/etc/nginx/entrypoint.d/90-envsubst-on-config-js.sh +++ b/nginx-pwa/etc/nginx/entrypoint.d/90-envsubst-on-config-js.sh @@ -5,16 +5,21 @@ set -e ME=$(basename $0) -test -z "$NGINX_CONFIG_JS_PATH" && exit 0 -test ! -f "$NGINX_CONFIG_JS_PATH" && exit 1 +test -z "$NGINX_CONFIG_JS_URI" && exit 0 + +configJsPath="$NGINX_DOCUMENT_ROOT/$NGINX_CONFIG_JS_URI" +if test ! -f "$configJsPath"; then + echo "$ME: ERROR: $configJsPath does not exist" + exit 1 +fi definedEnvs=$(printf '${%s} ' $(env | cut -d= -f1)) -if [ ! -w "$NGINX_CONFIG_JS_PATH" ]; then - echo >&3 "$ME: ERROR: $NGINX_CONFIG_JS_PATH exists, but is not writable" +if [ ! -w "$configJsPath" ]; then + echo "$ME: ERROR: $configJsPath exists, but is not writable" return 0 fi -echo >&3 "$ME: Running envsubst on $NGINX_CONFIG_JS_PATH" -envsubst "$definedEnvs" <"$NGINX_CONFIG_JS_PATH" >"${NGINX_CONFIG_JS_PATH}.tmp" -mv -f "${NGINX_CONFIG_JS_PATH}.tmp" "$NGINX_CONFIG_JS_PATH" +echo "$ME: Running envsubst on $configJsPath" +envsubst "$definedEnvs" <"$configJsPath" >"${configJsPath}.tmp" +mv -f "${configJsPath}.tmp" "$configJsPath" exit 0