Skip to content

Commit

Permalink
miniupnpd: avoid unnecessary restarts, add SPDX tag
Browse files Browse the repository at this point in the history
  • Loading branch information
sbyx committed Oct 15, 2014
1 parent 93f7d5c commit 8bc38fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion miniupnpd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=miniupnpd
PKG_VERSION:=1.8.20140906
PKG_RELEASE:=1
PKG_RELEASE:=2

PKG_SOURCE_URL:=http://miniupnp.free.fr/files
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_MD5SUM:=72a68c5757031d906a555f84e9a2a8f2

PKG_MAINTAINER:=Markus Stenberg <fingon@iki.fi>
PKG_LICENSE:=BSD-3-Clause

include $(INCLUDE_DIR)/package.mk

Expand Down
29 changes: 18 additions & 11 deletions miniupnpd/files/miniupnpd.hotplug
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,29 @@ fi

[ ! "$ACTION" = "ifup" ] && service_check /usr/sbin/miniupnpd && exit 0

# DEVICE is set only in ifup as of 20140625 netifd
[ -z "$DEVICE" ] && network_get_device DEVICE $INTERFACE

local iface
local ext_iface
local ext_iface6
local ifname
local tmpconf="/var/etc/miniupnpd.conf"
local extiface=$(uci get upnpd.config.external_iface)
local extzone=$(uci get upnpd.config.external_zone)

. /lib/functions/network.sh
network_find_wan ext_iface
network_find_wan6 ext_iface6

for iface in $ext_iface $ext_iface6 $(uci_get upnpd config internal_iface; uci_get upnpd config external_iface); do
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

for device in $(fw3 -q zone `uci_get upnpd config external_zone`); do
[ "$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

0 comments on commit 8bc38fc

Please sign in to comment.