new script: wpa_temp

This commit is contained in:
Valerie Wolfe 2024-03-16 21:41:11 -04:00
parent 69a96b958f
commit 3d9e629586

32
wpa_temp/wpa_temp.sh Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/bash
# protect existing connection
if [ -f /tmp/wpa.conf ]; then
read -p "delete existing temp config? (y/N) " choice
case "$choice" in
y|Y ) rm /tmp/wpa.conf;;
* ) exit 1;;
esac
fi
# get passphrase if not provided by $2
if [[ "$2" -ne "" ]]; then
PSK="$2"
else
read -p "enter passphrase: " PSK
fi
# make tmp config
echo -e "# temp configuration file for wpa_supplicant\nctrl_interface=/run/wpa_supplicant\nctrl_interface_group=wheel\neapol_version=1\nap_scan=1\nfast_reauth=1\nupdate_config=1\n" > /tmp/wpa.conf
wpa_passphrase "$1" "$PSK" >> /tmp/wpa.conf
# protect existing wpa_supplicant
if [ -f /run/wpa_supplicant/wlp3s0 ]; then
read -p "stop existing wpa_supplicant? (y/N) " choice
case "$choice" in
y|Y ) sudo rm /run/wpa_supplicant/wlp3s0;;
* ) rm /tmp/wpa.conf; exit 1;;
esac
fi
sudo wpa_supplicant -B -i wlp3s0 -c /tmp/wpa.conf