073e80d2dad996581da3b612ae3a66363b57d474
[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 # kill active ppp daemon
16 pid="$(cat /var/run/ppp-${cfg}.pid 2>/dev/null)"
17 [ -n "$pid" -a -d "/proc/$pid" ] && {
18 kill $pid
19 sleep 1
20 [ -d "/proc/$pid" ] && kill -9 $pid
21 }
22
23 # kill any other process associated with the interface
24 config_get ifname "$cfg" ifname
25 pid="$(cat /var/run/${ifname}.pid 2>/dev/null)"
26 [ -n "$pid" -a -d "/proc/$pid" ] && kill -9 $pid
27
28 config_get ifname "$cfg" ifname
29 ifconfig "$ifname" >/dev/null 2>/dev/null && {
30 ifconfig "$ifname" 0.0.0.0 down
31
32 config_get iftype "$cfg" type
33 [ "$iftype" = "bridge" ] && brctl delbr "$ifname"
34 }
This page took 0.042065 seconds and 3 git commands to generate.