The preremove script was unconditionally stopping and disabling the service, which meant upgrades (dpkg -i new.deb) would disable the service. Users had to manually re-enable after every upgrade. Now: - preremove: only stop+disable on actual removal (not upgrade) Checks $1 for "remove"/"purge" (deb) or "0" (rpm) - postinstall: restart the service on upgrade if it was running, preserving enable/disable state. Only shows first-install instructions on initial install. Tested with shellcheck. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
982 B
Bash
Executable file
30 lines
982 B
Bash
Executable file
#!/bin/sh
|
|
# Pre-remove script for Favoritter .deb/.rpm package.
|
|
# Only stops and disables the service on actual removal, not on upgrade.
|
|
#
|
|
# Debian/Ubuntu: called with "remove" on uninstall, "upgrade" on upgrade.
|
|
# RPM (Fedora/RHEL): called with 0 on final removal, 1+ on upgrade.
|
|
set -e
|
|
|
|
action="${1:-}"
|
|
|
|
case "$action" in
|
|
# Debian: full removal.
|
|
remove|purge)
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
systemctl stop favoritter 2>/dev/null || true
|
|
systemctl disable favoritter 2>/dev/null || true
|
|
fi
|
|
;;
|
|
# RPM: $1 is the number of remaining installations.
|
|
0)
|
|
if command -v systemctl >/dev/null 2>&1; then
|
|
systemctl stop favoritter 2>/dev/null || true
|
|
systemctl disable favoritter 2>/dev/null || true
|
|
fi
|
|
;;
|
|
# Debian "upgrade" or RPM "1+" — do nothing, the service stays running.
|
|
# The new postinstall will daemon-reload and restart.
|
|
*)
|
|
;;
|
|
esac
|