Bug#752075: daemontools-run: Add systemd support

Gerrit Pape pape at dbnbgs.smarden.org
Tue Jul 22 13:34:19 BST 2014


On Fri, Jul 18, 2014 at 12:03:41PM +0000, Gerrit Pape wrote:
> I'm really not keen to add a dependency to daemontools-run, esp. not to
> the runit package, just for (un)installing and starting/stopping a
> service.

Hi, I've now prepared this changeset.  Do you have any comments on it?


Author: Gerrit Pape <pape at smarden.org>
Date:   Tue Jul 22 12:26:42 2014 +0000

      * debian/systemd/daemontools.path, debian/systemd/daemontools.service:
        new; daemontools-run systemd unit files (thx Michael Biebl, Jonathan de
        Boyne Pollard, Milan P. Stanic).
      * debian/rules: install daemontools-run systemd unit files.
      * debian/daemontools-run.postinst, debian/daemontools-run.postrm: enable
        and start, disable and stop respectively daemontools units if systemd
        is process 1.

diff --git a/debian/changelog b/debian/changelog
index 8d124f4..d2d4efc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+daemontools (1:0.76-3.1) UNRELEASED; urgency=low
+
+  * debian/systemd/daemontools.path, debian/systemd/daemontools.service:
+    new; daemontools-run systemd unit files (thx Michael Biebl, Jonathan de
+    Boyne Pollard, Milan P. Stanic).
+  * debian/rules: install daemontools-run systemd unit files.
+  * debian/daemontools-run.postinst, debian/daemontools-run.postrm: enable
+    and start, disable and stop respectively, daemontools units if systemd
+    is process 1.
+
+ -- Gerrit Pape <pape at smarden.org>  Tue, 22 Jul 2014 14:00:45 +0200
+
 daemontools (1:0.76-3) unstable; urgency=low
 
   * debian/daemontools-run.postinst: don't exec into the kill program, so
diff --git a/debian/daemontools-run.postinst b/debian/daemontools-run.postinst
index d51ac09..1d7aae1 100644
--- a/debian/daemontools-run.postinst
+++ b/debian/daemontools-run.postinst
@@ -74,3 +74,7 @@ if ! grep '^SV:' /etc/inittab >/dev/null; then
   mv -f /etc/inittab'{new}' /etc/inittab
   kill -s HUP 1
 fi
+if test "$(readlink /sbin/init || :)" = /lib/systemd/systemd; then
+  systemctl enable -f daemontools.path
+  systemctl start daemontools.path
+fi
diff --git a/debian/daemontools-run.postrm b/debian/daemontools-run.postrm
index 683e8dc..04f5299 100644
--- a/debian/daemontools-run.postrm
+++ b/debian/daemontools-run.postrm
@@ -16,3 +16,10 @@ if grep -q "#-- daemontools-run begin" /etc/inittab; then
   echo 'Sending log services the TERM and CONT signals...'
   svc -dx /etc/service/*/log || :
 fi
+if test "$(readlink /sbin/init || :)" = /lib/systemd/systemd; then
+  systemctl disable daemontools.path
+  ! systemctl is-active daemontools.path >/dev/null ||
+    systemctl stop daemontools.path
+  ! systemctl is-active daemontools.service >/dev/null ||
+    systemctl stop daemontools.service
+fi
diff --git a/debian/rules b/debian/rules
index eeab545..d7ff9c0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -63,6 +63,10 @@ install-indep: deb-checkdir deb-checkuid
 	install -d -m0755 '$(DIR)'-run/usr/share/man/man8
 	install -m0644 debian/update-service.8 '$(DIR)'-run/usr/share/man/man8/
 	gzip -9 '$(DIR)'-run/usr/share/man/man8/update-service.8
+	#  systemd units
+	install -d -m0755 '$(DIR)'-run/lib/systemd/system
+	install -m0644 debian/systemd/daemontools.* \
+	  '$(DIR)'-run/lib/systemd/system/
 	#  changelog
 	test -r changelog || ln -s daemontools-0.76/src/CHANGES changelog
 
diff --git a/debian/systemd/daemontools.path b/debian/systemd/daemontools.path
new file mode 100644
index 0000000..97ca37b
--- /dev/null
+++ b/debian/systemd/daemontools.path
@@ -0,0 +1,9 @@
+[Unit]
+Description=Daemontools service monitor
+
+[Path]
+DirectoryNotEmpty=/etc/service/
+Unit=daemontools.service
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/systemd/daemontools.service b/debian/systemd/daemontools.service
new file mode 100644
index 0000000..077e6ab
--- /dev/null
+++ b/debian/systemd/daemontools.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Daemontools service scanner
+
+[Service]
+ExecStart=/usr/bin/svscanboot /etc/service/
+Restart=always
+
+[Install]




More information about the Pkg-systemd-maintainers mailing list