shithub: rc

ref: f3afdf563f784c0a5703496f48c1a72dff4617f4
dir: /wifis/

View raw version
#!/bin/rc -e
# wifis - initialize wifi and prompt for network
# usage: wifis

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 -b '#'l1 /net
	aux/wpa -p2 -s $essid /net/ether1
	ip/ipconfig -6
	ip/ipconfig ra6 recvra 1 &
	ip/ipconfig ether /net/ether1 &
	wait
	secstore=`{grep sys /net/ndb | awk -F'=' '{print $2}'}
	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
}