2014-07-11 16:25:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
. /usr/share/libubox/jshn.sh
|
|
|
|
. /lib/functions/service.sh
|
|
|
|
|
2016-02-02 05:38:03 +00:00
|
|
|
DEVLIST=/var/run/gluon-respondd.devs
|
2015-04-23 16:18:13 +00:00
|
|
|
DAEMON=/usr/bin/respondd
|
2014-07-11 16:25:39 +00:00
|
|
|
|
|
|
|
ifname_to_dev () {
|
|
|
|
json_load "$(ubus call network.interface.$1 status)"
|
|
|
|
json_get_var dev device
|
|
|
|
|
|
|
|
echo "$dev"
|
|
|
|
}
|
|
|
|
|
2016-02-02 05:38:03 +00:00
|
|
|
restart_respondd () {
|
2014-07-11 16:25:39 +00:00
|
|
|
SERVICE_USE_PID=1
|
|
|
|
SERVICE_WRITE_PID=1
|
|
|
|
SERVICE_DAEMONIZE=1
|
|
|
|
|
2015-04-23 16:18:13 +00:00
|
|
|
DEVS=$(cat $DEVLIST | while read dev iface; do echo -n " -i $dev"; done)
|
2014-07-11 16:25:39 +00:00
|
|
|
|
|
|
|
service_stop $DAEMON
|
2016-02-02 05:38:03 +00:00
|
|
|
service_start $DAEMON -g ff02::2:1001 -p 1001 -d /lib/gluon/respondd $DEVS
|
2014-07-11 16:25:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$ACTION" in
|
|
|
|
ifdown)
|
|
|
|
sed -i "/$INTERFACE/d" $DEVLIST
|
|
|
|
;;
|
|
|
|
ifup)
|
2015-04-23 16:18:13 +00:00
|
|
|
DEVICE="$(ifname_to_dev "$INTERFACE")"
|
|
|
|
MESH="$(cat "/sys/class/net/$DEVICE/batman_adv/mesh_iface" 2>/dev/null)"
|
2014-07-11 16:25:39 +00:00
|
|
|
|
2015-04-23 16:18:13 +00:00
|
|
|
[ "$MESH" = "bat0" -o "$INTERFACE" = "client" ] || exit 0
|
2014-07-11 16:25:39 +00:00
|
|
|
|
2015-04-23 16:18:13 +00:00
|
|
|
DEVS=$(cat $DEVLIST; echo $DEVICE $INTERFACE)
|
2014-07-11 16:25:39 +00:00
|
|
|
|
2015-04-23 16:18:13 +00:00
|
|
|
echo "$DEVS" | sort -u > $DEVLIST
|
2014-07-11 16:25:39 +00:00
|
|
|
|
2016-02-02 05:38:03 +00:00
|
|
|
restart_respondd
|
2014-07-11 16:25:39 +00:00
|
|
|
|
|
|
|
;;
|
|
|
|
esac
|