merge 13082/3 to 8.09
[openwrt/svn-archive/archive.git] / package / base-files / files / sbin / ifdown
index 5a98003b1de0dbf3d13094b19e21e0e08fd9d86c..883f8ec42893bc8c3fb70286a6674f1430deeeac 100755 (executable)
@@ -4,12 +4,14 @@
 . /etc/functions.sh
 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
 [ "x$1" = "x-a" ] && {
+       [ -e "/tmp/resolv.conf.auto" ] && rm /tmp/resolv.conf.auto
        config_cb() {
                [ interface != "$1" -o -z "$2" ] || eval "$0 $2"
        }
        config_load network
        exit
 }
+
 include /lib/network
 scan_interfaces
 
@@ -20,7 +22,7 @@ config_get proto "$cfg" proto
 [ -z "$proto" ] && { echo "interface not found."; exit; }
 
 config_get iface "$cfg" device
-[ "$proto" = "static" ] && {
+[ "static" = "$proto" ] && {
        env -i ACTION="ifdown" INTERFACE="$cfg" DEVICE="$iface" PROTO=static /sbin/hotplug-call "iface" &
 }
 
@@ -58,5 +60,13 @@ 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
+
+# remove the interface's network state
+uci_revert_state network "$1"
 
+# revert aliases state as well
+config_get aliases "$1" aliases
+for config in $aliases; do
+       uci_revert_state network "$config"
+done