I use a simple AWK script which parses the available networks as returned by ifconfig wpi0 scan and selects the first known one it finds. It then creates an /etc/hostname.wpi0 for that network and runs /etc/netstart wpi0. I attached it for reference, though I think it's extremely easy to rebuild from scratch.
--
Gregor Best
#!/usr/bin/awk -f
BEGIN {
conf["essid0"] = "wpakey foobar\ndhcp";
conf["essid1"] = "-wpakey\ndhcp";
device = "wpi0";
}
/^[[:space:]]+nwid/ {
sub("^[[:space:]]+nwid ", "")
sub(" chan [[:digit:]]+ bssid.+", "")
if ($0 in conf) {
print "Using configuration for ESSID "$0
print "up\nnwid "$0"\n"conf[$0] >("/etc/hostname."device)
system("sh /etc/netstart "device)
exit
}
}
pgpR0l9QtVop0.pgp
Description: PGP signature

