|
@@ -39,6 +39,12 @@ WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
|
39
|
39
|
# repo for atheros AR9271 wifi driver
|
40
|
40
|
ATHEROS_WIFI_REPO="https://github.com/qca/open-ath9k-htc-firmware.git"
|
41
|
41
|
|
|
42
|
+function default_network_config {
|
|
43
|
+ echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
|
|
44
|
+ echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
|
|
45
|
+ echo 'source /etc/network/interfaces.d/*' >> /etc/network/interfaces
|
|
46
|
+}
|
|
47
|
+
|
42
|
48
|
# Debian stretch has a problem where the formerly predictable wlan0 and eth0
|
43
|
49
|
# device names get assigned random names. This is a hacky workaround.
|
44
|
50
|
# Also adding net.ifnames=0 to kernel options on bootloader may work.
|
|
@@ -65,16 +71,15 @@ function wifi_static_network_interface {
|
65
|
71
|
NETWORK_IS_STATIC=0
|
66
|
72
|
read_config_param "NETWORK_IS_STATIC"
|
67
|
73
|
if [ ${NETWORK_IS_STATIC} -eq 0 ]; then
|
68
|
|
- echo '#this line must always be here' >> /etc/network/interfaces
|
69
|
|
- echo 'iface default inet dhcp' >> /etc/network/interfaces
|
|
74
|
+ echo '#this line must always be here' > /etc/network/interfaces.d/static
|
|
75
|
+ echo 'iface default inet dhcp' >> /etc/network/interfaces.d/static
|
70
|
76
|
else
|
71
|
77
|
read_config_param "LOCAL_NETWORK_STATIC_IP_ADDRESS"
|
72
|
78
|
read_config_param "ROUTER_IP_ADDRESS"
|
73
|
|
- echo '#static address' >> /etc/network/interfaces
|
74
|
|
- echo 'iface default inet static' >> /etc/network/interfaces
|
75
|
|
- echo " address ${LOCAL_NETWORK_STATIC_IP_ADDRESS}" >> /etc/network/interfaces
|
76
|
|
- echo ' netmask 255.255.255.0' >> /etc/network/interfaces
|
77
|
|
- echo " gateway ${ROUTER_IP_ADDRESS}" >> /etc/network/interfaces
|
|
79
|
+ echo 'iface default inet static' > /etc/network/interfaces.d/static
|
|
80
|
+ echo " address ${LOCAL_NETWORK_STATIC_IP_ADDRESS}" >> /etc/network/interfaces.d/static
|
|
81
|
+ echo ' netmask 255.255.255.0' >> /etc/network/interfaces.d/static
|
|
82
|
+ echo " gateway ${ROUTER_IP_ADDRESS}" >> /etc/network/interfaces.d/static
|
78
|
83
|
fi
|
79
|
84
|
}
|
80
|
85
|
|
|
@@ -240,13 +245,25 @@ function hotspot_off {
|
240
|
245
|
|
241
|
246
|
rm /etc/hostapd/hostapd.conf
|
242
|
247
|
|
243
|
|
- if [ -f /etc/network/interfaces_original ]; then
|
244
|
|
- cp /etc/network/interfaces_original /etc/network/interfaces
|
|
248
|
+ if [ -f /etc/network/interfaces_original_static ]; then
|
|
249
|
+ cp /etc/network/interfaces_original_static /etc/network/interfaces.d/static
|
|
250
|
+ else
|
|
251
|
+ if [ -f /etc/network/interfaces.d/static ]; then
|
|
252
|
+ rm /etc/network/interfaces.d/static
|
|
253
|
+ fi
|
|
254
|
+ fi
|
|
255
|
+ if [ -f /etc/network/interfaces_original_wifi ]; then
|
|
256
|
+ cp /etc/network/interfaces_original_wifi /etc/network/interfaces.d/wifi
|
245
|
257
|
else
|
246
|
|
- echo '# interfaces(5) file used by ifup(8) and ifdown(8)' > /etc/network/interfaces
|
247
|
|
- echo '# Include files from /etc/network/interfaces.d:' >> /etc/network/interfaces
|
248
|
|
- echo 'source-directory /etc/network/interfaces.d' >> /etc/network/interfaces
|
|
258
|
+ if [ -f /etc/network/interfaces.d/wifi ]; then
|
|
259
|
+ rm /etc/network/interfaces.d/wifi
|
|
260
|
+ fi
|
249
|
261
|
fi
|
|
262
|
+ if [ -f /etc/network/interfaces.d/bridge ]; then
|
|
263
|
+ rm /etc/network/interfaces.d/bridge
|
|
264
|
+ fi
|
|
265
|
+
|
|
266
|
+ default_network_config
|
250
|
267
|
|
251
|
268
|
wpa_action ${WIFI_INTERFACE} stop
|
252
|
269
|
wpa_cli -i ${WIFI_INTERFACE} terminate
|
|
@@ -294,30 +311,29 @@ function hotspot_on {
|
294
|
311
|
echo '## Accept all MAC address ###' >> /etc/hostapd/hostapd.conf
|
295
|
312
|
echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
|
296
|
313
|
|
297
|
|
- if [ ! -f /etc/network/interfaces_original ]; then
|
298
|
|
- if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
299
|
|
- cp /etc/network/interfaces /etc/network/interfaces_original
|
|
314
|
+ if [ ! -f /etc/network/interfaces_original_static ]; then
|
|
315
|
+ if [ -f /etc/network/interfaces.d/static ]; then
|
|
316
|
+ cp /etc/network/interfaces.d/static /etc/network/interfaces_original_static
|
|
317
|
+ fi
|
|
318
|
+ fi
|
|
319
|
+ if [ ! -f /etc/network/interfaces_original_wifi ]; then
|
|
320
|
+ if [ -f /etc/network/interfaces.d/wifi ]; then
|
|
321
|
+ cp /etc/network/interfaces.d/wifi /etc/network/interfaces_original_wifi
|
300
|
322
|
fi
|
301
|
323
|
fi
|
302
|
324
|
|
303
|
|
- echo '# wifi enabled' > /etc/network/interfaces
|
304
|
|
- echo 'auto lo br0' >> /etc/network/interfaces
|
305
|
|
- echo 'iface lo inet loopback' >> /etc/network/interfaces
|
306
|
|
- echo '' >> /etc/network/interfaces
|
307
|
|
- echo "# wireless $WIFI_INTERFACE" >> /etc/network/interfaces
|
308
|
|
- echo "allow-hotplug $WIFI_INTERFACE" >> /etc/network/interfaces
|
309
|
|
- echo "iface $WIFI_INTERFACE inet manual" >> /etc/network/interfaces
|
310
|
|
- echo '' >> /etc/network/interfaces
|
311
|
|
- echo '# eth0 connected to the ISP router' >> /etc/network/interfaces
|
312
|
|
- echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
313
|
|
- echo 'iface eth0 inet manual' >> /etc/network/interfaces
|
314
|
|
- echo '' >> /etc/network/interfaces
|
315
|
|
- echo '# Setup bridge' >> /etc/network/interfaces
|
316
|
|
- echo 'iface br0 inet static' >> /etc/network/interfaces
|
317
|
|
- echo " bridge_ports $WIFI_INTERFACE eth0" >> /etc/network/interfaces
|
|
325
|
+ default_network_config
|
|
326
|
+
|
|
327
|
+ echo "allow-hotplug $WIFI_INTERFACE" > /etc/network/interfaces.d/wifi
|
|
328
|
+ echo "iface $WIFI_INTERFACE inet manual" >> /etc/network/interfaces.d/wifi
|
|
329
|
+
|
|
330
|
+ echo 'allow-hotplug eth0' >> /etc/network/interfaces.d/static
|
|
331
|
+ echo 'iface eth0 inet manual' >> /etc/network/interfaces.d/static
|
|
332
|
+
|
|
333
|
+ echo 'iface br0 inet static' >> /etc/network/interfaces.d/bridge
|
|
334
|
+ echo " bridge_ports $WIFI_INTERFACE eth0" >> /etc/network/interfaces.d/bridge
|
318
|
335
|
|
319
|
336
|
systemctl restart network-manager
|
320
|
|
- #ifconfig $WIFI_INTERFACE up
|
321
|
337
|
ifup $WIFI_INTERFACE
|
322
|
338
|
systemctl restart hostapd
|
323
|
339
|
}
|
|
@@ -332,8 +348,14 @@ function wifi_store_original_network_settings {
|
332
|
348
|
|
333
|
349
|
function wifi_original_network_settings {
|
334
|
350
|
remove_config_param "NETWORK_IS_STATIC"
|
335
|
|
- if [ -f /etc/network/interfaces_original ]; then
|
336
|
|
- cp /etc/network/interfaces_original /etc/network/interfaces
|
|
351
|
+ if [ -f /etc/network/interfaces.d/static ]; then
|
|
352
|
+ rm /etc/network/interfaces.d/static
|
|
353
|
+ fi
|
|
354
|
+ if [ -f /etc/network/interfaces.d/wifi ]; then
|
|
355
|
+ rm /etc/network/interfaces.d/wifi
|
|
356
|
+ fi
|
|
357
|
+ if [ -f /etc/network/interfaces.d/bridge ]; then
|
|
358
|
+ rm /etc/network/interfaces.d/bridge
|
337
|
359
|
fi
|
338
|
360
|
}
|
339
|
361
|
|
|
@@ -343,23 +365,17 @@ function wifi_wpa2_psk {
|
343
|
365
|
|
344
|
366
|
wifi_store_original_network_settings
|
345
|
367
|
|
346
|
|
- echo '# wifi enabled' > /etc/network/interfaces
|
347
|
|
- echo 'auto lo' >> /etc/network/interfaces
|
348
|
|
- echo 'iface lo inet loopback' >> /etc/network/interfaces
|
349
|
|
- echo '' >> /etc/network/interfaces
|
350
|
|
- echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
351
|
|
- echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
352
|
|
- echo '' >> /etc/network/interfaces
|
353
|
|
- echo "allow-hotplug ${WIFI_INTERFACE}" >> /etc/network/interfaces
|
354
|
|
- echo "iface ${WIFI_INTERFACE} inet manual" >> /etc/network/interfaces
|
355
|
|
- echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
356
|
|
- echo '' >> /etc/network/interfaces
|
|
368
|
+ echo 'allow-hotplug eth0' > /etc/network/interfaces.d/static
|
|
369
|
+ echo 'iface eth0 inet dhcp' >> /etc/network/interfaces.d/static
|
|
370
|
+
|
|
371
|
+ echo "allow-hotplug ${WIFI_INTERFACE}" > /etc/network/interfaces.d/wifi
|
|
372
|
+ echo "iface ${WIFI_INTERFACE} inet manual" >> /etc/network/interfaces.d/wifi
|
|
373
|
+ echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces.d/wifi
|
357
|
374
|
wifi_static_network_interface
|
358
|
375
|
|
359
|
376
|
wpa_passphrase "$ssid" "$passphrase" > $WIFI_CONFIG
|
360
|
377
|
|
361
|
378
|
systemctl restart network-manager
|
362
|
|
- #ifconfig ${WIFI_INTERFACE} up
|
363
|
379
|
ifup $WIFI_INTERFACE
|
364
|
380
|
}
|
365
|
381
|
|
|
@@ -368,17 +384,13 @@ function wifi_none {
|
368
|
384
|
|
369
|
385
|
wifi_store_original_network_settings
|
370
|
386
|
|
371
|
|
- echo '# wifi enabled' > /etc/network/interfaces
|
372
|
|
- echo 'auto lo' >> /etc/network/interfaces
|
373
|
|
- echo 'iface lo inet loopback' >> /etc/network/interfaces
|
374
|
|
- echo '' >> /etc/network/interfaces
|
375
|
|
- echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
376
|
|
- echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
377
|
|
- echo '' >> /etc/network/interfaces
|
378
|
|
- echo "allow-hotplug ${WIFI_INTERFACE}" >> /etc/network/interfaces
|
379
|
|
- echo "iface ${WIFI_INTERFACE} inet manual" >> /etc/network/interfaces
|
380
|
|
- echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
381
|
|
- echo '' >> /etc/network/interfaces
|
|
387
|
+ echo 'allow-hotplug eth0' > /etc/network/interfaces.d/static
|
|
388
|
+ echo 'iface eth0 inet dhcp' >> /etc/network/interfaces.d/static
|
|
389
|
+
|
|
390
|
+ echo "allow-hotplug ${WIFI_INTERFACE}" > /etc/network/interfaces.d/wifi
|
|
391
|
+ echo "iface ${WIFI_INTERFACE} inet manual" >> /etc/network/interfaces.d/wifi
|
|
392
|
+ echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces.d/wifi
|
|
393
|
+
|
382
|
394
|
wifi_static_network_interface
|
383
|
395
|
|
384
|
396
|
echo 'ctrl_interface=/run/wpa_supplicant' > $WIFI_CONFIG
|
|
@@ -394,7 +406,6 @@ function wifi_none {
|
394
|
406
|
echo '}' >> $WIFI_CONFIG
|
395
|
407
|
|
396
|
408
|
systemctl restart network-manager
|
397
|
|
- #ifconfig ${WIFI_INTERFACE} up
|
398
|
409
|
ifup $WIFI_INTERFACE
|
399
|
410
|
}
|
400
|
411
|
|
|
@@ -410,17 +421,13 @@ function networks_from_file {
|
410
|
421
|
|
411
|
422
|
wifi_store_original_network_settings
|
412
|
423
|
|
413
|
|
- echo '# wifi enabled' > /etc/network/interfaces
|
414
|
|
- echo 'auto lo' >> /etc/network/interfaces
|
415
|
|
- echo 'iface lo inet loopback' >> /etc/network/interfaces
|
416
|
|
- echo '' >> /etc/network/interfaces
|
417
|
|
- echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
418
|
|
- echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
419
|
|
- echo '' >> /etc/network/interfaces
|
420
|
|
- echo "allow-hotplug ${WIFI_INTERFACE}" >> /etc/network/interfaces
|
421
|
|
- echo "iface ${WIFI_INTERFACE} inet manual" >> /etc/network/interfaces
|
422
|
|
- echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
423
|
|
- echo '' >> /etc/network/interfaces
|
|
424
|
+ echo 'allow-hotplug eth0' > /etc/network/interfaces.d/static
|
|
425
|
+ echo 'iface eth0 inet dhcp' >> /etc/network/interfaces.d/static
|
|
426
|
+
|
|
427
|
+ echo "allow-hotplug ${WIFI_INTERFACE}" >> /etc/network/interfaces.d/wifi
|
|
428
|
+ echo "iface ${WIFI_INTERFACE} inet manual" >> /etc/network/interfaces.d/wifi
|
|
429
|
+ echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces.d/wifi
|
|
430
|
+
|
424
|
431
|
wifi_static_network_interface
|
425
|
432
|
|
426
|
433
|
# remove wpa_supplicant.conf if it exists
|
|
@@ -577,9 +584,19 @@ function create_networks_interactive {
|
577
|
584
|
function disable_wifi {
|
578
|
585
|
if [[ ${1} == 'yes' || ${1} == 'y' ]]; then
|
579
|
586
|
hotspot_off
|
580
|
|
- echo '# interfaces(5) file used by ifup(8) and ifdown(8)' > /etc/network/interfaces
|
581
|
|
- echo '# Include files from /etc/network/interfaces.d:' >> /etc/network/interfaces
|
582
|
|
- echo 'source-directory /etc/network/interfaces.d' >> /etc/network/interfaces
|
|
587
|
+
|
|
588
|
+ if [ -f /etc/network/interfaces.d/static ]; then
|
|
589
|
+ rm /etc/network/interfaces.d/static
|
|
590
|
+ fi
|
|
591
|
+ if [ -f /etc/network/interfaces.d/wifi ]; then
|
|
592
|
+ rm /etc/network/interfaces.d/wifi
|
|
593
|
+ fi
|
|
594
|
+ if [ -f /etc/network/interfaces.d/bridge ]; then
|
|
595
|
+ rm /etc/network/interfaces.d/bridge
|
|
596
|
+ fi
|
|
597
|
+
|
|
598
|
+ default_network_config
|
|
599
|
+
|
583
|
600
|
remove_config_param "WIFI_INTERFACE"
|
584
|
601
|
wpa_action ${WIFI_INTERFACE} stop
|
585
|
602
|
wpa_cli -i ${WIFI_INTERFACE} terminate
|