gluon-respondd: Use procd in initscript and to restart on network changes
This commit is contained in:
parent
cb86fce29f
commit
d8bb97831b
@ -1,16 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
. /lib/functions/service.sh
|
|
||||||
|
|
||||||
ifname_to_dev () {
|
|
||||||
ifstatus client "$1"|jsonfilter -e "@.device"
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$ACTION" in
|
|
||||||
ifup)
|
|
||||||
DEVICE="$(ifname_to_dev "$INTERFACE")"
|
|
||||||
|
|
||||||
[ "$DEVICE" != "$(cat /lib/gluon/respondd/client.dev 2>/dev/null)" ] ||
|
|
||||||
/etc/init.d/gluon-respondd restart_if_running &
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,48 +1,28 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
EXTRA_COMMANDS='restart_if_running'
|
USE_PROCD=1
|
||||||
|
|
||||||
START=50
|
START=50
|
||||||
|
|
||||||
SERVICE_WRITE_PID=1
|
|
||||||
SERVICE_DAEMONIZE=1
|
|
||||||
|
|
||||||
DAEMON=/usr/bin/respondd
|
DAEMON=/usr/bin/respondd
|
||||||
LOCK=/var/run/gluon-respondd.lock
|
|
||||||
|
|
||||||
|
start_service() {
|
||||||
do_start() {
|
|
||||||
DEVS=""
|
DEVS=""
|
||||||
for dev in $( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device") $(cat /lib/gluon/respondd/client.dev 2>/dev/null)
|
for dev in $( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device") $(cat /lib/gluon/respondd/client.dev 2>/dev/null)
|
||||||
do
|
do
|
||||||
DEVS="$DEVS -i $dev"
|
DEVS="$DEVS -i $dev"
|
||||||
done
|
done
|
||||||
service_start $DAEMON -g ff02::2:1001 -p 1001 -d /lib/gluon/respondd $DEVS
|
procd_open_instance
|
||||||
|
procd_set_param command $DAEMON -g ff02::2:1001 -p 1001 -d /lib/gluon/respondd $DEVS
|
||||||
|
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
do_stop() {
|
service_triggers() {
|
||||||
service_stop $DAEMON
|
local script=$(readlink "$initscript")
|
||||||
}
|
local name=$(basename ${script:-$initscript})
|
||||||
|
|
||||||
start() {
|
procd_open_trigger
|
||||||
lock $LOCK
|
procd_add_raw_trigger "interface.*" 0 "/etc/init.d/$name" reload
|
||||||
do_start
|
procd_close_trigger
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
/etc/init.d/gluon-respondd restart_if_running &
|
|
Loading…
Reference in New Issue
Block a user