6da7df2956085d8220979fcfdbda4e0384e521cb
[openwrt.git] / obsolete-buildroot / sources / openwrt / root / etc / functions.sh
1 #!/bin/ash
2
3 alias debug=${DEBUG:-:}
4
5 # allow env to override nvram
6 nvram () {
7 case $1 in
8 get) eval "echo \${NVRAM_$2:-\$(command nvram get $2)}";;
9 *) command nvram $*;;
10 esac
11 }
12 . /etc/nvram.overrides
13
14 # valid interface?
15 if_valid () (
16 [ "${1%%[0-9]}" = "vlan" ] && {
17 i=${1#vlan}
18 hwname=$(nvram get vlan${i}hwname)
19 hwaddr=$(nvram get ${hwname}macaddr)
20 [ -z "$hwaddr" ] && return 1
21
22 vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1)
23 debug "# vlan$i: $hwname $hwaddr => $vif"
24
25 $DEBUG ifconfig $vif up
26 $DEBUG vconfig add $vif $i 2>/dev/null
27 }
28 ifconfig "$1" >/dev/null 2>&1 || [ "${1%%[0-9]}" = "br" ]
29 )
This page took 0.049163 seconds and 3 git commands to generate.