Files
madcat-caddy/debian/preinst
T
BT-7274 3f911ab7a6 fix: handle masked/missing caddy.service during package transition
Fixes the postinst failure when replacing stock caddy on hosts where
caddy.service was masked. The unit file could be missing after dpkg
removes the old caddy package, causing systemctl enable to fail.

Changes:
- postinst: unmask caddy.service before enable, recreate unit file
  from embedded copy if missing after unmasking, stop caddy-api.service
  with guard
- preinst (new): stop caddy.service and caddy-api.service with || true
  guards before install/upgrade
- Makefile: include preinst in deb build

Handles three scenarios:
1. Fresh install (no prior caddy)
2. Upgrade from stock caddy with masked service
3. Upgrade from previous madcat-caddy

Closes #1
2026-06-12 21:24:11 +02:00

15 lines
462 B
Bash

#!/bin/sh
# preinst for madcat-caddy
#
# Stop existing caddy services before install/upgrade.
# Guards against failures when services don't exist (e.g., caddy-api.service
# from stock caddy may not be present on all systems).
set -e
if [ -d /run/systemd/system ]; then
# Stop stock caddy services — both may not exist, so guard with || true
systemctl stop caddy.service 2>/dev/null || true
systemctl stop caddy-api.service 2>/dev/null || true
fi