source: trunk/root/etc/functions.sh @ 94

Last change on this file since 94 was 94, checked in by mbm, 12 years ago

split ifup/ifdown/wifi into standalone scripts

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 606 bytes
Line 
1#!/bin/ash
2
3alias debug=${DEBUG:-:}
4
5# allow env to override nvram
6nvram_get () {
7 eval "echo \${$1:-\$(nvram get $1)}"
8}
9. /etc/nvram.overrides
10
11# valid interface?
12if_valid () (
13  [ "${1%%[0-9]}" = "vlan" ] && {
14    i=${1#vlan}
15    hwname=$(nvram_get vlan${i}hwname)
16    hwaddr=$(nvram_get ${hwname}macaddr)
17    [ -z "$hwaddr" ] && return 1
18
19    vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1)
20    debug "# vlan$i: $hwname $hwaddr => $vif"
21
22    $DEBUG ifconfig $vif up
23    $DEBUG vconfig add $vif $i 2>/dev/null
24  }
25  ifconfig "$1" >/dev/null 2>&1 || [ "${1%%[0-9]}" = "br" ]
26)
Note: See TracBrowser for help on using the repository browser.