Bug 40901: (follow-up) Fix parallel execution of SysV and systemd services

When upgrading from the old koha-common (pre-split) to the new
koha-core + koha-systemd packages, the SysV init script
/etc/init.d/koha-common is left behind as an orphan. The
systemd-sysv-generator auto-creates koha-common.service from it,
which runs in parallel with the native systemd units, causing
double-starts of all Koha services.

Changes:
- koha-systemd.postinst now stops, disables, and removes the
  orphaned SysV init script when koha-sysv is not installed
- koha-sysv gets Replaces/Breaks on koha-common (<< 25.11) so
  dpkg can cleanly take over the init script file

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
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:
Tomás Cohen Arazi 2026-04-28 21:25:07 -03:00 committed by Pedro Amorim
parent 6763a3048b
commit d8b3d46634
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
3 changed files with 21 additions and 0 deletions

2
debian/control vendored
View File

@ -498,6 +498,8 @@ Architecture: all
Depends: ${misc:Depends}, daemon, koha-core
Provides: koha-init
Conflicts: koha-systemd
Replaces: koha-common (<< 25.11)
Breaks: koha-common (<< 25.11)
Description: SysV init scripts for Koha ILS
Koha is an Integrated Library Management system for real-world libraries
(the kinds with books).

2
debian/control.in vendored
View File

@ -162,6 +162,8 @@ Architecture: all
Depends: ${misc:Depends}, daemon, koha-core
Provides: koha-init
Conflicts: koha-systemd
Replaces: koha-common (<< 25.11)
Breaks: koha-common (<< 25.11)
Description: SysV init scripts for Koha ILS
Koha is an Integrated Library Management system for real-world libraries
(the kinds with books).

View File

@ -6,6 +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