diff options
Diffstat (limited to 'networking/wifi/device-files/select_network.sh')
-rw-r--r-- | networking/wifi/device-files/select_network.sh | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/networking/wifi/device-files/select_network.sh b/networking/wifi/device-files/select_network.sh index cdb96ab..871a7eb 100644 --- a/networking/wifi/device-files/select_network.sh +++ b/networking/wifi/device-files/select_network.sh @@ -94,6 +94,7 @@ echo -e "\t---|------------------" tmpLineFile="$workdir""/""tmpln" idx=1 declare -a AR +declare -a AUTH while IFS= read -r line do # split the line into the different properties: @@ -105,7 +106,8 @@ do IFS=' ' read -r -a SUBAR < "$tmpLineFile" AR[$idx]="${SUBAR[4]}" #the SSID is the 4th field - echo -e "\t"$idx") | ""${SUBAR[4]}" + AUTH[$idx]="${SUBAR[3]}" #the auth method is the 3rd field + echo -e "\t"$idx") | ""${SUBAR[4]}"" | ${SUBAR[3]}" idx=$(($idx+1)) done < "$tmpNetsFile" @@ -126,40 +128,55 @@ if [ "$selnet" -le 0 ] || [ "$selnet" -gt "$netnum" ]; then fi selectedSSID="${AR[$selnet]}" +selectedAuthScheme="${AUTH[$selnet]}" # check if the selected network is a known one: knownnet=$(bash "$knets_get" "$selectedSSID") -if [ -z "$knownnet" ]; then + +#We now check if the network does not need a password +echo "$selectedAuthScheme" +if [ $selectedAuthScheme == "[ESS]" ]; then + echo "No password needed." +else + if [ -z "$knownnet" ]; then # network not found among the known ones # ask for a password: echo "Enter a password for "$selectedSSID read password -else + else # extract the password from the tuple: tmpTupleFile="$workdir""/tmptpl" if [ -e "$tmpTupleFile" ]; then - rm "$tmpTupleFile" + rm "$tmpTupleFile" fi echo "$knownnet" > "$tmpTupleFile" IFS=$'\t' read -r -a TUPLE < "$tmpTupleFile" password="${TUPLE[1]}" IFS= + fi fi - #sleep 1s echo "Do you want to connect to ""$selectedSSID"" now? [y/n] " read answer if [ $answer = "y" ] || [ $answer = "Y" ]; then + if [ $selectedAuthScheme == "[ESS]" ]; then + bash "$scriptConnect" ""$selectedSSID"" + else bash "$scriptConnect" ""$selectedSSID"" ""$password"" - if [ $? -eq 0 ]; then - # successfully connected - # save password for future connections - source "$knets_add" "$selectedSSID" "$password" - echo "CONNECTED" + fi + if [ $? -eq 0 ]; then + # successfully connected + # save password for future connections + if [ $selectedAuthScheme == "[ESS]" ]; then + source "$knets_add" "$selectedSSID" else - echo "FAILED TO CONNECT" + source "$knets_add" "$selectedSSID" "$password" fi + echo "CONNECTED" + else + echo "FAILED TO CONNECT" + fi fi |