|
@@ -37,6 +37,7 @@ CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
|
37
|
37
|
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
|
38
|
38
|
|
39
|
39
|
WIFI_INTERFACE=wlan0
|
|
40
|
+wifi_interface_specified=
|
40
|
41
|
WIFI_TYPE='wpa2-psk'
|
41
|
42
|
WIFI_SSID=
|
42
|
43
|
WIFI_PASSPHRASE=
|
|
@@ -46,6 +47,25 @@ WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
|
46
|
47
|
NETWORKS_INTERACTIVE=
|
47
|
48
|
WIFI_DISABLE=
|
48
|
49
|
|
|
50
|
+IFACE=
|
|
51
|
+IFACE_SECONDARY=
|
|
52
|
+
|
|
53
|
+function update_wifi_adaptors {
|
|
54
|
+ IFACE=
|
|
55
|
+ IFACE_SECONDARY=
|
|
56
|
+
|
|
57
|
+ for i in $(seq 10 -1 0); do
|
|
58
|
+ if grep -q "wlan${i}" /proc/net/dev; then
|
|
59
|
+ if [ ! $IFACE ]; then
|
|
60
|
+ IFACE="wlan${i}"
|
|
61
|
+ else
|
|
62
|
+ IFACE_SECONDARY="wlan${i}"
|
|
63
|
+ return
|
|
64
|
+ fi
|
|
65
|
+ fi
|
|
66
|
+ done
|
|
67
|
+}
|
|
68
|
+
|
49
|
69
|
function wifi_get_psk {
|
50
|
70
|
ssid=$1
|
51
|
71
|
passphrase=$2
|
|
@@ -267,6 +287,12 @@ function networks_from_file {
|
267
|
287
|
}
|
268
|
288
|
|
269
|
289
|
function create_networks_interactive {
|
|
290
|
+ update_wifi_adaptors
|
|
291
|
+ if [ ! $IFACE ]; then
|
|
292
|
+ # Don't try to configure wifi if there are no adaptors
|
|
293
|
+ return
|
|
294
|
+ fi
|
|
295
|
+
|
270
|
296
|
if [ -f $WIFI_NETWORKS_FILE ]; then
|
271
|
297
|
rm $WIFI_NETWORKS_FILE
|
272
|
298
|
fi
|
|
@@ -384,6 +410,7 @@ do
|
384
|
410
|
-i|--if|--interface)
|
385
|
411
|
shift
|
386
|
412
|
WIFI_INTERFACE=${1}
|
|
413
|
+ wifi_interface_specified=1
|
387
|
414
|
;;
|
388
|
415
|
-t|--type)
|
389
|
416
|
shift
|
|
@@ -426,14 +453,23 @@ do
|
426
|
453
|
shift
|
427
|
454
|
done
|
428
|
455
|
|
|
456
|
+if [ $NETWORKS_INTERACTIVE ]; then
|
|
457
|
+ create_networks_interactive
|
|
458
|
+ exit 0
|
|
459
|
+fi
|
|
460
|
+
|
429
|
461
|
if [ $WIFI_DISABLE ]; then
|
430
|
462
|
disable_wifi $WIFI_DISABLE
|
431
|
463
|
exit 0
|
432
|
464
|
fi
|
433
|
465
|
|
434
|
|
-if [ $NETWORKS_INTERACTIVE ]; then
|
435
|
|
- create_networks_interactive
|
436
|
|
- exit 0
|
|
466
|
+if [ ! $wifi_interface_specified= ]; then
|
|
467
|
+ update_wifi_adaptors
|
|
468
|
+ if [ ! $IFACE ]; then
|
|
469
|
+ echo $'No wifi adaptors were found'
|
|
470
|
+ exit 872356
|
|
471
|
+ fi
|
|
472
|
+ WIFI_INTERFACE=$IFACE
|
437
|
473
|
fi
|
438
|
474
|
|
439
|
475
|
if [ -f $WIFI_NETWORKS_FILE ]; then
|