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