2 # Copyright (C) 2006 OpenWrt.org
5 [ $# = 0 ] && { echo " $0 <group>"; exit; }
8 [ interface != "$1" -o -z "$2" ] || eval "$0 $2"
14 # remove the interface's network state
15 uci_revert_state network "$1"
21 debug "### ifdown $cfg ###"
23 config_get proto "$cfg" proto
24 [ -z "$proto" ] && { echo "interface not found."; exit; }
26 config_get iface "$cfg" device
27 [ "static" = "$proto" ] && {
28 env -i ACTION="ifdown" INTERFACE="$cfg" DEVICE="$iface" PROTO=static /sbin/hotplug-call "iface" &
31 # call interface stop handler
32 ( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
34 # make sure all locks are removed
35 for lock in "/var/lock/dhcp-$iface" "/var/lock/ppp-$iface"; do
42 # kill active ppp daemon and other processes
43 config_get ifname "$cfg" ifname
44 pids="$(head -n1 -q /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid 2>/dev/null)"
46 [ -d "/proc/$pid" ] && {
48 [ -d "/proc/$pid" ] && {
50 kill -9 $pid 2>/dev/null >/dev/null
54 rm -f /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid
56 config_get ifname "$cfg" ifname
57 config_get device "$cfg" device
59 [ ."$device" != ."$ifname" ] || device=
60 for dev in $ifname $device; do
61 ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
64 config_get iftype "$cfg" type
65 [ "bridge" = "$iftype" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null