deploy: make the Caddy hash grep defensive under set -e

A missing CADDY_*_HASH in the .env made the 'grep | tail | cut' pipeline
return non-zero, which aborted the deploy under 'set -e' before it could warn
and keep the placeholder. Add '|| true' so an absent hash warns instead of
aborting. (The homepage deploy aborted here because CADDY_ADMIN_HASH was not
in the repo-root .env the deploy reads.)
This commit is contained in:
Frank
2026-08-23 15:25:53 -07:00
parent cc1f421d27
commit f400be76c6
+3 -2
View File
@@ -163,8 +163,9 @@ if [ '${COPY_SHARED[$TARGET]}' = '1' ]; then
echo ' Rendering Caddyfile (basicauth hashes from .env)...' echo ' Rendering Caddyfile (basicauth hashes from .env)...'
# Extract the hashes with grep/cut rather than sourcing .env: sourcing a # Extract the hashes with grep/cut rather than sourcing .env: sourcing a
# bcrypt value in a set -u shell dies on its dollar-sign expansion. # bcrypt value in a set -u shell dies on its dollar-sign expansion.
CADDY_BASICAUTH_HASH=\"\$(grep -E '^CADDY_BASICAUTH_HASH=' .env | tail -1 | cut -d= -f2-)\" # '|| true' so a missing hash warns below instead of aborting under set -e.
CADDY_ADMIN_HASH=\"\$(grep -E '^CADDY_ADMIN_HASH=' .env | tail -1 | cut -d= -f2-)\" CADDY_BASICAUTH_HASH=\"\$(grep -E '^CADDY_BASICAUTH_HASH=' .env 2>/dev/null | tail -1 | cut -d= -f2- || true)\"
CADDY_ADMIN_HASH=\"\$(grep -E '^CADDY_ADMIN_HASH=' .env 2>/dev/null | tail -1 | cut -d= -f2- || true)\"
if [ -n \"\${CADDY_BASICAUTH_HASH}\" ] && [ -n \"\${CADDY_ADMIN_HASH}\" ]; then if [ -n \"\${CADDY_BASICAUTH_HASH}\" ] && [ -n \"\${CADDY_ADMIN_HASH}\" ]; then
# '|' delimiter: the bcrypt hash contains '/' characters. # '|' delimiter: the bcrypt hash contains '/' characters.
mkdir -p /home/dank/Containers/caddy mkdir -p /home/dank/Containers/caddy