diff options
author | mbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2005-02-06 00:52:16 +0000 |
---|---|---|
committer | mbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2005-02-06 00:52:16 +0000 |
commit | 6fa165042b07cbb6ff52d2439e79d8ffe17be4ab (patch) | |
tree | e27ce18c541d0166fa93d2d596091036835321b0 /openwrt/target/default/target_skeleton/etc/functions.sh | |
parent | b7edba48e2818e1d302f385c1757feca86353366 (diff) |
openwrt root filesystem
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@211 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'openwrt/target/default/target_skeleton/etc/functions.sh')
-rwxr-xr-x | openwrt/target/default/target_skeleton/etc/functions.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/openwrt/target/default/target_skeleton/etc/functions.sh b/openwrt/target/default/target_skeleton/etc/functions.sh new file mode 100755 index 0000000000..75500a2aab --- /dev/null +++ b/openwrt/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; } +} |