package/smcroute: add sysv init script
authorJoachim Wiberg <troglobit@gmail.com>
Mon, 30 Aug 2021 15:30:55 +0000 (17:30 +0200)
committerArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Sat, 11 Sep 2021 14:27:19 +0000 (16:27 +0200)
Same start order as mrouted, start after networking is up.

Custom command line options, like startup delay, or disable multicast
routing by default, can be added to the optional /etc/default/smcroute
env. file.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
package/smcroute/S41smcroute [new file with mode: 0755]
package/smcroute/smcroute.mk

diff --git a/package/smcroute/S41smcroute b/package/smcroute/S41smcroute
new file mode 100755 (executable)
index 0000000..bdc0f87
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+NAME="smcroute"
+DAEMON="smcrouted"
+PIDFILE="/var/run/$NAME.pid"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$NAME" ] && . "/etc/default/$NAME"
+
+cmd()
+{
+    start-stop-daemon -q -p "$PIDFILE" "$@"
+    status=$?
+    if [ $status -eq 0 ]; then
+       echo "OK"
+    else
+       echo "FAIL"
+    fi
+    return $status
+}
+
+case "$1" in
+    start)
+       printf 'Starting %s: ' "$DAEMON"
+       # shellcheck disable=SC2086 # we need the word splitting
+       cmd -S -x "/usr/sbin/$DAEMON" -- $SMCROUTED_ARGS
+       ;;
+
+    stop)
+       printf 'Stopping %s: ' "$DAEMON"
+       cmd -K
+       ;;
+
+    restart)
+       $0 stop
+       sleep 1
+       $0 start
+       ;;
+
+    reload)
+       printf 'Reloading %s: ' "$DAEMON"
+       cmd -K -s HUP
+       ;;
+
+    *)
+       echo "Usage: $0 {start|stop|restart|reload}"
+       exit 1
+esac
index e4ee81db6f8c137b9685e7578604c450cb4fcae8..9cce0acbbccaa0e97fad120c79ee46956b992193 100644 (file)
@@ -19,4 +19,9 @@ else
 SMCROUTE_CONF_OPTS += --without-libcap
 endif
 
+define SMCROUTE_INSTALL_INIT_SYSV
+       $(INSTALL) -m 755 -D package/smcroute/S41smcroute \
+               $(TARGET_DIR)/etc/init.d/S41smcroute
+endef
+
 $(eval $(autotools-package))