From c84c378756344017a3ccc986b94c59437eb30b97 Mon Sep 17 00:00:00 2001 From: James King Date: Sun, 2 Mar 2025 23:12:24 +0000 Subject: [PATCH 1/2] Use cat instead of printf Fixes #3 --- scripts/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index eabc24a..2ce3666 100755 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -29,7 +29,7 @@ configure_ssh_key() { } configure_env_file() { - printf '%s' "$ENV_FILE" > "${ENV_FILE_PATH}" + cat "$ENV_FILE" > "${ENV_FILE_PATH}" env_file_len=$(grep -v '^#' ${ENV_FILE_PATH}|grep -v '^$' -c) if [[ $env_file_len -gt 0 ]]; then echo "Environment Variables: Additional values" From 3b91255157a3a4e70d2f05bae977ac5ac9469dcc Mon Sep 17 00:00:00 2001 From: James King Date: Sun, 2 Mar 2025 23:40:43 +0000 Subject: [PATCH 2/2] Fix environment substitution Fixes issues where environment variables are quoted strings with spaces as well as keep port numbers as intended integers --- scripts/docker-entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 2ce3666..e8f09c9 100755 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -36,8 +36,11 @@ configure_env_file() { if [ "${DEBUG}" != "0" ]; then echo "Environment vars before: $(env|wc -l)" fi - # shellcheck disable=SC2046 - export $(grep -v '^#' ${ENV_FILE_PATH} | grep -v '^$' | xargs -d '\n') + while IFS='=' read -r key value; do + # Remove optional surrounding quotes + value=$(echo "$value" | sed -E 's/^"(.*)"$/\1/') + export "$key=$value" + done < <(grep -vE '^#|^$' "${ENV_FILE_PATH}") if [ "${DEBUG}" != "0" ]; then echo "Environment vars after: $(env|wc -l)" fi