hotplug-based network script rewrite
[openwrt.git] / package / base-files / default / sbin / ifdown
1 #!/bin/sh
2 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
3 . /etc/functions.sh
4 . /etc/network.overrides
5 [ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network
6
7 debug "### ifdown $type ###"
8 type=$1
9
10 if_proto=$(nvram get ${type}_proto)
11 if=$(nvram get ${type}_ifname)
12
13 case "$if_proto" in
14         pppoa) hotplug_dev unregister atm0; exit 0 ;;
15         pppoe) 
16                 [ "$(nvram get pppoe_atm)" = 1 ] && {
17                         hotplug_dev unregister atm0
18                         exit
19                 }
20         ;;
21 esac
22
23 if [ "${if%%[0-9]}" = "br" ]; then
24         for sif in $(nvram get ${type}_ifnames); do
25                 hotplug_dev unregister "$sif"
26         done
27 fi
28         
29 hotplug_dev unregister "$if"