ar7: clocks setup (prerequisite for dsl/usb) and misc cleanups.
[openwrt.git] / package / base-files / files / sbin / ifdown
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 . /etc/functions.sh
5 [ $# = 0 ] && { echo " $0 <group>"; exit; }
6 [ "x$1" = "x-a" ] && {
7 config_cb() {
8 [ -z "$2" ] || eval "$0 $2"
9 }
10 config_load network
11 exit
12 }
13 include /lib/network
14 scan_interfaces
15
16 cfg=$1
17 debug "### ifdown $cfg ###"
18
19 config_get proto "$cfg" proto
20 [ -z "$proto" ] && { echo "interface not found."; exit; }
21
22 config_get iface "$cfg" device
23 [ "$proto" = "static" ] && {
24 env -i ACTION="ifdown" INTERFACE="$config" DEVICE="$iface" PROTO=static /sbin/hotplug-call "iface" &
25 }
26
27 # call interface stop handler
28 ( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
29
30 # make sure all locks are removed
31 for lock in "/var/lock/dhcp-$iface" "/var/lock/ppp-$iface"; do
32 [ -f "$lock" ] && {
33 lock -u "$lock"
34 sleep 1
35 }
36 done
37
38 # kill active ppp daemon and other processes
39 config_get ifname "$cfg" ifname
40 pids="$(head -n1 -q /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid 2>/dev/null)"
41 for pid in $pids; do
42 [ -d "/proc/$pid" ] && {
43 kill $pid
44 [ -d "/proc/$pid" ] && {
45 sleep 1
46 kill -9 $pid 2>/dev/null >/dev/null
47 }
48 }
49 done
50 rm -f /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid
51
52 config_get ifname "$cfg" ifname
53 config_get device "$cfg" device
54
55 [ ."$device" != ."$ifname" ] || device=
56 for dev in $ifname $device; do
57 ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
58 done
59
60 config_get iftype "$cfg" type
61 [ "$iftype" = "bridge" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null
62
This page took 0.049302 seconds and 5 git commands to generate.