From d8b3d46634ecead671bdcaca9b965101fd847e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Tue, 28 Apr 2026 21:25:07 -0300 Subject: [PATCH] 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 Signed-off-by: Martin Renvoize Signed-off-by: Pedro Amorim --- debian/control | 2 ++ debian/control.in | 2 ++ debian/koha-systemd.postinst | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/debian/control b/debian/control index a9acc27f0e..b7f8286b71 100644 --- a/debian/control +++ b/debian/control @@ -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). diff --git a/debian/control.in b/debian/control.in index 8b9a02450a..9703bc3f40 100644 --- a/debian/control.in +++ b/debian/control.in @@ -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). diff --git a/debian/koha-systemd.postinst b/debian/koha-systemd.postinst index ab66ad23b0..3e5593e0a5 100644 --- a/debian/koha-systemd.postinst +++ b/debian/koha-systemd.postinst @@ -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