gluon-respondd: add init script
Instead of starting gluon-respondd from a hotplug handler, add a proper init script. The new init script has a restart_if_running argument which is now used by the hotplug handler.
This commit is contained in:
parent
9004028cb4
commit
b4aaf8a1f8
@ -4,7 +4,6 @@
|
||||
. /lib/functions/service.sh
|
||||
|
||||
DEVLIST=/var/run/gluon-respondd.devs
|
||||
DAEMON=/usr/bin/respondd
|
||||
|
||||
ifname_to_dev () {
|
||||
json_load "$(ubus call network.interface.$1 status)"
|
||||
@ -13,20 +12,10 @@ ifname_to_dev () {
|
||||
echo "$dev"
|
||||
}
|
||||
|
||||
restart_respondd () {
|
||||
SERVICE_USE_PID=1
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
|
||||
DEVS=$(cat $DEVLIST | while read dev iface; do echo -n " -i $dev"; done)
|
||||
|
||||
service_stop $DAEMON
|
||||
service_start $DAEMON -g ff02::2:1001 -p 1001 -d /lib/gluon/respondd $DEVS
|
||||
}
|
||||
|
||||
case "$ACTION" in
|
||||
ifdown)
|
||||
sed -i "/$INTERFACE/d" $DEVLIST
|
||||
sed "/ $INTERFACE$/d" $DEVLIST > $DEVLIST.new
|
||||
mv $DEVLIST.new $DEVLIST
|
||||
;;
|
||||
ifup)
|
||||
DEVICE="$(ifname_to_dev "$INTERFACE")"
|
||||
@ -34,11 +23,12 @@ case "$ACTION" in
|
||||
|
||||
[ "$MESH" = "bat0" -o "$INTERFACE" = "client" ] || exit 0
|
||||
|
||||
DEVS=$(cat $DEVLIST; echo $DEVICE $INTERFACE)
|
||||
DEVS=$(cat $DEVLIST 2>/dev/null; echo $DEVICE $INTERFACE)
|
||||
|
||||
echo "$DEVS" | sort -u > $DEVLIST
|
||||
echo "$DEVS" | sort -u > $DEVLIST.new
|
||||
mv $DEVLIST.new $DEVLIST
|
||||
|
||||
restart_respondd
|
||||
/etc/init.d/gluon-respondd restart_if_running &
|
||||
|
||||
;;
|
||||
esac
|
||||
|
45
package/gluon-respondd/files/etc/init.d/gluon-respondd
Executable file
45
package/gluon-respondd/files/etc/init.d/gluon-respondd
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
EXTRA_COMMANDS='restart_if_running'
|
||||
|
||||
START=50
|
||||
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
|
||||
DEVLIST=/var/run/gluon-respondd.devs
|
||||
DAEMON=/usr/bin/respondd
|
||||
LOCK=/var/run/gluon-respondd.lock
|
||||
|
||||
|
||||
do_start() {
|
||||
DEVS=$(cat $DEVLIST 2>/dev/null | while read dev iface; do echo -n " -i $dev"; done)
|
||||
service_start $DAEMON -g ff02::2:1001 -p 1001 -d /lib/gluon/respondd $DEVS
|
||||
}
|
||||
|
||||
do_stop() {
|
||||
service_stop $DAEMON
|
||||
}
|
||||
|
||||
start() {
|
||||
lock $LOCK
|
||||
do_start
|
||||
lock -u $LOCK
|
||||
}
|
||||
|
||||
stop() {
|
||||
lock $LOCK
|
||||
do_stop
|
||||
lock -u $LOCK
|
||||
}
|
||||
|
||||
restart_if_running() {
|
||||
lock $LOCK
|
||||
|
||||
if service_check $DAEMON; then
|
||||
do_stop
|
||||
do_start
|
||||
fi
|
||||
|
||||
lock -u $LOCK
|
||||
}
|
Loading…
Reference in New Issue
Block a user