miniupnpd: implement an 'enabled' flag
[feed/routing.git] / miniupnpd / files / miniupnpd.init
index caa69ad8ef638c6657d4aaa7948b0c3bec2a74c2..c934a283732b60e357bb75bb13934ae0123a2f6e 100644 (file)
@@ -1,7 +1,8 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2006-2011 OpenWrt.org
+# Copyright (C) 2006-2014 OpenWrt.org
 
-START=95
+START=94
+STOP=15
 
 SERVICE_USE_PID=1
 
@@ -67,9 +68,14 @@ start() {
        local extip port usesysuptime conffile serial_number model_number
        local uuid notify_interval presentation_url enable_upnp
        local upnp_lease_file clean_ruleset_threshold clean_ruleset_interval
-        local ipv6_listening_ip
+        local ipv6_listening_ip enabled
+
+       config_get_bool enabled config enabled 1
+
+       [ "$enabled" -gt 0 ] || return 1
 
        config_get extiface config external_iface
+       config_get extzone config external_zone
        config_get intiface config internal_iface
        config_get extip config external_ip
        config_get port config port 5000
@@ -93,9 +99,18 @@ start() {
 
        local ifname
 
-        [ -n "$extiface" ] || network_find_wan extiface
-
-       network_get_device ifname ${extiface}
+        # manual external interface overrides everything
+        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}
 
        if [ -n "$conffile" ]; then
                args="-f $conffile"