hotplug-based network script rewrite
[openwrt.git] / package / base-files / default / sbin / ifup
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 ifdown $1
8
9 debug "### ifup $type ###"
10 type=$1
11
12 if_proto=$(nvram get ${type}_proto)
13 if=$(nvram get ${type}_ifname)
14
15 case "$if_proto" in
16         pppoa) hotplug_dev register atm0; exit 0 ;;
17         pppoe) 
18                 [ "$(nvram get pppoe_atm)" = 1 ] && {
19                         hotplug_dev register atm0
20                         exit
21                 }
22         ;;
23 esac
24
25 if [ "${if%%[0-9]}" = "br" ]; then
26         for sif in $(nvram get ${type}_ifnames); do
27                 hotplug_dev register "$sif"
28         done
29 else
30         hotplug_dev register "$if"
31 fi