Fix authelia.sh skipping the real Caddy snippet due to a commented example
grep -q "(authelia)" matches caddy.sh's starter Caddyfile's own commented-
out example block ("# (authelia) {", included as documentation), so
authelia.sh believed the real snippet already existed and never wrote
it. Any later service adding `import authelia` to its own site block
then references a snippet that only exists as a comment.
Confirmed live: this takes Caddy down completely, not just the
Authelia-protected site — "Error: adapting config using caddyfile:
File to import not found: authelia" is a load-time failure, so Caddy
restart-loops and every site it fronts goes with it.
Anchor the check to an actual uncommented snippet definition
(^\(authelia\)\s*\{) instead of a bare substring match.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H4k6J1qXXyYxhGEgnJaMvn
This commit is contained in:
+10
-1
@@ -425,7 +425,16 @@ AUTHELIA_USERS
|
||||
local CADDY_FILE="$DOCKER_DIR/caddy/Caddyfile"
|
||||
if [ -f "$CADDY_FILE" ]; then
|
||||
echo " Configuring Caddy for Authelia..."
|
||||
if ! grep -q "(authelia)" "$CADDY_FILE"; then
|
||||
# Anchored to an actual, uncommented snippet definition — a bare
|
||||
# `grep -q "(authelia)"` also matches the commented-out example
|
||||
# block caddy.sh's starter Caddyfile ships ("# (authelia) {" as
|
||||
# documentation). Confirmed live: that false match made this skip
|
||||
# writing the real snippet entirely, leaving any later `import
|
||||
# authelia` reference elsewhere in the file dangling — Caddy then
|
||||
# refuses to start at all ("File to import not found: authelia"),
|
||||
# taking down every site it fronts, not just the Authelia-protected
|
||||
# one.
|
||||
if ! grep -qE '^\(authelia\)[[:space:]]*\{' "$CADDY_FILE"; then
|
||||
cp "$CADDY_FILE" "$CADDY_FILE.backup.$(date +%Y%m%d-%H%M%S)"
|
||||
{ cat << 'SNIPPET_EOF'
|
||||
# ── Authelia forward auth snippet ─────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user