4 [ -z "$DEBUG" ] ||
echo $1
7 # allow env to override nvram
9 eval "echo \${$1:-\$(nvram get $1)}"
11 .
/etc
/nvram.overrides
15 [ "${1%%[0-9]}" = "vlan" ] && {
17 hwname
=$
(nvram_get vlan
${i}hwname
)
18 hwaddr
=$
(nvram_get
${hwname}macaddr
)
19 [ -z "$hwaddr" ] && return 1
21 vif
=$
(ifconfig
-a |
awk '{IGNORECASE=1} /^eth.*'$hwaddr'/ {print $1; exit}')
22 debug
"# vlan$i: $hwname $hwaddr => $vif"
24 $DEBUG ifconfig
$vif up
25 $DEBUG vconfig add
$vif $i 2>/dev
/null
27 ifconfig
"$1" >/dev
/null
2>&1 ||
[ "${1%%[0-9]}" = "br" ]
32 echo $2|
awk -F ":" '{for(x=6,y='$1';x;x--){y+=int("0x"$x);$x=sprintf("%02x",y%256);y/=256}gsub(" ",":");print$0}'
35 debug
"### wifi $1 ###"
36 if=$
(awk 'gsub(":","") {print $1}' /proc
/net
/wireless
)
37 $DEBUG ifconfig
$if hw ether $
(mac
2 $
(nvram get et0macaddr
))
43 debug
"### ifup $type ###"
45 if=$
(nvram_get
${type}_ifname
)
46 if [ "${if%%[0-9]}" = "ppp" ]; then
47 if=$
(nvram_get pppoe_ifname
)
50 if_valid
$if ||
return
52 $DEBUG ifconfig
$if down
53 if [ "${if%%[0-9]}" = "br" ]; then
54 stp
=$
(nvram_get
${type}_stp
)
55 $DEBUG brctl delbr
$if
56 $DEBUG brctl addbr
$if
57 $DEBUG brctl setfd
$if 0
58 $DEBUG brctl stp
$if $stp
59 if_list
=$
(nvram_get
${type}_ifnames
)
60 for sif
in $if_list; do {
61 if_valid
$sif ||
continue
62 $DEBUG ifconfig
$sif 0.0.0.0 up
63 $DEBUG brctl addif
$if $sif
67 if_mac
=$
(nvram_get
${type}_hwaddr
)
68 [ -z "$if_mac" ] ||
$DEBUG ifconfig
$if hw ether
$if_mac
70 if_proto
=$
(nvram_get
${type}_proto
)
73 if_ip
=$
(nvram_get
${type}_ipaddr
)
74 if_netmask
=$
(nvram_get
${type}_netmask
)
75 if_gateway
=$
(nvram_get
${type}_gateway
)
77 ipcalc
-s "$if_ip" ||
return
78 ipcalc
-s "$if_netmask" ||
return
79 $DEBUG ifconfig
$if $if_ip netmask
$if_netmask up
81 ipcalc
-s "$if_gateway" ||
return
82 $DEBUG route add default gw
$if_gateway
84 [ -f /etc
/resolv.conf
] && return
86 debug
"# --- creating /etc/resolv.conf ---"
87 for dns
in $
(nvram_get
${type}_dns
); do {
88 echo "nameserver $dns" >> /etc
/resolv.conf
92 pidfile
=/tmp
/dhcp-
${type}.pid
93 if [ -f $pidfile ]; then
94 $DEBUG kill $
(cat $pidfile)
96 cmd
="udhcpc -i $if -b -p $pidfile &"
100 if_username
=$
(nvram_get ppp_username
)
101 if_password
=$
(nvram_get ppp_passwd
)
102 if_redial
=$
(nvram_get ppp_redialperiod
)
103 if_idletime
=$
(nvram_get ppp_idletime
)
105 $DEBUG ifconfig
$if 0.0.0.0 up
107 $DEBUG /sbin
/pppoecd
$if -u $if_username -p $if_password -i 0 -I $if_redial -T $if_idletime -k
110 echo "### WARNING $if: $if_proto is not supported"
117 debug
"### ifdown $type ###"
118 if=$
(nvram_get
${type}_ifname
)
119 if_valid
$if ||
return