Skip to content

Commit

Permalink
Fix connecting to wifi networks where SSID contains a space or comma
Browse files Browse the repository at this point in the history
  • Loading branch information
viraniac committed Sep 24, 2024
1 parent 7aedf20 commit e8b241f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/bsp/common/usr/lib/armbian/armbian-firstlogin
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ set_timezone_and_locales() {
while [[ ${scanning} -lt 3 ]]; do
sleep 0.5
scanning=$(( scanning + 1 ))
ARRAY=($(iwlist ${WIFI_DEVICE} scanning 2> /dev/null | egrep 'ESSID' | sed 's/^[ \t]*//' | sed 's/"//g' | sed 's/ESSID://' | sed '/^$/d' | sort | uniq | awk 'BEGIN{FS=OFS=","} {$NF=++count OFS $NF} 1'))
if [[ $? == 0 ]]; then broken=0; break; fi
readarray -t ARRAY < <(iwlist ${WIFI_DEVICE} scanning 2> /dev/null | egrep 'ESSID' | sed 's/^[ \t]*//' | sed 's/"//g' | sed 's/ESSID://' | sed '/^$/d' | sort | uniq | awk 'BEGIN{FS=OFS=","} {$NF=++count OFS $NF} 1')
if [[ ${#ARRAY[@]} -gt 0 ]]; then broken=0; break; fi
done
# wifi can also fail
if [[ ${broken} == 1 ]]; then
Expand All @@ -320,14 +320,14 @@ set_timezone_and_locales() {
while [[ ${scanning} -lt 3 ]]; do
scanning=$(( scanning + 1 ))
while [[ 1 ]] ; do
for str in ${ARRAY[@]}; do echo $str | sed "s/,/ \t /g"; done
for str in "${ARRAY[@]}"; do echo $str | sed "s/,/ \t /"; done
echo ""
read -r -p "Enter a number of SSID: " input
if [[ "$input" =~ ^[0-9]{,2}$ ]] ; then break; fi
done
# get password
while [[ -n "${input}" ]] ; do
SSID=$(echo ${ARRAY[$input-1]} | cut -d"," -f2)
SSID=$(echo ${ARRAY[$input-1]} | cut -d"," -f2-)
echo ""
read -r -p "Enter a password for ${SSID}: " password
break
Expand Down

0 comments on commit e8b241f

Please sign in to comment.