Bug#752075: daemontools-run: Add systemd support

Gerrit Pape pape at dbnbgs.smarden.org
Sat Jul 26 14:21:52 BST 2014


On Tue, Jul 22, 2014 at 03:03:02PM +0200, Michael Biebl wrote:
> Am 22.07.2014 14:34, schrieb Gerrit Pape:
> > 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?
> That said, the logic you added is incomplete/broken in several ways:

Hi, I'm about to upload these changes:


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

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

diff --git a/debian/changelog b/debian/changelog
index 8d124f4..a7b7d0e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,14 @@
+daemontools (1:0.76-4) unstable; urgency=low
+
+  * debian/systemd/daemontools.service: new; daemontools-run systemd unit
+    file (thx Michael Biebl, Jonathan de Boyne Pollard, Milan P. Stanic).
+  * debian/rules: install daemontools-run systemd unit file.
+  * debian/daemontools-run.postinst, debian/daemontools-run.postrm: enable
+    and start, disable and stop respectively, daemontools unit if systemd
+    is process 1 (closes: #752075).
+
+ -- Gerrit Pape <pape at smarden.org>  Sat, 26 Jul 2014 09:58:37 +0000
+
 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..7c49b06 100644
--- a/debian/daemontools-run.postinst
+++ b/debian/daemontools-run.postinst
@@ -74,3 +74,10 @@ if ! grep '^SV:' /etc/inittab >/dev/null; then
   mv -f /etc/inittab'{new}' /etc/inittab
   kill -s HUP 1
 fi
+
+# systemd service
+test -h /etc/systemd/system/multi-user.target.wants/daemontools.service ||
+  test ! -d /etc/systemd/system/multi-user.target.wants ||
+    ln -s /lib/systemd/system/daemontools.service \
+      /etc/systemd/system/multi-user.target.wants/
+test ! -d /run/systemd/system || systemctl start daemontools.service
diff --git a/debian/daemontools-run.postrm b/debian/daemontools-run.postrm
index 683e8dc..d27eef5 100644
--- a/debian/daemontools-run.postrm
+++ b/debian/daemontools-run.postrm
@@ -16,3 +16,9 @@ if grep -q "#-- daemontools-run begin" /etc/inittab; then
   echo 'Sending log services the TERM and CONT signals...'
   svc -dx /etc/service/*/log || :
 fi
+
+# systemd service
+test ! -d /run/systemd/system ||
+  ! systemctl is-active daemontools.service >/dev/null ||
+    systemctl stop daemontools.service
+rm -f /etc/systemd/system/multi-user.target.wants/daemontools.service
diff --git a/debian/rules b/debian/rules
index eeab545..21fb57c 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 service
+	install -d -m0755 '$(DIR)'-run/lib/systemd/system
+	install -m0644 debian/systemd/daemontools.service \
+	  '$(DIR)'-run/lib/systemd/system/
 	#  changelog
 	test -r changelog || ln -s daemontools-0.76/src/CHANGES changelog
 
diff --git a/debian/systemd/daemontools.service b/debian/systemd/daemontools.service
new file mode 100644
index 0000000..09d9228
--- /dev/null
+++ b/debian/systemd/daemontools.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Daemontools service supervision
+
+[Service]
+ExecStart=/usr/bin/svscanboot /etc/service/
+Restart=always
+
+[Install]
+WantedBy=multi-user.target




More information about the Pkg-systemd-maintainers mailing list