miniupnpd: Fixes #39. Based on discussion with jow, use external interface if specifi...
[feed/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
18 [ ! "$ACTION" = "ifup" ] && service_check /usr/sbin/miniupnpd && exit 0
19
20 local iface
21 local ext_iface
22 local ext_iface6
23
24 . /lib/functions/network.sh
25 network_find_wan ext_iface
26 network_find_wan6 ext_iface6
27
28 for iface in $ext_iface $ext_iface6 $(uci_get upnpd config internal_iface; uci_get upnpd config external_iface); do
29 network_get_device device $iface
30 [ "$DEVICE" = "$device" ] && /etc/init.d/miniupnpd restart && exit 0
31 done