miniupnpd.hotplug 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. /etc/init.d/miniupnpd enabled || exit 0
  3. . /lib/functions/service.sh
  4. # If miniupnpd is not running:
  5. # - check on _any_ event (even updates may contribute to network_find_wan*)
  6. # If miniupnpd _is_ running:
  7. # - check only on ifup (otherwise lease updates etc would cause
  8. # miniupnpd state loss)
  9. [ ! "$ACTION" = "ifup" ] && service_check /usr/sbin/miniupnpd && exit 0
  10. tmpconf="/var/etc/miniupnpd.conf"
  11. extiface=$(uci get upnpd.config.external_iface)
  12. extzone=$(uci get upnpd.config.external_zone)
  13. . /lib/functions/network.sh
  14. for iface in $(uci get upnpd.config.internal_iface); do
  15. network_get_device device $iface
  16. [ "$DEVICE" = "$device" ] && /etc/init.d/miniupnpd restart && exit 0
  17. done
  18. if [ -z "$extiface" ] ; then
  19. # manual external zone (if dynamically find interfaces
  20. # belonging to it) overrides network_find_wan*
  21. if [ -n "$extzone" ] ; then
  22. ifname=$(fw3 -q zone $extzone | head -1)
  23. fi
  24. [ -n "$extiface" ] || network_find_wan extiface
  25. [ -n "$extiface" ] || network_find_wan6 extiface
  26. fi
  27. [ -n "$ifname" ] || network_get_device ifname ${extiface}
  28. grep -q "ext_ifname=$ifname" $tmpconf || /etc/init.d/miniupnpd restart