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