gluon/package/gluon-respondd/files/etc/hotplug.d/iface/10-gluon-respondd
Jan-Philipp Litza 545930b0bb gluon-respondd: Adapt to new respondd version
The new version supports loading the list of multicast interfaces from a
file and brings its own initscript and UCI configuration.
2016-09-28 18:00:08 +02:00

37 lines
724 B
Bash

#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions/service.sh
DEVLIST="$(uci_get "respondd.@respondd[0].iface_list_file")"
ifname_to_dev () {
json_load "$(ubus call network.interface.$1 status)"
json_get_var dev device
echo "$dev"
}
case "$ACTION" in
ifdown)
DEVICE="$(ifname_to_dev "$INTERFACE")"
sed "/^$DEVICE$/d" $DEVLIST > $DEVLIST.new
mv $DEVLIST.new $DEVLIST
;;
ifup)
DEVICE="$(ifname_to_dev "$INTERFACE")"
MESH="$(cat "/sys/class/net/$DEVICE/batman_adv/mesh_iface" 2>/dev/null)"
[ "$MESH" = "bat0" -o "$INTERFACE" = "client" ] || exit 0
{
cat $DEVLIST 2>/dev/null
echo $DEVICE
} | sort -u > $DEVLIST.new
mv $DEVLIST.new $DEVLIST
/etc/init.d/respondd reload &
;;
esac