6 [ -z "$DEBUG" ] ||
echo $1
9 # allow env to override nvram
11 eval "echo \${$1:-\$(nvram get $1)}"
16 [ "${1%%[0-9]}" = "vlan" ] && {
18 hwname
=$
(nvram_get vlan
${i}hwname
)
19 hwaddr
=$
(nvram_get
${hwname}macaddr
)
20 [ -z "$hwaddr" ] && return 1
22 vif
=$
(ifconfig
-a |
awk '{IGNORECASE=1} /^eth.*'$hwaddr'/ {print $1; exit}')
23 debug
"# vlan$i: $hwname $hwaddr => $vif"
25 $DEBUG ifconfig
$vif up
26 $DEBUG vconfig add
$vif $i 2>/dev
/null
28 ifconfig
"$1" >/dev
/null
2>&1 ||
[ "${1%%[0-9]}" = "br" ]
33 debug
"### wifi $1 ###"
34 if=$
(awk 'gsub(":","") {print $1}' /proc
/net
/wireless
)
40 debug
"### ifup $type ###"
42 if=$
(nvram_get
${type}_ifname
)
43 if [ "${if%%[0-9]}" = "ppp" ]; then
44 if=$
(nvram_get pppoe_ifname
)
47 if_valid
$if ||
return
49 $DEBUG ifconfig
$if down
50 if [ "${if%%[0-9]}" = "br" ]; then
51 stp
=$
(nvram_get
${type}_stp
)
52 $DEBUG brctl delbr
$if
53 $DEBUG brctl addbr
$if
54 $DEBUG brctl setfd
$if 0
55 $DEBUG brctl stp
$if $stp
56 if_list
=$
(nvram_get
${type}_ifnames
)
57 for sif
in $if_list; do {
58 if_valid
$sif ||
continue
59 $DEBUG ifconfig
$sif 0.0.0.0 up
60 $DEBUG brctl addif
$if $sif
64 if_mac
=$
(nvram_get
${type}_hwaddr
)
65 [ -z "$if_mac" ] ||
$DEBUG ifconfig
$if hw ether
$if_mac
67 if_proto
=$
(nvram_get
${type}_proto
)
70 if_ip
=$
(nvram_get
${type}_ipaddr
)
71 if_netmask
=$
(nvram_get
${type}_netmask
)
72 if_gateway
=$
(nvram_get
${type}_gateway
)
74 ipcalc
-s "$if_ip" ||
return
75 ipcalc
-s "$if_netmask" ||
return
76 $DEBUG ifconfig
$if $if_ip netmask
$if_netmask up
78 ipcalc
-s "$if_gateway" ||
return
79 $DEBUG route add default gw
$if_gateway
81 [ -f /etc
/resolv.conf
] && return
83 debug
"# --- creating /etc/resolv.conf ---"
84 for dns
in $
(nvram_get
${type}_dns
); do {
85 echo "nameserver $dns" >> /etc
/resolv.conf
89 pidfile
=/tmp
/dhcp-
${type}.pid
90 if [ -f $pidfile ]; then
91 $DEBUG kill $
(cat $pidfile)
93 cmd
="udhcpc -i $if -b -p $pidfile &"
97 if_username
=$
(nvram_get ppp_username
)
98 if_password
=$
(nvram_get ppp_passwd
)
99 if_redial
=$
(nvram_get ppp_redialperiod
)
100 if_idletime
=$
(nvram_get ppp_idletime
)
102 $DEBUG ifconfig
$if 0.0.0.0 up
104 $DEBUG /sbin
/pppoecd
$if -u $if_username -p $if_password -i 0 -I $if_redial -T $if_idletime -k
107 echo "### WARNING $if: $if_proto is not supported"
114 debug
"### ifdown $type ###"
115 if=$
(nvram_get
${type}_ifname
)
116 if_valid
$if ||
return