new url, reported by dumpedcore
[openwrt.git] / openwrt / target / default / target_skeleton / 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 ifconfig "$1" >&- 2>&- ||
17 [ "${1%%[0-9]}" = "br" ] ||
18 {
19 [ "${1%%[0-9]}" = "vlan" ] && (
20 i=${1#vlan}
21 hwname=$(nvram get vlan${i}hwname)
22 hwaddr=$(nvram get ${hwname}macaddr)
23 [ -z "$hwaddr" ] && return 1
24
25 vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1)
26 debug "# vlan$i => $vif"
27
28 $DEBUG ifconfig $vif up
29 $DEBUG vconfig add $vif $i 2>&-
30 )
31 } ||
32 { echo -e "# $1 ignored: can't find/create"; false; }
33 }
This page took 0.038744 seconds and 5 git commands to generate.