dotfiles/bin/rc/initwifi

36 lines
520 B
Bash

#!/bin/rc -e
rfork e
fn Help{ echo `{basename $0}^' [essid]' }
fn Dump{ grep node '#'l1/ether1/ifstats }
fn Ask{
echo -n $1
essid=`{dd -bs 64 -count 1 >[2]/dev/null}
}
fn Wifi{
ip/ipconfig ether /net/ether0 unbind
bind -a '#'l1 /net
aux/wpa -p2 -s $essid /net/ether1
ip/ipconfig ether /net/ether1
cat /net/ndb
}
switch($#*){
case 0
if(~ $#essid 0){
echo Available wifi essids…
Dump
echo
Ask 'essid='
}
if(! ~ $#essid 0){
Wifi
}
case 1
essid=($1)
Wifi
case *
Help
Dump
}