ref: 267e3cc41aa9aed63f2b9f7e9b69ef0b49f3c7c7
dir: /sys/src/9/boot/net.rc/
#!/bin/rc
fn confignet{
# get primary default interface if not specified
if(~ $#* 0){
e=/net/ether*
if(! ~ $e '/net/ether*')
*=(ether $e(1))
}
# setup wifi encryption if any
if(~ $1 ether && ~ $service terminal && test -x /bin/aux/wpa){
if(grep -s '^status: need authentication' $2/ifstats >[2]/dev/null){
aux/wpa -p $2
}
}
must ip/ipconfig -p $*
if(~ $#fs 0)
fs=`{awk -F'=' '/fs=/{print $2; exit}' /net/ndb}
if(~ $#auth 0)
auth=`{awk -F'=' '/auth=/{print $2; exit}' /net/ndb}
if(~ $#fs 0)
ask fs ' ip is? ' $auth
if(~ $#auth 0){
ask auth ' ip is? ' $fs
if(~ $#auth 1)
echo ' auth='^$auth >>/net/ndb
}
}
fn connecttcp{
srv -q tcp!$fs!564 boot
}
fn connectil{
srv -q il!$fs!17008 boot
}
mtcp=(confignet connecttcp)
mil=(confignet connectil)
mt=(mtcp mil $mt)