-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Describe the bug
When a systemd preset is applied to make new services disabled by default, the rabbitmq-server service should not be automatically started after the installation. I'm using this approach successfully for Debian-maintained packages as well as several other packages from third party repos. However, for RabbitMQ, this does not work.
The root cause is the following snippet in the postinstall script of the package:
# Automatically added by dh_installinit/13.3.4
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -x "/etc/init.d/rabbitmq-server" ]; then
update-rc.d rabbitmq-server defaults >/dev/null
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
invoke-rc.d rabbitmq-server $_dh_action || exit 1
fi
fi
# End automatically added section
This calls invoke-rc.dto start the rabbitmq-server using the package supplied init script - regardless of status of the systemd unit.
I had a look at the Debian-maintained openssh-server package for reference and there the dh_installinit snippet looks like this:
# Automatically added by dh_installinit/13.11.4
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/ssh" ]; then
update-rc.d ssh defaults >/dev/null
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
invoke-rc.d --skip-systemd-native ssh $_dh_action || exit 1
fi
fi
# End automatically added section
Note the --skip-systemd-native flag set for invoke-rc.d - according to debian documentation this "Exits before doing anything if a systemd environment is detected and the requested service is a native systemd unit. ". This would be the correct behaviour from my point of view and the rabbitmq package should be changed to also include this.
I'm not sure how this could be changed - it could be some setting for the debhelper or an update of the debhelper version (13.3.4 vs. 13.11.4) but I don't know where to look. If someone could point me there, I would be open to make a PR out of it.
Reproduction steps
- On a Debian 12 system create a systemd preset to disable new services by default:
echo "disable *" > /etc/systemd/system-preset/99-default-disable.preset. - Install the rabbitmq-server deb package (i.e.
rabbitmq-server_3.13.1-1_all.deb). - Check the service status:
systemctl status rabbitmq-server. It will be started although the unit is in disabled state.
Expected behavior
When the systemd unit is disabled by a preset, the rabbitmq server should not be started on deb package installation.
Additional context
I observed the bug on a debian 12 system:
# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"