Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nathaniel Roach <nroach44@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] package/quagga: Add systemd.service file and helper script
Date: Sun, 19 Jun 2016 01:02:00 +0800	[thread overview]
Message-ID: <1466269320-23938-1-git-send-email-nroach44@gmail.com> (raw)

We 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.

We need the helper script as systemd doesn't like having the
instance (%i) in the path to the executable.

Signed-off-by: Nathaniel Roach <nroach44@gmail.com>
---
 package/quagga/quagga-shim     | 51 ++++++++++++++++++++++++++++++++++++++++++
 package/quagga/quagga.mk       |  6 +++++
 package/quagga/quagga at .service | 19 ++++++++++++++++
 3 files changed, 76 insertions(+)
 create mode 100644 package/quagga/quagga-shim
 create mode 100644 package/quagga/quagga at .service

diff --git a/package/quagga/quagga-shim b/package/quagga/quagga-shim
new file mode 100644
index 0000000..1687e7c
--- /dev/null
+++ b/package/quagga/quagga-shim
@@ -0,0 +1,51 @@
+#!/bin/sh
+#Shim for systemd's quagga at .service
+
+export QUAGGA_PATH="/usr/sbin"
+
+# Check if $1 is a valid quagga binary
+case $1 in
+  zebra)
+    export BINARY="zebra"
+    ;;
+
+  bgpd)
+    export BINARY="bgpd"
+    ;;
+
+  ospfd)
+    export BINARY="ospfd"
+    ;;
+
+  ospf6d)
+    export BINARY="bgpd"
+    ;;
+
+  ripd)
+    export BINARY="ripd"
+    ;;
+
+  ripngd)
+    export BINARY="ripngd"
+    ;;
+
+  pimd)
+    export BINARY="pimd"
+    ;;
+
+  *)
+    echo "Must be called with a valid Quagga daemon as the first argument"
+    exit 2
+    ;;
+
+esac
+
+# Check the binary exists
+if [ -e "$QUAGGA_PATH/$BINARY" ]; then
+  shift # Remove the first argument (binary name)
+  "$QUAGGA_PATH/$BINARY" "$@" # Run the daemon with the remaining arguments
+else
+  echo "Binary \"$BINARY\" not found in $QUAGGA_PATH"
+  exit 1
+fi
+
diff --git a/package/quagga/quagga.mk b/package/quagga/quagga.mk
index 22e90ad..5d9c292 100644
--- a/package/quagga/quagga.mk
+++ b/package/quagga/quagga.mk
@@ -75,6 +75,12 @@ 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 at .service \
+		$(TARGET_DIR)/usr/lib/systemd/system/bandwidthd.service
+
+	$(INSTALL) -D -m 755 package/quagga/quagga-shim \
+		$(TARGET_DIR)/usr/sbin/quagga-shim
 endef
 
 $(eval $(autotools-package))
diff --git a/package/quagga/quagga at .service b/package/quagga/quagga at .service
new file mode 100644
index 0000000..3e98318
--- /dev/null
+++ b/package/quagga/quagga at .service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Quagga %i routing daemon
+PartOf=quagga.service
+ReloadPropagatedFrom=quagga.service
+Wants=quagga at zebra.service
+
+[Service]
+PrivateTmp=true
+KillMode=mixed
+Type=forking
+EnvironmentFile=/etc/default/quagga-%i
+ExecStart=/usr/sbin/quagga-shim %i --daemon $OPTS -f /etc/quagga/%i.conf -i /var/run/quagga/%i.pid
+PIDFile=/var/run/quagga/%i.pid
+KillSignal=SIGINT
+Restart=on-failure
+RestartSec=1
+
+[Install]
+WantedBy=multi-user.target
-- 
2.8.1

             reply	other threads:[~2016-06-18 17:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-18 17:02 Nathaniel Roach [this message]
2016-06-22 21:49 ` [Buildroot] [PATCH 1/1] package/quagga: Add systemd.service file and helper script Arnout Vandecappelle
2016-06-22 21:58 ` Arnout Vandecappelle
2016-06-23  3:40   ` Nathaniel Roach
2016-06-23 21:29     ` Arnout Vandecappelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466269320-23938-1-git-send-email-nroach44@gmail.com \
    --to=nroach44@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox