File tree 1 file changed +17
-1
lines changed
packages/bsp/common/usr/lib/armbian
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -284,13 +284,29 @@ set_timezone_and_locales() {
284
284
done
285
285
if [[ " ${response} " =~ ^(Y| y)$ ]]; then
286
286
287
+ # We could have multiple devices
288
+ if (( $(grep - c . <<< "$WIFI_DEVICE ") > 1 )) ; then
289
+ scanning=0
290
+ while [[ ${scanning} -lt 3 ]]; do
291
+ scanning=$(( scanning + 1 ))
292
+ echo -e " \nMultiple wireless adaptors detected. Choose primary:\n"
293
+ WIFI_DEVICES=($( printf ' %s\n' " ${WIFI_DEVICE[@]} " | sed ' s/^[ \t]*//' | sed ' s/"//g' | sed ' s/ESSID://' | awk ' BEGIN{FS=OFS=","} {$NF=++count OFS $NF} 1' ) )
294
+ for str in ${WIFI_DEVICES[@]} ; do echo $str | sed " s/,/ \t /g" ; done
295
+ echo " "
296
+ read -r -p " Enter a number of wireles adaptor: " input
297
+ if [[ " $input " =~ ^[0-9]{,2}$ && -n " $input " ]] ; then break ; fi
298
+ done
299
+ [[ -z $input ]] && input=1
300
+ WIFI_DEVICE=$( echo ${WIFI_DEVICES[$input-1]} | cut -d" ," -f2)
301
+ fi
302
+
287
303
# get list of wireless networks
288
304
scanning=0
289
305
broken=1
290
306
while [[ ${scanning} -lt 3 ]]; do
291
307
sleep 0.5
292
308
scanning=$(( scanning + 1 ))
293
- ARRAY=($( iwlist ${WIFI_DEVICE} scanning 2> /dev/null | egrep ' ESSID' | sed ' s/^[ \t]*//' | sed ' s/"//g' | sed ' s/ESSID://' | awk ' BEGIN{FS=OFS=","} {$NF=++count OFS $NF} 1' ) )
309
+ 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' ) )
294
310
if [[ $? == 0 ]]; then broken=0; break ; fi
295
311
done
296
312
# wifi can also fail
You can’t perform that action at this time.
0 commit comments