From 731c057af359c870ecc7a4d4217aba23d273e123 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 15 Feb 2024 21:54:23 -0600 Subject: [PATCH] Minor envsubst improvements. --- .../cerc-nextjs-base/scripts/apply-runtime-env.sh | 4 ++-- .../cerc-webapp-base/scripts/apply-runtime-env.sh | 4 ++-- .../container-build/cerc-webapp-base/scripts/build-app.sh | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/apply-runtime-env.sh b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/apply-runtime-env.sh index cf1e7ce5..a662ae02 100755 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/apply-runtime-env.sh +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/apply-runtime-env.sh @@ -33,8 +33,8 @@ if [ -f ".env" ]; then rm -f $TMP_ENV fi -for f in $(find "$TRG_DIR" -regex ".*.[tj]sx?$" -type f | grep -v 'node_modules'); do - for e in $(cat "${f}" | tr -s '[:blank:]' '\n' | tr -s '[{},();]' '\n' | egrep -o '^"CERC_RUNTIME_ENV_[^\"]+"'); do +for f in $(find . -type f \( -regex '.*.html?' -or -regex ".*.[tj]s\(x\|on\)?$" \) | grep -v 'node_modules' | grep -v '.git'); do + for e in $(cat "${f}" | tr -s '[:blank:]' '\n' | tr -s '["/\\{},();]' '\n' | tr -s "[']" '\n' | egrep -o -e '^CERC_RUNTIME_ENV_.+$' -e '^LACONIC_HOSTED_CONFIG_.+$'); do orig_name=$(echo -n "${e}" | sed 's/"//g') cur_name=$(echo -n "${orig_name}" | sed 's/CERC_RUNTIME_ENV_//g') cur_val=$(echo -n "\$${cur_name}" | envsubst) diff --git a/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/apply-runtime-env.sh b/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/apply-runtime-env.sh index d3ea1d34..0e48303f 100755 --- a/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/apply-runtime-env.sh +++ b/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/apply-runtime-env.sh @@ -18,8 +18,8 @@ if [ -f ".env" ]; then rm -f $TMP_ENV fi -for f in $(find . -regex ".*.[tj]sx?$" -type f | grep -v 'node_modules'); do - for e in $(cat "${f}" | tr -s '[:blank:]' '\n' | tr -s '[{},();]' '\n' | egrep -o -e '^"CERC_RUNTIME_ENV_[^\"]+"' -e '^"LACONIC_HOSTED_CONFIG_[^\"]+"'); do +for f in $(find . -type f \( -regex '.*.html?' -or -regex ".*.[tj]s\(x\|on\)?$" \) | grep -v 'node_modules' | grep -v '.git'); do + for e in $(cat "${f}" | tr -s '[:blank:]' '\n' | tr -s '["/\\{},();]' '\n' | tr -s "[']" '\n' | egrep -o -e '^CERC_RUNTIME_ENV_.+$' -e '^LACONIC_HOSTED_CONFIG_.+$'); do orig_name=$(echo -n "${e}" | sed 's/"//g') cur_name=$(echo -n "${orig_name}" | sed 's/CERC_RUNTIME_ENV_//g') cur_val=$(echo -n "\$${cur_name}" | envsubst) diff --git a/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/build-app.sh b/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/build-app.sh index c102a054..f44931f4 100755 --- a/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/build-app.sh +++ b/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/build-app.sh @@ -33,4 +33,10 @@ else mv "${WORK_DIR}" "${DEST_DIR}" fi +# One special fix ... +cd "${DEST_DIR}" +for f in $(find . -type f -name '*.htm*'); do + sed -i -e 's#/LACONIC_HOSTED_CONFIG_homepage/#LACONIC_HOSTED_CONFIG_homepage/#g' "$f" +done + exit 0