Howto prevent service restarts on Debian package upgrades

Prevent the restart of daemons from Debian package upgrades.

Proper written postinstall scripts for Debian packages utilize deb-systemd-invoke to restart systemd units after installation and upgrade of packages.

deb-systemd-invoke in turn uses policy-rc-d to determine if a service can be restarted or not.

To manipulate the default behaviour, the package policy-rcd-declarative-allow-all or policy-rcd-declarative-deny-all can be installed.

Setup

apt install policy-rcd-declarative policy-rcd-declarative-deny-all
apt purge policy-rcd-declarative-allow-all

Reference

Moritz Kraus