gluon/package/gluon-respondd/files/etc/hotplug.d/iface/10-gluon-respondd
Matthias Schiffer b4aaf8a1f8 gluon-respondd: add init script
Instead of starting gluon-respondd from a hotplug handler, add a proper
init script. The new init script has a restart_if_running argument which
is now used by the hotplug handler.
2016-02-02 09:18:13 +01:00

35 lines
704 B
Bash

#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions/service.sh
DEVLIST=/var/run/gluon-respondd.devs
ifname_to_dev () {
json_load "$(ubus call network.interface.$1 status)"
json_get_var dev device
echo "$dev"
}
case "$ACTION" in
ifdown)
sed "/ $INTERFACE$/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
DEVS=$(cat $DEVLIST 2>/dev/null; echo $DEVICE $INTERFACE)
echo "$DEVS" | sort -u > $DEVLIST.new
mv $DEVLIST.new $DEVLIST
/etc/init.d/gluon-respondd restart_if_running &
;;
esac