fix a few issues with dynamically assigned interfaces
[openwrt/openwrt.git] / package / base-files / files / sbin / ifdown
index 8c36a25b48d2bfc4ec8c494bf39f1d7fea820a94..08433c75c6e392f6ab537fdd4513610e871d5b84 100755 (executable)
        config_load network
        exit
 }
+
+config_load /var/state/network
+
+# remove the interface's network state
+FILE=/var/state/network.$$
+grep -v "^config_set '$1' " /var/state/network > "$FILE"
+mv "$FILE" /var/state/network
+
 include /lib/network
 scan_interfaces
 
@@ -20,8 +28,8 @@ config_get proto "$cfg" proto
 [ -z "$proto" ] && { echo "interface not found."; exit; }
 
 config_get iface "$cfg" device
-[ "$proto" = "static" ] && {
-       env -i ACTION="ifdown" INTERFACE="$config" DEVICE="$iface" PROTO=static /sbin/hotplug-call "iface" &
+[ "static" = "$proto" ] && {
+       env -i ACTION="ifdown" INTERFACE="$cfg" DEVICE="$iface" PROTO=static /sbin/hotplug-call "iface" &
 }
 
 # call interface stop handler
@@ -58,5 +66,5 @@ for dev in $ifname $device; do
 done
 
 config_get iftype "$cfg" type
-[ "$iftype" = "bridge" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null
+[ "bridge" = "$iftype" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null