Testing: 3.4-rc7
Estable: 3.3.6
Estable: 3.2.17
Estable: 3.1.10 (EOL)
Estable: 3.0.31
Estable: 2.6.35.13
Estable: 2.6.34.12
Estable: 2.6.32.59
Estable: 2.6.27.62
(18/05/12 10:58:59)
#!/bin/bash
# $1 [ start | stop]
# $2 [ESSID]
# $3 [interface]
# $4 driver, [hostap | hermes | madwifi | atmel | wext | ndiswrapper | broadcom | ipw | wired | bsd | ndis]
# conecta_wpa.sh start Luiso eth1 wext
case "$1" in
start)
if [ "$2" == "" ]||[ "$3" == "" ]||[ "$4" == "" ];
then
echo "I'm not a fortune teller, "$0" start essid interface driver"
exit 1
fi
LISTA=$(iwlist $3 scan |awk -F'"' '/ESSID/{print $2}')
for i in $LISTA
do
if [ "$i" == "$2" ];
then
echo $i ok, connecting...
WPA_EXEC=$(which wpa_supplicant)
if [ "$?" == "0" ];
then
$WPA_EXEC -Bw -D$4 -i$3 -c/etc/wpa_supplicant.conf
else
echo "wpa_supplicant not found"
exit 1
fi
exit 0
fi
done
echo "ESSID: "$2" not found :("
#I need to exit with 0 to try to connect with other networks, without wpa.
exit 0
;;
stop)
killall -q wpa_supplicant
;;
*)
echo "What I have to do? [start | stop]: "$0" start essid interface driver"
esac
Y ahora en /etc/network/interfaces
auto eth1 iface eth1 inet dhcp pre-up /root/conecta_wpa.sh start Luiso eth1 wext post-down /root/conecta_wpa.sh stop