Bug 40901: (QA follow-up) Fix koha-sysv.postinst configure guard and double-enable

Two problems in the original koha-sysv.postinst:

1. #DEBHELPER# was placed at the top (line 5) before any case statement,
   so whatever dh_installsystemd expands it to ran for ALL postinst
   invocations (abort-upgrade, abort-remove, triggered…), not just
   configure.

2. The custom block manually called `deb-systemd-helper enable
   koha-common.service` on systemd hosts.  Because koha-sysv also ships
   koha-sysv.service (which dh_installsystemd enables via #DEBHELPER#),
   both koha-sysv.service and the sysv-generator-created koha-common.service
   could end up enabled, resulting in a double-start of the init script
   at boot.

Fix both by wrapping the custom code in `case "$1" in configure)`, moving
manual enable: dh_installsystemd already enables and starts
koha-sysv.service correctly.

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:
Martin Renvoize 2026-05-21 17:50:42 +01:00 committed by Pedro Amorim
parent 53ebfcb8c5
commit 6d3b026d91
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 13 additions and 12 deletions

View File

@ -2,18 +2,19 @@
set -e
case "$1" in
configure)
# Bug 18250: Correct startup order of koha-common and memcached.
# On non-systemd systems only: force the rc.d ordering.
# On systemd, dh_installsystemd (via #DEBHELPER# below) enables and
# starts koha-sysv.service automatically; no manual enable needed.
if [ ! -d /run/systemd/system ]; then
update-rc.d koha-common disable
update-rc.d koha-common enable
fi
;;
esac
#DEBHELPER#
# Enable and start the service on systemd systems
if [ -d /run/systemd/system ]; then
deb-systemd-helper enable koha-common.service >/dev/null || true
deb-systemd-invoke start koha-common.service >/dev/null || true
else
# Bug 18250: Correct startup order of koha-common and memcached
# Since the init script has been updated, we can force the order in rc.d
# by disabling and enabling again.
update-rc.d koha-common disable
update-rc.d koha-common enable
fi
exit 0