minimalist-pcproxy/miniupnpd: added+using upnp.config.external_zone.
[lede-routing/.git] / miniupnpd / files / miniupnpd.hotplug
1 #!/bin/sh
2
3 if [ ! /etc/init.d/miniupnpd enabled ]
4 then
5     exit 0
6 fi
7
8 . /lib/functions/service.sh
9
10 # If miniupnpd is not running:
11 # - check on _any_ event (even updates may contribute to network_find_wan*)
12
13 # If miniupnpd _is_ running:
14 # - check only on ifup (otherwise lease updates etc would cause
15 #   miniupnpd state loss)
16
17 [ ! "$ACTION" = "ifup" ] && service_check /usr/sbin/miniupnpd && exit 0
18
19 # DEVICE is set only in ifup as of 20140625 netifd
20 [ -z "$DEVICE" ] && network_get_device DEVICE $INTERFACE
21
22 local iface
23 local ext_iface
24 local ext_iface6
25
26 . /lib/functions/network.sh
27 network_find_wan ext_iface
28 network_find_wan6 ext_iface6
29
30 for iface in $ext_iface $ext_iface6 $(uci_get upnpd config internal_iface; uci_get upnpd config external_iface); do
31     network_get_device device $iface
32     [ "$DEVICE" = "$device" ] && /etc/init.d/miniupnpd restart && exit 0
33 done
34
35 for device in $(fw3 -q zone `uci_get upnpd config external_zone`); do
36     [ "$DEVICE" = "$device" ] && /etc/init.d/miniupnpd restart && exit 0
37 done