gregor herrmann: [...] > But I also started looking at deb-systemd-helper (in > init-system-helpers) and found an interesting example: > > https://sources.debian.net/src/isatapd/0.9.7-2/debian/postinst/?hl=12#L12 > > Maybe this is the way to go? > (And if yes: "disable" or "mask"?)
The code in the above link is what I expected to help: sourcing in the
/etc/default file, and having systemd enable or disable the service in
the postinst.
I just had a look at the way this is being done in the vsftpd package;
it Buidl-Depends on dh-systemd, and in the debian/rules file it has:
dh ${@} --parallel --with=systemd
which is the same as you have in iodine, except for the --parallel...
where it differes slightly is in debian/postinst where it has the
following snippet in the "configure" case:
if [ -f "systemd-tmpfiles" ]
then
systemd-tmpfiles --create --exclude-prefix=/dev
fi
;;
When the package installs, it appears dh_systemd_enable modifies the
vsftpd.postinst file (thus the file in /var/lib/dpkg info differs from
that of the source package after installation -- ugh) which removes the
above snippet and adds the following after the case statement:
-------------------------------------------------------------------
# Automatically added by dh_systemd_enable
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask vsftpd.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled vsftpd.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable vsftpd.service >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need
to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state vsftpd.service >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/vsftpd" ]; then
update-rc.d vsftpd defaults >/dev/null
invoke-rc.d vsftpd start || exit $?
fi
# End automatically added section
-------------------------------------------------------------------
The 'purge' case of the vsftpd.postrm has this:
-------------------------------------------------------------------
purge)
#
# purge systemd files
#
rm -f /etc/systemd/system/vsftpd.service
rm -f /etc/systemd/system/multi-user.target.wants/vsftpd.service
rm -f
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/vsftpd.service
rm -f
/var/lib/systemd/deb-systemd-helper-enabled/vsftpd.service.dsh-also
rm -f /var/lib/systemd/deb-systemd-helper-masked/vsftpd.service
if [ -d
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/ ]; then
rmdir --ignore-fail-on-non-empty
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/
fi
if [ -d /var/lib/systemd/deb-systemd-helper-enabled ]; then
rmdir --ignore-fail-on-non-empty
/var/lib/systemd/deb-systemd-helper-enabled
fi
if [ -d /var/lib/systemd/deb-systemd-helper-masked ]; then
rmdir --ignore-fail-on-non-empty
/var/lib/systemd/deb-systemd-helper-masked
fi
;;
-------------------------------------------------------------------
and after installation the file in /var/lib/dpkg/info/vsftpd.postrm has
the entirety of the above snippet removed, with the following added
after the case statement:
-------------------------------------------------------------------
# Automatically added by dh_installinit
if [ "$1" = "purge" ] ; then
update-rc.d vsftpd remove >/dev/null
fi
# In case this system is running systemd, we make systemd reload the
unit files
# to pick up changes.
if [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_systemd_enable
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask vsftpd.service >/dev/null
fi
fi
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge vsftpd.service >/dev/null
deb-systemd-helper unmask vsftpd.service >/dev/null
fi
fi
# End automatically added section
# Automatically added by dh_installdebconf
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
db_purge
fi
# End automatically added section
-------------------------------------------------------------------
This seems to be ... a bit more confusing than I would have hoped.
-- Chris
--
Chris Knadle
[email protected]
signature.asc
Description: OpenPGP digital signature

