1
0
mirror of https://github.com/freifunk-gluon/packages.git synced 2024-06-15 11:43:55 +02:00
gluon-packages/gluon/gluon-announced/files/etc/hotplug.d/iface/10-gluon-announced
Nils Schneider 59a9663cd1 gluon-announced: send nodeinformation on request
This is a simple daemon that will respond to multicast UDP packets
containing the keyword "nodeinfo" with all the information we
currently distribute using alfred.

The daemon will listen on all mesh interface, that is the hard
interfaces batman-adv uses.
2014-07-14 16:50:26 +02:00

46 lines
861 B
Bash

#!/bin/sh
. /usr/share/libubox/jshn.sh
. /lib/functions/service.sh
DEVLIST=/var/run/gluon-announce.devs
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
service_start $DAEMON -g ff02:0:0:0:0:0:2:1001 -p 1001 -s /lib/gluon/announce/announce.lua $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)
[ $MESH = "bat0" ] || exit 0
DEVS="$(cat $DEVLIST; echo $DEVICE $INTERFACE)"
echo "$DEVS" | sort | uniq > $DEVLIST
restart_announced
;;
esac