]> the.earth.li Git - onak.git/commitdiff
Enable use of systemd + socket activation support for Debian package
authorJonathan McDowell <noodles@earth.li>
Mon, 29 Sep 2014 20:57:08 +0000 (21:57 +0100)
committerJonathan McDowell <noodles@earth.li>
Mon, 29 Sep 2014 20:57:08 +0000 (21:57 +0100)
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
debian/onak.service [new file with mode: 0644]
debian/onak.socket [new file with mode: 0644]
debian/postinst
debian/prerm [new file with mode: 0644]
debian/rules

index 60fe9814a52b8afdb0683cdc7205be4094695a81..9565cb32c88780af0946432116febb8cec97a98a 100644 (file)
@@ -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 <noodles@earth.li>  Sun, 06 Oct 2013 13:18:38 +0100
 
diff --git a/debian/onak.service b/debian/onak.service
new file mode 100644 (file)
index 0000000..efc1718
--- /dev/null
@@ -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 (file)
index 0000000..7e317d5
--- /dev/null
@@ -0,0 +1,7 @@
+[Socket]
+ListenStream=/var/lib/onak/keyd.sock
+SocketUser=onak
+SocketMode=0660
+
+[Install]
+WantedBy=sockets.target
index c954775252a475f06c4914ca6583161b68330385..40d0d5f9f28289d271a43b9dc9c2243a6bc370dd 100644 (file)
@@ -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 (file)
index 0000000..7fdade5
--- /dev/null
@@ -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#
index 4c1e6ddde8697c297d35f676b7b4a045a116a568..f5e30f303c64c0676ede27b6a888cb3cec3db1e1 100755 (executable)
@@ -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