You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
990 B

  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. if [ -z "$extiface" ] ; then
  15. # manual external zone (if dynamically find interfaces
  16. # belonging to it) overrides network_find_wan*
  17. if [ -n "$extzone" ] ; then
  18. ifname=$(fw3 -q zone $extzone | head -1)
  19. fi
  20. [ -n "$extiface" ] || network_find_wan extiface
  21. [ -n "$extiface" ] || network_find_wan6 extiface
  22. fi
  23. [ -n "$ifname" ] || network_get_device ifname "$extiface"
  24. grep -q "ext_ifname=$ifname" "$tmpconf" || /etc/init.d/miniupnpd restart