This draft describes how systemd packaging should be done in Debian. It will be integrated into Systemd once it has been reviewed.
- Unit files should be installed to /lib/systemd/system/ under the same name (with .service suffix) as the init script. E.g. for a package shipping /etc/init.d/libvirt-bin, the corresponding service file should be /lib/systemd/system/libvirt-bin.service
- tmpfiles.d(5) configuration files should go to /usr/lib/tmpfiles.d/
The systemctl enable and systemctl start actions are performed through update-rc.d and invoke-rc.d (NOTE: These don’t provide the necessary code yet! See bug #683084 for a patch)
dh_installinit contains code to call systemd-tmpfiles --create when running under systemd and installs debian/<package>.service and debian/<package>.tmpfile to the proper locations (NOTE: You need debhelper from git for that)
- Avoid using Accept=yes in .socket files, because service(8) cannot stop that service correctly. E.g. you have approx.socket and approx@.service, which gets expanded to approx@1-::1:9999-::1:44903.service, then service approx stop will not work.
Calling systemctl enable on Debian will also run update-rc.d enable and vice-versa so that you can switch to and from systemd without losing this configuration.
- invoke-rc.d will automatically proxy its actions to systemd on systems running systemd
Custom actions are still passed to the initscript directly, for example the _cron action of /etc/init.d/atop. The actions which are passed to systemd are start, stop, restart, status, reload, force-stop and force-reload.
TODO: Do we want to recommend not using custom actions in initscripts?
To determine whether systemd is currently running on a system, use [ -d /run/systemd/system ]
Please don’t use After=syslog.target. It’s obsolete since syslog services are socket-activated nowadays.
- in postrm we need systemctl --system daemon-reload