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.

45 lines
1.4 KiB

  1. /etc/init.d/miniupnpd enabled || exit 0
  2. # If miniupnpd is not running:
  3. # - check on _any_ event (event updates may contribute to network_find_wan*)
  4. # If miniupnpd _is_ running:
  5. # - check only on ifup (otherwise lease updates etc would cause
  6. # miniupnpd state loss)
  7. [ "$ACTION" != "ifup" ] && /etc/init.d/miniupnpd running && exit 0
  8. tmpconf="/var/etc/miniupnpd.conf"
  9. external_iface=$(uci -q get upnpd.config.external_iface)
  10. external_iface6=$(uci -q get upnpd.config.external_iface6)
  11. external_zone=$(uci -q get upnpd.config.external_zone)
  12. [ -x "$(command -v nft)" ] && FW="fw4" || FW="fw3"
  13. . /lib/functions/network.sh
  14. if [ -n "$external_iface" ] ; then
  15. network_get_device ifname "$external_iface"
  16. else
  17. if [ -n "$external_zone" ] ; then
  18. ifname=$($FW -q zone "$external_zone" 2>/dev/null | head -1)
  19. else
  20. network_find_wan external_iface && \
  21. network_get_device ifname "$external_iface"
  22. fi
  23. fi
  24. if [ -n "$external_iface6" ] ; then
  25. network_get_device ifname6 "$external_iface6"
  26. else
  27. if [ -n "$external_zone" ] ; then
  28. ifname6=$($FW -q zone "$external_zone" 2>/dev/null | head -1)
  29. else
  30. network_find_wan6 external_iface6 && \
  31. network_get_device ifname6 "$external_iface6"
  32. fi
  33. fi
  34. [ "$DEVICE" != "$ifname" ] && [ "$DEVICE" != "$ifname6" ] && exit 0
  35. grep -qs "^ext_ifname=$ifname" "$tmpconf" && grep -qs "^ext_ifname6=$ifname6" "$tmpconf" && exit 0
  36. /etc/init.d/miniupnpd restart