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 debug
"### wifi $1 ###"
33 if=$
(awk 'gsub(":","") {print $1}' /proc
/net
/wireless
)
39 debug
"### ifup $type ###"
41 if=$
(nvram_get
${type}_ifname
)
42 if [ "${if%%[0-9]}" = "ppp" ]; then
43 if=$
(nvram_get pppoe_ifname
)
46 if_valid
$if ||
return
48 $DEBUG ifconfig
$if down
49 if [ "${if%%[0-9]}" = "br" ]; then
50 stp
=$
(nvram_get
${type}_stp
)
51 $DEBUG brctl delbr
$if
52 $DEBUG brctl addbr
$if
53 $DEBUG brctl setfd
$if 0
54 $DEBUG brctl stp
$if $stp
55 if_list
=$
(nvram_get
${type}_ifnames
)
56 for sif
in $if_list; do {
57 if_valid
$sif ||
continue
58 $DEBUG ifconfig
$sif 0.0.0.0 up
59 $DEBUG brctl addif
$if $sif
63 if_mac
=$
(nvram_get
${type}_hwaddr
)
64 [ -z "$if_mac" ] ||
$DEBUG ifconfig
$if hw ether
$if_mac
66 if_proto
=$
(nvram_get
${type}_proto
)
69 if_ip
=$
(nvram_get
${type}_ipaddr
)
70 if_netmask
=$
(nvram_get
${type}_netmask
)
71 if_gateway
=$
(nvram_get
${type}_gateway
)
73 ipcalc
-s "$if_ip" ||
return
74 ipcalc
-s "$if_netmask" ||
return
75 $DEBUG ifconfig
$if $if_ip netmask
$if_netmask up
77 ipcalc
-s "$if_gateway" ||
return
78 $DEBUG route add default gw
$if_gateway
80 [ -f /etc
/resolv.conf
] && return
82 debug
"# --- creating /etc/resolv.conf ---"
83 for dns
in $
(nvram_get
${type}_dns
); do {
84 echo "nameserver $dns" >> /etc
/resolv.conf
88 pidfile
=/tmp
/dhcp-
${type}.pid
89 if [ -f $pidfile ]; then
90 $DEBUG kill $
(cat $pidfile)
92 cmd
="udhcpc -i $if -b -p $pidfile &"
96 if_username
=$
(nvram_get ppp_username
)
97 if_password
=$
(nvram_get ppp_passwd
)
98 if_redial
=$
(nvram_get ppp_redialperiod
)
99 if_idletime
=$
(nvram_get ppp_idletime
)
101 $DEBUG ifconfig
$if 0.0.0.0 up
103 $DEBUG /sbin
/pppoecd
$if -u $if_username -p $if_password -i 0 -I $if_redial -T $if_idletime -k
106 echo "### WARNING $if: $if_proto is not supported"
113 debug
"### ifdown $type ###"
114 if=$
(nvram_get
${type}_ifname
)
115 if_valid
$if ||
return