packages/net/miniupnpd/files/miniupnpd.hotplug
Rosen Penev 1fe1c80d66
miniupnpd: convert to procd
Massive cleanup of the shell script. Many issues were fixed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
(cherry picked from commit c61614a849)
2020-04-17 15:21:35 -07:00

29 lines
936 B
Bash

#!/bin/sh /etc/rc.common
enabled miniupnpd || exit 0
# If miniupnpd is not running:
# - check on _any_ event (even updates may contribute to network_find_wan*)
# If miniupnpd _is_ running:
# - check only on ifup (otherwise lease updates etc would cause
# miniupnpd state loss)
[ "$ACTION" != "ifup" ] && service_running miniupnpd && exit 0
tmpconf="/var/etc/miniupnpd.conf"
extiface=$(uci get upnpd.config.external_iface)
extzone=$(uci get upnpd.config.external_zone)
. /lib/functions/network.sh
[ -z "$extiface" ] && {
# manual external zone (if dynamically find interfaces
# belonging to it) overrides network_find_wan*
[ -n "$extzone" ] && ifname=$(fw3 -q zone "$extzone" | head -1)
[ -z "$extiface" ] && network_find_wan extiface
[ -z "$extiface" ] && network_find_wan6 extiface
}
[ -z "$ifname" ] && network_get_device ifname "$extiface"
grep -q "ext_ifname=$ifname" "$tmpconf" || /etc/init.d/miniupnpd restart