amangs commited on
Commit
f764d85
·
1 Parent(s): c8b7138

Auto-validate and restore /data/Caddyfile on boot to prevent syntax crashes

Browse files
Files changed (1) hide show
  1. entrypoint.sh +3 -3
entrypoint.sh CHANGED
@@ -31,9 +31,9 @@ for f in /app/services/*.sh; do
31
  done
32
 
33
  # 2. Persistent Caddyfile on /data (user-editable):
34
- # If /data/Caddyfile does NOT exist, seed it from /app/config/Caddyfile.example
35
- if [ ! -f /data/Caddyfile ]; then
36
- echo "📋 Seeding persistent /data/Caddyfile from /app/config/Caddyfile.example..."
37
  cp /app/config/Caddyfile.example /data/Caddyfile
38
  fi
39
 
 
31
  done
32
 
33
  # 2. Persistent Caddyfile on /data (user-editable):
34
+ # If /data/Caddyfile is missing OR has syntax errors, restore from /app/config/Caddyfile.example
35
+ if [ ! -f /data/Caddyfile ] || ! caddy validate --config /data/Caddyfile --adapter caddyfile >/dev/null 2>&1; then
36
+ echo "📋 Restoring valid /data/Caddyfile from /app/config/Caddyfile.example..."
37
  cp /app/config/Caddyfile.example /data/Caddyfile
38
  fi
39