Merge pull request #12342 from PolynomialDivision/feature/add_dawn_node_exporter
[feed/packages.git] / net / miniupnpd / files / miniupnpd.hotplug
1 /etc/init.d/miniupnpd enabled || exit 0
2
3 # If miniupnpd is not running:
4 # - check on _any_ event (event updates may contribute to network_find_wan*)
5
6 # If miniupnpd _is_ running:
7 # - check only on ifup (otherwise lease updates etc would cause
8 # miniupnpd state loss)
9
10 . /lib/functions/procd.sh
11
12 [ "$ACTION" != "ifup" ] && procd_running "miniupnpd" "*" && exit 0
13
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)
18
19 . /lib/functions/network.sh
20
21 if [ -n "$external_iface" ] ; then
22 network_get_device ifname "$external_iface"
23 else
24 if [ -n "$external_zone" ] ; then
25 ifname=$(fw3 -q zone "$external_zone" 2>/dev/null | head -1)
26 else
27 network_find_wan external_iface && \
28 network_get_device ifname "$external_iface"
29 fi
30 fi
31 if [ -n "$external_iface6" ] ; then
32 network_get_device ifname6 "$external_iface6"
33 else
34 if [ -n "$external_zone" ] ; then
35 ifname6=$(fw3 -q zone "$external_zone" 2>/dev/null | head -1)
36 else
37 network_find_wan6 external_iface6 && \
38 network_get_device ifname6 "$external_iface6"
39 fi
40 fi
41
42 [ "$DEVICE" != "$ifname" ] && [ "$DEVICE" != "$ifname6" ] && exit 0
43
44 grep -qs "^ext_ifname=$ifname" "$tmpconf" && grep -qs "^ext_ifname6=$ifname6" "$tmpconf" && exit 0
45
46 /etc/init.d/miniupnpd restart