2005-11-07 09:12:51 +08:00
|
|
|
#!/bin/sh
|
2006-06-27 08:36:13 +08:00
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
|
2005-02-06 08:58:10 +08:00
|
|
|
. /etc/functions.sh
|
2007-03-02 21:21:33 +08:00
|
|
|
[ $# = 0 ] && { echo " $0 <group>"; exit; }
|
|
|
|
[ "x$1" = "x-a" ] && {
|
2008-10-30 04:31:14 +08:00
|
|
|
[ -e "/tmp/resolv.conf.auto" ] && rm /tmp/resolv.conf.auto
|
2007-03-02 21:21:33 +08:00
|
|
|
config_cb() {
|
2007-04-15 15:22:11 +08:00
|
|
|
[ interface != "$1" -o -z "$2" ] || eval "$0 $2"
|
2007-03-02 21:21:33 +08:00
|
|
|
}
|
|
|
|
config_load network
|
|
|
|
exit
|
|
|
|
}
|
2007-06-16 08:01:33 +08:00
|
|
|
|
2006-09-24 21:32:18 +08:00
|
|
|
include /lib/network
|
2006-07-30 11:09:09 +08:00
|
|
|
scan_interfaces
|
2005-11-07 09:12:51 +08:00
|
|
|
|
2006-07-30 21:21:18 +08:00
|
|
|
cfg=$1
|
|
|
|
debug "### ifdown $cfg ###"
|
2005-11-07 09:12:51 +08:00
|
|
|
|
2006-07-30 21:21:18 +08:00
|
|
|
config_get proto "$cfg" proto
|
2006-07-30 11:09:09 +08:00
|
|
|
[ -z "$proto" ] && { echo "interface not found."; exit; }
|
2005-11-19 11:17:20 +08:00
|
|
|
|
2006-11-10 06:22:45 +08:00
|
|
|
config_get iface "$cfg" device
|
2009-09-15 00:14:27 +08:00
|
|
|
[ "static" = "$proto" -o "none" = "$proto" ] && {
|
|
|
|
env -i ACTION="ifdown" INTERFACE="$cfg" DEVICE="$iface" PROTO="$proto" /sbin/hotplug-call "iface"
|
2006-11-10 06:22:45 +08:00
|
|
|
}
|
|
|
|
|
2006-11-04 08:01:51 +08:00
|
|
|
# call interface stop handler
|
|
|
|
( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
|
|
|
|
|
2006-10-26 09:33:36 +08:00
|
|
|
# make sure all locks are removed
|
|
|
|
for lock in "/var/lock/dhcp-$iface" "/var/lock/ppp-$iface"; do
|
|
|
|
[ -f "$lock" ] && {
|
|
|
|
lock -u "$lock"
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
done
|
|
|
|
|
2006-10-25 07:59:08 +08:00
|
|
|
# kill active ppp daemon and other processes
|
2006-07-30 21:21:18 +08:00
|
|
|
config_get ifname "$cfg" ifname
|
2006-11-19 07:19:32 +08:00
|
|
|
pids="$(head -n1 -q /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid 2>/dev/null)"
|
2006-10-25 07:59:08 +08:00
|
|
|
for pid in $pids; do
|
|
|
|
[ -d "/proc/$pid" ] && {
|
|
|
|
kill $pid
|
2006-10-26 09:33:36 +08:00
|
|
|
[ -d "/proc/$pid" ] && {
|
|
|
|
sleep 1
|
|
|
|
kill -9 $pid 2>/dev/null >/dev/null
|
|
|
|
}
|
2006-10-25 07:59:08 +08:00
|
|
|
}
|
|
|
|
done
|
|
|
|
rm -f /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid
|
2006-07-30 11:09:09 +08:00
|
|
|
|
2006-07-30 21:21:18 +08:00
|
|
|
config_get ifname "$cfg" ifname
|
2007-02-06 09:02:30 +08:00
|
|
|
config_get device "$cfg" device
|
2006-10-25 07:59:08 +08:00
|
|
|
|
|
|
|
[ ."$device" != ."$ifname" ] || device=
|
|
|
|
for dev in $ifname $device; do
|
2007-02-06 09:02:30 +08:00
|
|
|
ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
|
2006-10-25 07:59:08 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
config_get iftype "$cfg" type
|
2007-06-16 00:07:09 +08:00
|
|
|
[ "bridge" = "$iftype" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null
|
2006-07-30 11:09:09 +08:00
|
|
|
|
2008-08-04 05:00:01 +08:00
|
|
|
# remove the interface's network state
|
|
|
|
uci_revert_state network "$1"
|
|
|
|
|
2008-08-07 23:28:48 +08:00
|
|
|
# revert aliases state as well
|
|
|
|
config_get aliases "$1" aliases
|
|
|
|
for config in $aliases; do
|
|
|
|
uci_revert_state network "$config"
|
|
|
|
done
|