From 8a226fc21aa3979ed79914ae8e3cc5b628a7d911 Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 13 Sep 2024 11:37:38 -0400 Subject: [PATCH] wpa_temp: more correct process management --- wpa_temp/wpa_temp.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wpa_temp/wpa_temp.sh b/wpa_temp/wpa_temp.sh index 5db3946..5fe7c5c 100755 --- a/wpa_temp/wpa_temp.sh +++ b/wpa_temp/wpa_temp.sh @@ -10,7 +10,9 @@ if [ -f /tmp/wpa.conf ]; then fi # get passphrase if not provided by $2 -if [[ "$2" -ne "" ]]; then +if [[ "$2" -eq "NONE" ]]; then + PSK="" +elif [[ "$2" -ne "" ]]; then PSK="$2" else read -p "enter passphrase: " PSK @@ -18,13 +20,17 @@ 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 +if [[ "$PSK" -ne "" ]]; then + wpa_passphrase "$1" "$PSK" >> /tmp/wpa.conf +else + echo -e "network={\n\tssid=\"$1\"\n\tkey_mgmt=NONE\n}" >> /tmp/wpa.conf +fi # 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;; + y|Y ) sudo sv stop wpa_supplicant;; * ) rm /tmp/wpa.conf; exit 1;; esac fi