Message ID | 20210830153056.3176678-3-troglobit@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | bump smcroute and add start script | expand |
On 30/08/2021 17:30, Joachim Wiberg wrote: > 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> > --- > package/smcroute/S41smcroute | 48 ++++++++++++++++++++++++++++++++++++ > package/smcroute/smcroute.mk | 5 ++++ > 2 files changed, 53 insertions(+) > create mode 100755 package/smcroute/S41smcroute > > diff --git a/package/smcroute/S41smcroute b/package/smcroute/S41smcroute > new file mode 100755 > index 0000000000..bdc0f87645 > --- /dev/null > +++ b/package/smcroute/S41smcroute > @@ -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() This is not how we usually write our start scripts, but I like it! > +{ > + start-stop-daemon -q -p "$PIDFILE" "$@" Can't you pass the -x here as well (which makes sure that you actually kill the intended daemon in stop() and not some other random process that happens to have the same PID)? Anyway, I applied as is. Regards, Arnout > + 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 > diff --git a/package/smcroute/smcroute.mk b/package/smcroute/smcroute.mk > index e4ee81db6f..9cce0acbbc 100644 > --- a/package/smcroute/smcroute.mk > +++ b/package/smcroute/smcroute.mk > @@ -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)) >
On Sat, Sep 11, 2021 at 16:33, Arnout Vandecappelle <arnout@mind.be> wrote: > On 30/08/2021 17:30, Joachim Wiberg wrote: > This is not how we usually write our start scripts, but I like it! Thank you, I wasn't sure it would pass inspection :) >> +{ >> + start-stop-daemon -q -p "$PIDFILE" "$@" > Can't you pass the -x here as well (which makes sure that you actually kill the > intended daemon in stop() and not some other random process that happens to have > the same PID)? Huh, from the usage text of start-stop-daemon it wasn't clear to me if -x was reserved only for starting. Thanks for alerting me to this! > Anyway, I applied as is. Thanks, I'll push another bump later today, for the v2.5.3 release, which will include a fix for -x as well. Cheers /Joachim
diff --git a/package/smcroute/S41smcroute b/package/smcroute/S41smcroute new file mode 100755 index 0000000000..bdc0f87645 --- /dev/null +++ b/package/smcroute/S41smcroute @@ -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 diff --git a/package/smcroute/smcroute.mk b/package/smcroute/smcroute.mk index e4ee81db6f..9cce0acbbc 100644 --- a/package/smcroute/smcroute.mk +++ b/package/smcroute/smcroute.mk @@ -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))
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> --- package/smcroute/S41smcroute | 48 ++++++++++++++++++++++++++++++++++++ package/smcroute/smcroute.mk | 5 ++++ 2 files changed, 53 insertions(+) create mode 100755 package/smcroute/S41smcroute