From 1b53af73633808e431a3fb8ee7d0a29c1a9d4dfa Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 9 Dec 2024 07:26:40 +0000 Subject: [PATCH] rename; use in more contexts --- .github/workflows/test.yml | 2 +- enketo.dockerfile | 1 + files/enketo/start-enketo.sh | 2 +- files/nginx/setup-odk.sh | 4 ++-- files/service/scripts/start-odk.sh | 2 +- files/{nginx/envsubber => shared/envsub.sh} | 0 nginx.dockerfile | 2 +- service.dockerfile | 1 + test/{envsubber => envsub}/good-example.expected | 0 test/{envsubber => envsub}/good-example.in | 0 test/{envsubber => envsub}/run-tests.sh | 6 +++--- 11 files changed, 11 insertions(+), 9 deletions(-) rename files/{nginx/envsubber => shared/envsub.sh} (100%) rename test/{envsubber => envsub}/good-example.expected (100%) rename test/{envsubber => envsub}/good-example.in (100%) rename test/{envsubber => envsub}/run-tests.sh (77%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 492d2648..944b94bc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: fetch-depth: 0 fetch-tags: true submodules: recursive - - run: cd test/envsubber && ./run-tests.sh + - run: cd test/envsub && ./run-tests.sh test-nginx: timeout-minutes: 10 runs-on: ubuntu-latest diff --git a/enketo.dockerfile b/enketo.dockerfile index c4b03466..07cfb9dc 100644 --- a/enketo.dockerfile +++ b/enketo.dockerfile @@ -10,6 +10,7 @@ WORKDIR ${ENKETO_SRC_DIR} # care about anything the server needs. because the client config is baked at # build time, we therefore hand it the untemplated config. +COPY files/shared/envsub.sh /scripts/ COPY files/enketo/config.json.template ${ENKETO_SRC_DIR}/config/config.json.template COPY files/enketo/config.json.template ${ENKETO_SRC_DIR}/config/config.json COPY files/enketo/start-enketo.sh ${ENKETO_SRC_DIR}/start-enketo.sh diff --git a/files/enketo/start-enketo.sh b/files/enketo/start-enketo.sh index 2e6dbb11..3312faf1 100755 --- a/files/enketo/start-enketo.sh +++ b/files/enketo/start-enketo.sh @@ -7,7 +7,7 @@ BASE_URL=$( [ "${HTTPS_PORT}" = 443 ] && echo https://"${DOMAIN}" || echo https: SECRET=$(cat /etc/secrets/enketo-secret) \ LESS_SECRET=$(cat /etc/secrets/enketo-less-secret) \ API_KEY=$(cat /etc/secrets/enketo-api-key) \ -envsubst \ +/scripts/envsub.sh \ < "$CONFIG_PATH.template" \ > "$CONFIG_PATH" diff --git a/files/nginx/setup-odk.sh b/files/nginx/setup-odk.sh index 5a16fbea..e824f1d0 100644 --- a/files/nginx/setup-odk.sh +++ b/files/nginx/setup-odk.sh @@ -6,7 +6,7 @@ if [[ $OIDC_ENABLED != 'true' ]] && [[ $OIDC_ENABLED != 'false' ]]; then exit 1 fi -/scripts/envsubber \ +/scripts/envsub.sh \ < /usr/share/odk/nginx/client-config.json.template \ > /usr/share/nginx/html/client-config.json @@ -32,7 +32,7 @@ echo "writing fresh nginx templates..." cp /usr/share/odk/nginx/redirector.conf /etc/nginx/conf.d/redirector.conf CNAME=$( [ "$SSL_TYPE" = "customssl" ] && echo "local" || echo "$DOMAIN") \ -nginx_envsubst \ +/scripts/envsub.sh \ < /usr/share/odk/nginx/odk.conf.template \ > /etc/nginx/conf.d/odk.conf diff --git a/files/service/scripts/start-odk.sh b/files/service/scripts/start-odk.sh index 6e73a2b7..5834575e 100755 --- a/files/service/scripts/start-odk.sh +++ b/files/service/scripts/start-odk.sh @@ -4,7 +4,7 @@ echo "generating local service configuration.." ENKETO_API_KEY=$(cat /etc/secrets/enketo-api-key) \ BASE_URL=$( [ "${HTTPS_PORT}" = 443 ] && echo https://"${DOMAIN}" || echo https://"${DOMAIN}":"${HTTPS_PORT}" ) \ -envsubst \ +/scripts/envsub.sh \ < /usr/share/odk/config.json.template \ > /usr/odk/config/local.json diff --git a/files/nginx/envsubber b/files/shared/envsub.sh similarity index 100% rename from files/nginx/envsubber rename to files/shared/envsub.sh diff --git a/nginx.dockerfile b/nginx.dockerfile index 26d7e5ca..2707051f 100644 --- a/nginx.dockerfile +++ b/nginx.dockerfile @@ -29,7 +29,7 @@ RUN apt-get update && apt-get install -y netcat-openbsd RUN mkdir -p /usr/share/odk/nginx/ COPY files/nginx/setup-odk.sh \ - files/nginx/envsubber \ + files/shared/envsub.sh \ /scripts/ RUN chmod +x /scripts/setup-odk.sh diff --git a/service.dockerfile b/service.dockerfile index 82d5848f..599a1c56 100644 --- a/service.dockerfile +++ b/service.dockerfile @@ -58,6 +58,7 @@ RUN apt-get update \ --fund=false --update-notifier=false COPY server/ ./ +COPY files/shared/envsub.sh /scripts/ COPY files/service/scripts/ ./ COPY files/service/config.json.template /usr/share/odk/ diff --git a/test/envsubber/good-example.expected b/test/envsub/good-example.expected similarity index 100% rename from test/envsubber/good-example.expected rename to test/envsub/good-example.expected diff --git a/test/envsubber/good-example.in b/test/envsub/good-example.in similarity index 100% rename from test/envsubber/good-example.in rename to test/envsub/good-example.in diff --git a/test/envsubber/run-tests.sh b/test/envsub/run-tests.sh similarity index 77% rename from test/envsubber/run-tests.sh rename to test/envsub/run-tests.sh index 213e3761..79c7aaf1 100755 --- a/test/envsubber/run-tests.sh +++ b/test/envsub/run-tests.sh @@ -1,6 +1,6 @@ #!/bin/bash -eu -log() { echo >&2 "[test/envsubber] $*"; } +log() { echo >&2 "[test/envsub] $*"; } failed=0 @@ -10,7 +10,7 @@ if diff <( \ SIMPLE=sv_simple \ SUBVAL_1=sub_val_one \ SUBVAL_2=sub_val_two \ - ../../files/nginx/envsubber \ + ../../files/shared/envsub.sh \ < good-example.in ) good-example.expected; then log " OK" @@ -20,7 +20,7 @@ else fi log "should fail when asked to substitute undefined value" -if ! ../../files/nginx/envsubber <<<'${NOT_DEFINED}'; then +if ! ../../files/shared/envsub.sh <<<'${NOT_DEFINED}'; then log " OK" else failed=1