add password field

This commit is contained in:
2024-03-28 04:36:20 +01:00
parent 2d7186c7c9
commit db1731fde6
4 changed files with 36 additions and 2 deletions

22
scripts/connectToWifi.sh Normal file
View 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