2004-06-06 12:52:51 +08:00
|
|
|
#!/bin/ash
|
2004-05-08 15:28:08 +08:00
|
|
|
|
2004-07-07 13:11:08 +08:00
|
|
|
alias debug=${DEBUG:-:}
|
2004-05-08 15:28:08 +08:00
|
|
|
|
2004-06-06 12:52:51 +08:00
|
|
|
# allow env to override nvram
|
2004-05-08 15:28:08 +08:00
|
|
|
nvram_get () {
|
|
|
|
eval "echo \${$1:-\$(nvram get $1)}"
|
|
|
|
}
|
2004-05-09 01:07:56 +08:00
|
|
|
. /etc/nvram.overrides
|
2004-05-08 15:28:08 +08:00
|
|
|
|
|
|
|
# valid interface?
|
|
|
|
if_valid () (
|
|
|
|
[ "${1%%[0-9]}" = "vlan" ] && {
|
2004-06-06 12:52:51 +08:00
|
|
|
i=${1#vlan}
|
2004-05-08 15:28:08 +08:00
|
|
|
hwname=$(nvram_get vlan${i}hwname)
|
|
|
|
hwaddr=$(nvram_get ${hwname}macaddr)
|
|
|
|
[ -z "$hwaddr" ] && return 1
|
|
|
|
|
2004-07-13 10:51:21 +08:00
|
|
|
vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1)
|
2004-05-08 15:28:08 +08:00
|
|
|
debug "# vlan$i: $hwname $hwaddr => $vif"
|
|
|
|
|
|
|
|
$DEBUG ifconfig $vif up
|
|
|
|
$DEBUG vconfig add $vif $i 2>/dev/null
|
|
|
|
}
|
2004-06-06 12:52:51 +08:00
|
|
|
ifconfig "$1" >/dev/null 2>&1 || [ "${1%%[0-9]}" = "br" ]
|
2004-05-08 15:28:08 +08:00
|
|
|
)
|