diff options
author | Mike Baker <mbm@openwrt.org> | 2005-02-06 00:52:16 +0000 |
---|---|---|
committer | Mike Baker <mbm@openwrt.org> | 2005-02-06 00:52:16 +0000 |
commit | 6beed4602a645145cf500bfd211985eece93e35d (patch) | |
tree | 7f74d65e19595fd3b6a258f82ced9c9c964df586 /target/default/target_skeleton/etc/functions.sh | |
parent | 5acb824a30657b31ba7d30313d64a7da9742eb16 (diff) | |
download | upstream-6beed4602a645145cf500bfd211985eece93e35d.tar.gz upstream-6beed4602a645145cf500bfd211985eece93e35d.tar.bz2 upstream-6beed4602a645145cf500bfd211985eece93e35d.zip |
openwrt root filesystem
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@211 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/default/target_skeleton/etc/functions.sh')
-rwxr-xr-x | target/default/target_skeleton/etc/functions.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/target/default/target_skeleton/etc/functions.sh b/target/default/target_skeleton/etc/functions.sh new file mode 100755 index 0000000000..75500a2aab --- /dev/null +++ b/target/default/target_skeleton/etc/functions.sh @@ -0,0 +1,33 @@ +#!/bin/ash + +alias debug=${DEBUG:-:} + +# allow env to override nvram +nvram () { + case $1 in + get) eval "echo \${NVRAM_$2:-\$(command nvram get $2)}";; + *) command nvram $*;; + esac +} +. /etc/nvram.overrides + +# valid interface? +if_valid () { + ifconfig "$1" >&- 2>&- || + [ "${1%%[0-9]}" = "br" ] || + { + [ "${1%%[0-9]}" = "vlan" ] && ( + i=${1#vlan} + hwname=$(nvram get vlan${i}hwname) + hwaddr=$(nvram get ${hwname}macaddr) + [ -z "$hwaddr" ] && return 1 + + vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1) + debug "# vlan$i => $vif" + + $DEBUG ifconfig $vif up + $DEBUG vconfig add $vif $i 2>&- + ) + } || + { echo -e "# $1 ignored: can't find/create"; false; } +} |