LinuxCommandLibrary

deb-systemd-helper.

Enable/disable systemd services during package installation

SYNOPSIS

deb-systemd-helper [--quiet] [--no-restart-after-upgrade] [--no-restart-on-upgrade] [--no-reload-after-upgrade] [--no-reload-on-upgrade] [--no-restart] [--no-reload] [--no-reenable-on-upgrade] {verb|update-state} unit [unit ...]
deb-systemd-helper [--help] [--version]

PARAMETERS

--quiet
    Suppress non-error output

--no-restart-after-upgrade
    Do not restart unit after package upgrade

--no-restart-on-upgrade
    Do not restart unit during upgrade

--no-reload-after-upgrade
    Do not reload unit after package upgrade

--no-reload-on-upgrade
    Do not reload unit during upgrade

--no-restart
    Do not restart unit after verb actions

--no-reload
    Do not reload unit after verb actions

--no-reenable-on-upgrade
    Do not re-enable unit on upgrade

--help
    Show help and exit

--version
    Show version and exit

DESCRIPTION

deb-systemd-helper is a script from the Debian systemd package, invoked by package maintainer scripts (preinst, postinst, prerm, postrm) to manage systemd units during installation, upgrade, or removal.

It handles enabling/disabling units, starting/stopping services, and masking/unmasking, while detecting native systemd support vs. SysV fallback. Uses /run/deb-systemd-helper/ for temporary symlinks, ensuring safe operations without dh-systemd dependency.

Key uses: enable links unit to targets post-install; disable removes links on purge; update-state rescans enabled units after adding files. Upgrade flags like --no-restart-after-upgrade prevent disruptions.

Supports multi-unit handling and quiet mode. Ensures idempotency and proper error handling, logging to stderr. Essential for Debian packages shipping .service files, simplifying systemd integration.

CAVEATS

Intended for maintainer scripts only, not direct user invocation. Behavior varies by dpkg action (install/upgrade/remove). Relies on /run writable; may fail in chroot without systemd. Not for runtime service control.

VERBS

enable, disable, start, stop, restart, reload-or-restart, is-enabled, mask, unmask (reenabling deprecated)

EXIT STATUS

0 on success; non-zero on failure. Logs errors to stderr.

EXAMPLES

postinst: deb-systemd-helper enable foo.service && systemctl daemon-reload
prerm: deb-systemd-helper disable foo.service && systemctl daemon-reload
postrm: deb-systemd-helper update-state foo.service

HISTORY

Introduced in Debian with systemd 215 (Jessie, 2015) to ease unit management without rebuilding packages. Evolved in later versions for better upgrade handling and verb support. Now standard in Debian/Ubuntu for hybrid SysV/systemd setups.

SEE ALSO

systemctl(1), dh_installsystemd(1), invoke-rc.d(8), update-rc.d(8)

Copied to clipboard