add password field
This commit is contained in:
22
scripts/connectToWifi.sh
Normal file
22
scripts/connectToWifi.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo ip addr flush dev wlan0
|
||||
sudo killall wpa_supplicant
|
||||
sudo truncate -s 0 /tmp/wifi_connection_status.txt
|
||||
sudo wpa_supplicant -B -i wlan0 -f /tmp/wifi_connection_status.txt -c /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
|
||||
declare -i i=0
|
||||
declare -i timeout=10
|
||||
while [ $i -le $timeout ]; do
|
||||
if grep -iq 'CTRL-EVENT-CONNECTED' /tmp/wifi_connection_status.txt; then
|
||||
sudo dhclient wlan0
|
||||
exit 2
|
||||
elif grep -iq '4-Way Handshake failed' /tmp/wifi_connection_status.txt; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
(( i++ ))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user