gluon/package/gluon-respondd/files/etc/hotplug.d/iface/10-gluon-respondd
Matthias Schiffer 9004028cb4 Convert gluon-announce Lua code to C modules, rename to gluon-respondd
gluon-announced and gluon-announce are merged to gluon-respondd.
2016-02-02 09:18:12 +01:00

45 lines
874 B
Bash

#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions/service.sh
DEVLIST=/var/run/gluon-respondd.devs
DAEMON=/usr/bin/respondd
ifname_to_dev () {
json_load "$(ubus call network.interface.$1 status)"
json_get_var dev device
echo "$dev"
}
restart_respondd () {
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
service_start $DAEMON -g ff02::2:1001 -p 1001 -d /lib/gluon/respondd $DEVS
}
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" 2>/dev/null)"
[ "$MESH" = "bat0" -o "$INTERFACE" = "client" ] || exit 0
DEVS=$(cat $DEVLIST; echo $DEVICE $INTERFACE)
echo "$DEVS" | sort -u > $DEVLIST
restart_respondd
;;
esac