1 /etc/init.d/miniupnpd enabled || exit 0
3 # If miniupnpd is not running:
4 # - check on _any_ event (event 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)
10 . /lib/functions/procd.sh
12 [ "$ACTION" != "ifup" ] && procd_running "miniupnpd" "*" && exit 0
14 tmpconf="/var/etc/miniupnpd.conf"
15 external_iface=$(uci -q get upnpd.config.external_iface)
16 external_iface6=$(uci -q get upnpd.config.external_iface6)
17 external_zone=$(uci -q get upnpd.config.external_zone)
19 . /lib/functions/network.sh
21 if [ -n "$external_iface" ] ; then
22 network_get_device ifname "$external_iface"
24 if [ -n "$external_zone" ] ; then
25 ifname=$(fw3 -q zone "$external_zone" 2>/dev/null | head -1)
27 network_find_wan external_iface && \
28 network_get_device ifname "$external_iface"
31 if [ -n "$external_iface6" ] ; then
32 network_get_device ifname6 "$external_iface6"
34 if [ -n "$external_zone" ] ; then
35 ifname6=$(fw3 -q zone "$external_zone" 2>/dev/null | head -1)
37 network_find_wan6 external_iface6 && \
38 network_get_device ifname6 "$external_iface6"
42 [ "$DEVICE" != "$ifname" ] && [ "$DEVICE" != "$ifname6" ] && exit 0
44 grep -qs "^ext_ifname=$ifname" "$tmpconf" && grep -qs "^ext_ifname6=$ifname6" "$tmpconf" && exit 0
46 /etc/init.d/miniupnpd restart