fix ifup for pppoa
[openwrt.git] / package / base-files / default / sbin / ifup
1 #!/bin/ash
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 type=$1
8 debug "### ifup $type ###"
9
10 if_proto=$(nvram get ${type}_proto)
11 [ "${if_proto}" = "pppoa" ] || {
12 if=$(nvram get ${type}_ifname)
13 [ "${if%%[0-9]}" = "ppp" ] && if=$(nvram get ${if_proto}_ifname)
14
15 if_valid $if || exit
16 mac=$(nvram get ${type}_hwaddr)
17 $DEBUG ifconfig $if down 2>&-
18
19 pidfile=/var/run/${if}.pid
20 [ -f $pidfile ] && $DEBUG kill $(cat $pidfile)
21
22 if [ "${if%%[0-9]}" = "br" ]; then
23 stp=$(nvram get ${type}_stp)
24 $DEBUG brctl delbr $if 2>&-
25 $DEBUG brctl addbr $if
26 $DEBUG brctl setfd $if 0
27 $DEBUG brctl stp $if ${stp:-0}
28
29 for sif in $(nvram get ${type}_ifnames); do
30 if_valid $sif || continue
31 ${mac:+$DEBUG ifconfig $sif down hw ether $mac}
32 $DEBUG ifconfig $sif 0.0.0.0 up
33 $DEBUG brctl addif $if $sif
34 done
35 else
36 ${mac:+$DEBUG ifconfig $if down hw ether $mac}
37 fi
38 }
39
40 case "$if_proto" in
41 static)
42 ip=$(nvram get ${type}_ipaddr)
43 netmask=$(nvram get ${type}_netmask)
44 gateway=$(nvram get ${type}_gateway)
45
46 $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
47 ${gateway:+$DEBUG route add default gw $gateway}
48
49 [ -f /etc/resolv.conf ] && return
50
51 debug "# --- creating /etc/resolv.conf ---"
52 for dns in $(nvram get ${type}_dns); do
53 echo "nameserver $dns" >> /etc/resolv.conf
54 done
55 ;;
56 dhcp)
57 ip=$(nvram get ${type}_ipaddr)
58 ${DEBUG:-eval} "udhcpc -R -i $if ${ip:+-r $ip} -b -p $pidfile &"
59 ;;
60 none|"")
61 ;;
62 *)
63 [ -x "/sbin/ifup.${if_proto}" ] && { $DEBUG /sbin/ifup.${if_proto} $*; exit; }
64 echo "### ifup $type: ignored ${type}_proto=\"$if_proto\" (not supported)"
65 ;;
66 esac
This page took 0.055548 seconds and 5 git commands to generate.