routing/miniupnpd/files/miniupnpd.hotplug
Hannu Nyman 3db27f27b2 miniupnpd: fix local variables in hotplug, change startup priority
* Remove 'local' variable definitions from hotplug script.
  Busybox 1.25.0 does not allow local variables defined outside functions.
  This fixes #231

* Change startup priority from 95 to 94, so that miniupnpd starts
  before S95done (which is intended to be run last).

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2016-09-30 10:06:12 +03:00

39 lines
1.1 KiB
Bash

#!/bin/sh
/etc/init.d/miniupnpd enabled || exit 0
. /lib/functions/service.sh
# 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_check /usr/sbin/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
for iface in $(uci get upnpd.config.internal_iface); do
network_get_device device $iface
[ "$DEVICE" = "$device" ] && /etc/init.d/miniupnpd restart && exit 0
done
if [ -z "$extiface" ] ; then
# manual external zone (if dynamically find interfaces
# belonging to it) overrides network_find_wan*
if [ -n "$extzone" ] ; then
ifname=$(fw3 -q zone $extzone | head -1)
fi
[ -n "$extiface" ] || network_find_wan extiface
[ -n "$extiface" ] || network_find_wan6 extiface
fi
[ -n "$ifname" ] || network_get_device ifname ${extiface}
grep -q "ext_ifname=$ifname" $tmpconf || /etc/init.d/miniupnpd restart