2014-07-11 16:25:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
. /usr/share/libubox/jshn.sh
|
|
|
|
. /lib/functions/service.sh
|
|
|
|
|
2015-01-14 05:49:25 +00:00
|
|
|
DEVLIST=/var/run/gluon-announced.devs
|
2014-07-11 16:25:39 +00:00
|
|
|
DAEMON=/usr/bin/gluon-announced
|
|
|
|
|
|
|
|
ifname_to_dev () {
|
|
|
|
json_load "$(ubus call network.interface.$1 status)"
|
|
|
|
json_get_var dev device
|
|
|
|
|
|
|
|
echo "$dev"
|
|
|
|
}
|
|
|
|
|
|
|
|
restart_announced () {
|
|
|
|
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
|
2015-01-14 09:35:56 +00:00
|
|
|
service_start $DAEMON -g ff02:0:0:0:0:0:2:1001 -p 1001 -s '/lib/gluon/announce/collect.lua nodeinfo' $DEVS
|
2014-07-11 16:25:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$ACTION" in
|
|
|
|
ifdown)
|
|
|
|
sed -i "/$INTERFACE/d" $DEVLIST
|
|
|
|
;;
|
|
|
|
ifup)
|
|
|
|
DEVICE=$(ifname_to_dev $INTERFACE)
|
|
|
|
MESH=$(cat /sys/class/net/$DEVICE/batman_adv/mesh_iface)
|
|
|
|
|
|
|
|
[ $MESH = "bat0" ] || exit 0
|
|
|
|
|
|
|
|
DEVS="$(cat $DEVLIST; echo $DEVICE $INTERFACE)"
|
|
|
|
|
|
|
|
echo "$DEVS" | sort | uniq > $DEVLIST
|
|
|
|
|
|
|
|
restart_announced
|
|
|
|
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|