10-gluon-respondd 704 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. . /usr/share/libubox/jshn.sh
  3. . /lib/functions/service.sh
  4. DEVLIST=/var/run/gluon-respondd.devs
  5. ifname_to_dev () {
  6. json_load "$(ubus call network.interface.$1 status)"
  7. json_get_var dev device
  8. echo "$dev"
  9. }
  10. case "$ACTION" in
  11. ifdown)
  12. sed "/ $INTERFACE$/d" $DEVLIST > $DEVLIST.new
  13. mv $DEVLIST.new $DEVLIST
  14. ;;
  15. ifup)
  16. DEVICE="$(ifname_to_dev "$INTERFACE")"
  17. MESH="$(cat "/sys/class/net/$DEVICE/batman_adv/mesh_iface" 2>/dev/null)"
  18. [ "$MESH" = "bat0" -o "$INTERFACE" = "client" ] || exit 0
  19. DEVS=$(cat $DEVLIST 2>/dev/null; echo $DEVICE $INTERFACE)
  20. echo "$DEVS" | sort -u > $DEVLIST.new
  21. mv $DEVLIST.new $DEVLIST
  22. /etc/init.d/gluon-respondd restart_if_running &
  23. ;;
  24. esac