Bug 40901: (QA follow-up) Don't stop all Koha services on every koha-systemd upgrade

The postinst stopped and disabled koha-common.service on every
configure, which after migration means every upgrade of this package
shuts down every Koha instance. Now it only happens on first install,
where it exists to stop the old SysV-started services. The hand-rolled
deletion of the old init script is replaced with dpkg's standard
rm_conffile mechanism.

https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40901#c130
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Kyle M Hall 2026-07-24 12:12:04 -04:00 committed by Pedro Amorim
parent 67ec61a60f
commit a46f1aa4ca
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
2 changed files with 15 additions and 17 deletions

1
debian/koha-common.maintscript vendored Normal file
View File

@ -0,0 +1 @@
rm_conffile /etc/init.d/koha-common 25.11~

View File

@ -6,26 +6,23 @@ case "$1" in
# Reload systemd daemon
systemctl daemon-reload || true
# Stop and disable the legacy SysV koha-common.service if present.
# This service is auto-generated by systemd-sysv-generator from
# /etc/init.d/koha-common and would run in parallel with the native
# systemd units, causing double-starts.
if systemctl is-active --quiet koha-common.service 2>/dev/null; then
systemctl stop koha-common.service || true
fi
if systemctl is-enabled --quiet koha-common.service 2>/dev/null; then
systemctl disable koha-common.service || true
fi
# Remove the orphaned SysV init script if it was left behind by
# the old koha-common package (pre-split) and koha-sysv is not installed.
if [ -f /etc/init.d/koha-common ] && ! dpkg -s koha-sysv >/dev/null 2>&1; then
rm -f /etc/init.d/koha-common
systemctl daemon-reload || true
fi
# On first install (no previous version), enable units for all existing instances
# This handles migration from SysV init to systemd
if [ -z "$2" ]; then
# Stop and disable the legacy SysV koha-common.service if present.
# This service is auto-generated by systemd-sysv-generator from
# /etc/init.d/koha-common and would run in parallel with the native
# systemd units, causing double-starts. Only do this on first
# install: after migration, koha-common.service is our own compat
# unit, and stopping it here would stop every instance on each
# upgrade of this package.
if systemctl is-active --quiet koha-common.service 2>/dev/null; then
systemctl stop koha-common.service || true
fi
if systemctl is-enabled --quiet koha-common.service 2>/dev/null; then
systemctl disable koha-common.service || true
fi
for instance in $(koha-list --enabled 2>/dev/null); do
# Core services: always enable
systemctl enable koha-zebra@${instance}.service 2>/dev/null || true