hotplug scripts are sourced not exec'd so #!/bin/sh /etc/rc.common doesn't pull in the functions defined in /etc/rc.common thus since 'enabled' isn't defined the following sequence always fails: enabled miniupnpd || exit 0 Unfortunately sourcing /etc/rc.common doesn't appear to work so come up with some alternatives. Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
29 lines
955 B
Text
29 lines
955 B
Text
/etc/init.d/miniupnpd enabled || exit 0
|
|
|
|
# If miniupnpd is not running:
|
|
# - check on _any_ event (event updates may contribute to network_find_wan*)
|
|
|
|
# If miniupnpd _is_ running:
|
|
# - check only on ifup (otherwise lease updates etc would cause
|
|
# miniupnpd state loss)
|
|
|
|
. /lib/functions/procd.sh
|
|
|
|
[ "$ACTION" != "ifup" ] && procd_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
|