2 # Copyright (C) 2006 OpenWrt.org
5 [ $# = 0 ] && { echo " $0 <group>"; exit; }
8 [ interface != "$1" -o -z "$2" ] || eval "$0 $2"
14 config_load /var/state/network
16 # remove the interface's network state
17 FILE=/var/state/network.$$
18 grep -v "^config_set '$1' " /var/state/network > "$FILE"
19 mv "$FILE" /var/state/network
25 debug "### ifdown $cfg ###"
27 config_get proto "$cfg" proto
28 [ -z "$proto" ] && { echo "interface not found."; exit; }
30 config_get iface "$cfg" device
31 [ "static" = "$proto" ] && {
32 env -i ACTION="ifdown" INTERFACE="$cfg" DEVICE="$iface" PROTO=static /sbin/hotplug-call "iface" &
35 # call interface stop handler
36 ( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
38 # make sure all locks are removed
39 for lock in "/var/lock/dhcp-$iface" "/var/lock/ppp-$iface"; do
46 # kill active ppp daemon and other processes
47 config_get ifname "$cfg" ifname
48 pids="$(head -n1 -q /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid 2>/dev/null)"
50 [ -d "/proc/$pid" ] && {
52 [ -d "/proc/$pid" ] && {
54 kill -9 $pid 2>/dev/null >/dev/null
58 rm -f /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid
60 config_get ifname "$cfg" ifname
61 config_get device "$cfg" device
63 [ ."$device" != ."$ifname" ] || device=
64 for dev in $ifname $device; do
65 ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
68 config_get iftype "$cfg" type
69 [ "bridge" = "$iftype" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null