Skip to content

Commit 7f11dcb

Browse files
committed
Internal: tweak shell scripts (pipefail doesn't exist in POSIX)
1 parent b1a82c8 commit 7f11dcb

File tree

17 files changed

+58
-58
lines changed

17 files changed

+58
-58
lines changed

common/config/s6-overlay/startup-scripts/data/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
# Set defaults
6-
SECRET_DIR=/secrets
6+
readonly SECRET_DIR=/secrets
77

88
# Correct permissions so we can run as `nobody`
99
EXTRA_DIRS=
@@ -16,7 +16,7 @@ chown nobody:nogroup \
1616
$EXTRA_DIRS
1717

1818
# Ensure our working path is correct
19-
OLD_PWD="$PWD"
19+
readonly OLD_PWD="$PWD"
2020
if [ -d /app/www ]; then
2121
cd /app/www
2222
fi

common/scripts/docker-entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
# Set defaults
6-
SECRET_DIR=/secrets
6+
readonly SECRET_DIR=/secrets
77

88
# Helper to run a command, invoking startup scripts, dropping down to `nobody`
99
# user, and loading secrets into ENV.
@@ -17,7 +17,7 @@ safe_exec() {
1717
}
1818

1919
# Check if command matches, otherwise fallback to executing it
20-
COMMAND_SCRIPT="/scripts/commands/${1}.sh"
20+
readonly COMMAND_SCRIPT="/scripts/commands/${1}.sh"
2121
if [ -x "$COMMAND_SCRIPT" ]; then
2222
shift 1
2323
. "$COMMAND_SCRIPT"

common/scripts/startup/50-env-configure-nginx-api-paths.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
# Configure nginx CORS rules based on ENV vars
66
#
77
# Inputs:
88
# - NGINX_API_PATHS: defaults to '' (empty list)
99

1010
# Set defaults & clean up (normalize, trim, …)
11-
NGINX_CONFIG_FILE=/etc/nginx/site-mods-enabled.d/generated-api-paths.conf
12-
NGINX_API_PATHS=$(echo "${NGINX_API_PATHS:-}" \
11+
readonly NGINX_CONFIG_FILE=/etc/nginx/site-mods-enabled.d/generated-api-paths.conf
12+
readonly NGINX_API_PATHS=$(echo "${NGINX_API_PATHS:-}" \
1313
| sed 's/,/ /g; s/^ *//; s/ *$//; s/ */ /g')
1414

1515
# Check nginx structure

common/scripts/startup/50-env-configure-nginx-cors.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
# Configure nginx CORS rules based on ENV vars
66
#
@@ -9,10 +9,10 @@ set -euo pipefail
99
# - NGINX_CORS_RESOURCE_POLICY: defaults to 'same-origin'
1010

1111
# Set defaults & clean up (normalize, trim, …)
12-
NGINX_CONFIG_FILE=/etc/nginx/snippets/vars/cors-origin.conf
13-
NGINX_CORS_ORIGINS=$(echo "${NGINX_CORS_ORIGINS:-*}" \
12+
readonly NGINX_CONFIG_FILE=/etc/nginx/snippets/vars/cors-origin.conf
13+
readonly NGINX_CORS_ORIGINS=$(echo "${NGINX_CORS_ORIGINS:-*}" \
1414
| sed 's/,/ /g; s/^ *//; s/ *$//; s/ */ /g')
15-
NGINX_CORS_RESOURCE_POLICY="${NGINX_CORS_RESOURCE_POLICY:-same-origin}"
15+
readonly NGINX_CORS_RESOURCE_POLICY="${NGINX_CORS_RESOURCE_POLICY:-same-origin}"
1616

1717
# Check nginx structure
1818
if [ ! -f "${NGINX_CONFIG_FILE}" ]; then

common/scripts/startup/50-env-configure-nginx-csp.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
# Configure nginx security based on ENV vars, and if available the defaults
66
# located at `/etc/csp-generator/default`.
@@ -19,17 +19,17 @@ set -euo pipefail
1919
# - NGINX_FRAME_OPTIONS: defaults to 'deny', note that setting to `disable` removes the header completely.
2020

2121
# Set defaults
22-
NGINX_CONFIG_FILE='/etc/nginx/snippets/vars/csp-and-robots.conf'
23-
NGINX_CSP_ITEMS='child-src connect-src font-src form-action frame-ancestors frame-src img-src manifest-src media-src object-src require-trusted-types-for script-src style-src trusted-types worker-src'
24-
NGINX_CSP_MODE="${NGINX_CSP_MODE:-report-only}"
25-
NGINX_CSP_REPORT_URI="${NGINX_CSP_REPORT_URI:-}"
26-
NGINX_FRAME_OPTIONS="${NGINX_FRAME_OPTIONS:-deny}"
22+
readonly NGINX_CONFIG_FILE='/etc/nginx/snippets/vars/csp-and-robots.conf'
23+
readonly NGINX_CSP_ITEMS='child-src connect-src font-src form-action frame-ancestors frame-src img-src manifest-src media-src object-src require-trusted-types-for script-src style-src trusted-types worker-src'
24+
readonly NGINX_CSP_MODE="${NGINX_CSP_MODE:-report-only}"
25+
readonly NGINX_CSP_REPORT_URI="${NGINX_CSP_REPORT_URI:-}"
26+
readonly NGINX_FRAME_OPTIONS="${NGINX_FRAME_OPTIONS:-deny}"
2727

2828
# Validate input
2929
if [ "${NGINX_CSP_MODE}" = 'enforce' ]; then
30-
NGINX_CSP_VAR_NAME='content_security_policy'
30+
readonly NGINX_CSP_VAR_NAME='content_security_policy'
3131
elif [ "${NGINX_CSP_MODE}" = 'report-only' ]; then
32-
NGINX_CSP_VAR_NAME='content_security_policy_report_only'
32+
readonly NGINX_CSP_VAR_NAME='content_security_policy_report_only'
3333
else
3434
echo "Nginx: invalid CSP mode ${NGINX_CSP_MODE}"
3535
exit 1

common/scripts/startup/50-env-configure-nginx-robots.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
# Configure nginx robots rules based on ENV vars
66
#
@@ -9,10 +9,10 @@ set -euo pipefail
99
# - NGINX_ROBOTS_TXT: defaults to 'Disallow: /', note that setting to `disable` removes the rule completely.
1010

1111
# Set defaults
12-
NGINX_CONFIG_FILE_MODS=/etc/nginx/site-mods-enabled.d/generated-robots.conf
13-
NGINX_CONFIG_FILE_VARS=/etc/nginx/snippets/vars/robots-tag.conf
14-
NGINX_ROBOTS_TAG="${NGINX_ROBOTS_TAG:-none}"
15-
NGINX_ROBOTS_TXT="${NGINX_ROBOTS_TXT:-Disallow: /}"
12+
readonly NGINX_CONFIG_FILE_MODS=/etc/nginx/site-mods-enabled.d/generated-robots.conf
13+
readonly NGINX_CONFIG_FILE_VARS=/etc/nginx/snippets/vars/robots-tag.conf
14+
readonly NGINX_ROBOTS_TAG="${NGINX_ROBOTS_TAG:-none}"
15+
readonly NGINX_ROBOTS_TXT="${NGINX_ROBOTS_TXT:-Disallow: /}"
1616

1717
# robots tag header
1818
if [ -f "${NGINX_CONFIG_FILE_VARS}" ]; then

matomo/scripts/commands/init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
config_file="/var/www/html/config/config.ini.php"
66

matomo/scripts/startup/50-unzip-matomo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
if [ ! -e matomo.php ]; then
66
tar cf - --one-file-system -C /usr/src/matomo . | tar xf -

nuxt-base/config/s6-overlay/node-memory-monitor/data/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
# Configure PHP FPM `pm` based on ENV vars
66
#

nuxt-base/scripts/startup/50-prep-nginx-ready-check.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env sh
22

3-
set -euo pipefail
3+
set -eu
44

55
# Prep. nginx config files so memory monitor service can disable probes
66

77
if [ -d /etc/nginx/site-mods-enabled.d/ ]; then
8-
NGINX_CONFIG_FILE=/etc/nginx/snippets/nuxt-probes-content.conf
8+
readonly NGINX_CONFIG_FILE=/etc/nginx/snippets/nuxt-probes-content.conf
99

1010
# Default nginx config (i.e. just forward to API)
1111
cat <<EOF > "$NGINX_CONFIG_FILE"

0 commit comments

Comments
 (0)