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
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$ACTION" in
|
|
|
|
ifdown)
|
2016-02-02 05:38:03 +00:00
|
|
|
sed "/ $INTERFACE$/d" $DEVLIST > $DEVLIST.new
|
|
|
|
mv $DEVLIST.new $DEVLIST
|
2014-07-11 16:25:39 +00:00
|
|
|
;;
|
|
|
|
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
|
|
|
|
2016-02-02 05:38:03 +00:00
|
|
|
DEVS=$(cat $DEVLIST 2>/dev/null; echo $DEVICE $INTERFACE)
|
2014-07-11 16:25:39 +00:00
|
|
|
|
2016-02-02 05:38:03 +00:00
|
|
|
echo "$DEVS" | sort -u > $DEVLIST.new
|
|
|
|
mv $DEVLIST.new $DEVLIST
|
2014-07-11 16:25:39 +00:00
|
|
|
|
2016-02-02 05:38:03 +00:00
|
|
|
/etc/init.d/gluon-respondd restart_if_running &
|
2014-07-11 16:25:39 +00:00
|
|
|
|
|
|
|
;;
|
|
|
|
esac
|