From 4127b47cd6603d328e540f4f69f66fad9b303fa7 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Mon, 29 Sep 2014 21:57:08 +0100 Subject: [PATCH] Enable use of systemd + socket activation support for Debian package Now that onak supports systemd socket activation add the appropriate systemd service files to enable this on Debian installs. In the longer term I'd like this to be generic for any distro; patches from people experienced with them most welcome. --- debian/changelog | 1 + debian/onak.service | 9 +++++++++ debian/onak.socket | 7 +++++++ debian/postinst | 10 ++++++++++ debian/prerm | 8 ++++++++ debian/rules | 9 ++++++++- 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 debian/onak.service create mode 100644 debian/onak.socket create mode 100644 debian/prerm diff --git a/debian/changelog b/debian/changelog index 60fe981..9565cb3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ onak (0.4.2-1+git) unstable; urgency=low * Development build * Fix issue with pre-seeding key database on install. + * Add systemd service files using new systemd socket activation support. -- Jonathan McDowell Sun, 06 Oct 2013 13:18:38 +0100 diff --git a/debian/onak.service b/debian/onak.service new file mode 100644 index 0000000..efc1718 --- /dev/null +++ b/debian/onak.service @@ -0,0 +1,9 @@ +[Unit] +Description=Backend caching key daemon for onak OpenPGP keyserver +Documentation=man:keyd +Requires=onak.socket + +[Service] +User=onak +ExecStart=/usr/sbin/keyd -f +ExecStop=/usr/bin/keydctl quit diff --git a/debian/onak.socket b/debian/onak.socket new file mode 100644 index 0000000..7e317d5 --- /dev/null +++ b/debian/onak.socket @@ -0,0 +1,7 @@ +[Socket] +ListenStream=/var/lib/onak/keyd.sock +SocketUser=onak +SocketMode=0660 + +[Install] +WantedBy=sockets.target diff --git a/debian/postinst b/debian/postinst index c954775..40d0d5f 100644 --- a/debian/postinst +++ b/debian/postinst @@ -51,3 +51,13 @@ if [ "$1" = "configure" ]; then fi #DEBHELPER# + +# +# With the move to systemd this will force systemd to start keyd even if it's +# disabled in the onak config file; the systemd service file can't check the +# way the init script does. Work around this by doing the check here and +# only calling invoke-rc.d if it's actually enabled. +# +if grep -q -E '^use_keyd *(true|yes|1)$' /etc/onak.conf; then + invoke-rc.d onak start || exit $? +fi diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..7fdade5 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,8 @@ +#! /bin/sh + +# If keyd was enabled then make sure to stop it. +if grep -q -E '^use_keyd *(true|yes|1)$' /etc/onak.conf; then + invoke-rc.d onak stop || exit $? +fi + +#DEBHELPER# diff --git a/debian/rules b/debian/rules index 4c1e6dd..f5e30f3 100755 --- a/debian/rules +++ b/debian/rules @@ -5,4 +5,11 @@ DEB_CONFIGURE_EXTRA_FLAGS += --enable-backend=dynamic CFLAGS += -std=gnu99 %: - dh "$@" --with autoreconf + dh "$@" --with autoreconf,systemd + +override_dh_installinit: + dh_installinit --no-start + +override_dh_systemd_enable: + dh_systemd_enable --no-enable debian/onak.service + dh_systemd_enable --no-enable debian/onak.socket -- 2.39.5