mirror of
https://github.com/wekan/wekan.git
synced 2026-11-08 11:25:19 -05:00
When upgrading from an old WeKan snap, $SNAP_COMMON/Caddyfile may still be in Caddy v1 format, which Caddy 2 cannot parse (so caddy would fail to start). caddy-control now runs migrate-caddyfile-v1-to-v2.sh before 'caddy run' when caddy is enabled. It is safe: a no-op if the file already parses as Caddy 2; otherwise it backs up the original, converts the common v1 directives (drop the http:// scheme, 'proxy / TARGET' -> 'reverse_proxy TARGET', drop the v1 'websocket'/'transparent' presets that Caddy 2 does by default, 'gzip' -> 'encode gzip'), validates the result with 'caddy adapt', and only keeps it if valid — falling back to the shipped Caddy 2 template otherwise, so caddy always starts with valid config. Thanks to xet7.
24 lines
1.0 KiB
Bash
Executable File
24 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ "$PATH" != *"$SNAP_INSTANCE_NAME"* ]]; then
|
|
export PATH="${PATH/\/snap\/wekan\//\/snap\/$SNAP_INSTANCE_NAME\/}"
|
|
fi
|
|
|
|
# Get wekan/mongo settings
|
|
source $SNAP/bin/wekan-read-settings
|
|
|
|
if [ "$CADDY_ENABLED" = "true" ]; then
|
|
# If upgrading from an old WeKan snap, $SNAP_COMMON/Caddyfile may still be in
|
|
# Caddy v1 format, which Caddy 2 cannot parse. Migrate it to v2 first (no-op if
|
|
# already valid v2; backs up + validates + falls back to the shipped template).
|
|
CADDY="$SNAP/bin/caddy" bash "$SNAP/bin/migrate-caddyfile-v1-to-v2.sh" "$SNAP_COMMON/Caddyfile" || true
|
|
# Use Caddy 2 command format
|
|
# The 'host' option is no longer needed in Caddy 2
|
|
# The 'agree' option is no longer needed as Caddy 2 doesn't prompt for EULA
|
|
env LC_ALL=C caddy run --config $SNAP_COMMON/Caddyfile
|
|
else
|
|
echo "caddy is disabled. Service stopping disabled"
|
|
# snapctl stop --disable ${SNAP_NAME}.caddy
|
|
# sleep here, in case snapctl fails to stop service so we do not restart too often
|
|
fi
|