package/quagga: Add systemd.service file
authorNathaniel Roach <nroach44@gmail.com>
Sun, 3 Jul 2016 08:18:59 +0000 (16:18 +0800)
committerPeter Korsgaard <peter@korsgaard.com>
Sun, 3 Jul 2016 14:04:34 +0000 (16:04 +0200)
Use a template service file as all of the daemons use almost
identical arguments and generally appear the same to the init
system.

We "Wants=" zebra as that's the daemon for interfacing to the
kernel, and it's not required for the other daemons to work
but it's probably going to be used in nearly all setups.

/usr/bin/env is needed as systemd doesn't allow the instance
variable (%i) in the executable path.

We don't enable these services by default as this would require
creating configuration and /etc/default files. (And is easily
achieved with an FS overlay)

[Peter: remove killmode/killsignal/restartsec as suggested by Maxime]
Signed-off-by: Nathaniel Roach <nroach44@gmail.com>
Reviewed-by: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
package/quagga/quagga.mk
package/quagga/quagga@.service [new file with mode: 0644]

index 22e90add2c35beb896d4b9a7005a68c62e9b8663..1bbc72dee7a517a3e23d8fe9f2af1400a88fff24 100644 (file)
@@ -75,6 +75,8 @@ endif
 define QUAGGA_INSTALL_INIT_SYSTEMD
        $(INSTALL) -D -m 644 package/quagga/quagga_tmpfiles.conf \
                $(TARGET_DIR)/usr/lib/tmpfiles.d/quagga.conf
+       $(INSTALL) -D -m 644 package/quagga/quagga@.service \
+               $(TARGET_DIR)/usr/lib/systemd/system/quagga@.service
 endef
 
 $(eval $(autotools-package))
diff --git a/package/quagga/quagga@.service b/package/quagga/quagga@.service
new file mode 100644 (file)
index 0000000..797af32
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=Quagga %i routing daemon
+ConditionFileIsExecutable=/usr/sbin/%i
+Wants=quagga@zebra.service
+
+[Service]
+Type=simple
+EnvironmentFile=/etc/default/quagga-%i
+PrivateTmp=true
+# Systemd doesn't like having %i in the executable path.
+ExecStart=/usr/bin/env /usr/sbin/%i $OPTS -f /etc/quagga/%i.conf
+ExecReload=/bin/kill -HUP $MAINPID
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
+