Here comes the new UCI. Enjoy :)
[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 [ interface != "$1" -o -z "$2" ] || eval "$0 $2"
9 }
10 config_load network
11 exit
12 }
13
14 # remove the interface's network state
15 uci_revert_state network "$1"
16
17 include /lib/network
18 scan_interfaces
19
20 cfg=$1
21 debug "### ifdown $cfg ###"
22
23 config_get proto "$cfg" proto
24 [ -z "$proto" ] && { echo "interface not found."; exit; }
25
26 config_get iface "$cfg" device
27 [ "static" = "$proto" ] && {
28 env -i ACTION="ifdown" INTERFACE="$cfg" DEVICE="$iface" PROTO=static /sbin/hotplug-call "iface" &
29 }
30
31 # call interface stop handler
32 ( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
33
34 # make sure all locks are removed
35 for lock in "/var/lock/dhcp-$iface" "/var/lock/ppp-$iface"; do
36 [ -f "$lock" ] && {
37 lock -u "$lock"
38 sleep 1
39 }
40 done
41
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)"
45 for pid in $pids; do
46 [ -d "/proc/$pid" ] && {
47 kill $pid
48 [ -d "/proc/$pid" ] && {
49 sleep 1
50 kill -9 $pid 2>/dev/null >/dev/null
51 }
52 }
53 done
54 rm -f /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid
55
56 config_get ifname "$cfg" ifname
57 config_get device "$cfg" device
58
59 [ ."$device" != ."$ifname" ] || device=
60 for dev in $ifname $device; do
61 ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
62 done
63
64 config_get iftype "$cfg" type
65 [ "bridge" = "$iftype" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null
66
This page took 0.056537 seconds and 5 git commands to generate.