浏览代码

Transition to network manager interfaces directory

Bob Mottram 7 年前
父节点
当前提交
34003a4de8
共有 4 个文件被更改,包括 134 次插入188 次删除
  1. 21
    44
      src/freedombone-controlpanel
  2. 16
    41
      src/freedombone-image-customise
  3. 9
    32
      src/freedombone-utils-network
  4. 88
    71
      src/freedombone-utils-wifi

+ 21
- 44
src/freedombone-controlpanel 查看文件

@@ -1441,9 +1441,9 @@ function set_static_IP {
1441 1441
 
1442 1442
     NEW_STATIC_IP=
1443 1443
     NEW_STATIC_GATEWAY=
1444
-    if grep -q 'iface eth0 inet static' /etc/network/interfaces; then
1445
-        STATIC_IP=$(cat /etc/network/interfaces | grep "address " | head -n 1 | awk -F ' ' '{print $2}')
1446
-        STATIC_GATEWAY=$(cat /etc/network/interfaces | grep "gateway " | head -n 1 | awk -F ' ' '{print $2}')
1444
+    if [ -f /etc/network/interfaces.d/static ]; then
1445
+        STATIC_IP=$(cat /etc/network/interfaces.d/static | grep "address " | head -n 1 | awk -F ' ' '{print $2}')
1446
+        STATIC_GATEWAY=$(cat /etc/network/interfaces.d/static | grep "gateway " | head -n 1 | awk -F ' ' '{print $2}')
1447 1447
     fi
1448 1448
 
1449 1449
     # get the IP for the box
@@ -1482,11 +1482,13 @@ Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_
1482 1482
 
1483 1483
     if [[ "$NEW_STATIC_GATEWAY" == *"."* && "$NEW_STATIC_IP" == *"."* ]]; then
1484 1484
         ip_addresses_have_changed=
1485
-        if ! grep -q "address ${NEW_STATIC_IP}" /etc/network/interfaces; then
1486
-            ip_addresses_have_changed=1
1487
-        fi
1488
-        if ! grep -q "gateway ${NEW_STATIC_GATEWAY}" /etc/network/interfaces; then
1489
-            ip_addresses_have_changed=1
1485
+        if [ -f /etc/network/interfaces.d/static ]; then
1486
+            if ! grep -q "address ${NEW_STATIC_IP}" /etc/network/interfaces.d/static; then
1487
+                ip_addresses_have_changed=1
1488
+            fi
1489
+            if ! grep -q "gateway ${NEW_STATIC_GATEWAY}" /etc/network/interfaces.d/static; then
1490
+                ip_addresses_have_changed=1
1491
+            fi
1490 1492
         fi
1491 1493
         if [ $ip_addresses_have_changed ]; then
1492 1494
             write_config_param "NETWORK_IS_STATIC" "1"
@@ -1508,44 +1510,19 @@ Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_
1508 1510
                 esac
1509 1511
             fi
1510 1512
 
1513
+            echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
1514
+            echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
1515
+            echo 'source /etc/network/interfaces.d/*' >> /etc/network/interfaces
1516
+
1511 1517
             if [ ! $static_wifi_address ]; then
1512 1518
                 # wired network
1513 1519
                 remove_wifi_startup_script
1514
-                echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
1515
-                echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
1516
-                echo '' >> /etc/network/interfaces
1517
-                echo '# The loopback network interface' >> /etc/network/interfaces
1518
-                echo 'auto lo' >> /etc/network/interfaces
1519
-                echo 'iface lo inet loopback' >> /etc/network/interfaces
1520
-                echo '' >> /etc/network/interfaces
1521
-                echo '# The primary network interface' >> /etc/network/interfaces
1522
-                echo 'auto eth0' >> /etc/network/interfaces
1523
-                echo 'iface eth0 inet static' >> /etc/network/interfaces
1524
-                echo "    address ${NEW_STATIC_IP}" >> /etc/network/interfaces
1525
-                echo '    netmask 255.255.255.0' >> /etc/network/interfaces
1526
-                echo "    gateway ${NEW_STATIC_GATEWAY}" >> /etc/network/interfaces
1527
-                echo "    dns-nameservers 213.73.91.35 85.214.20.141" >> /etc/network/interfaces
1528
-                echo '# Example to keep MAC address between reboots' >> /etc/network/interfaces
1529
-                echo '#hwaddress ether DE:AD:BE:EF:CA:FE' >> /etc/network/interfaces
1530
-                echo '' >> /etc/network/interfaces
1531
-                echo '# The secondary network interface' >> /etc/network/interfaces
1532
-                echo '#auto eth1' >> /etc/network/interfaces
1533
-                echo '#iface eth1 inet dhcp' >> /etc/network/interfaces
1534
-                echo '' >> /etc/network/interfaces
1535
-                echo '# WiFi Example' >> /etc/network/interfaces
1536
-                echo "#auto $WIFI_INTERFACE" >> /etc/network/interfaces
1537
-                echo "#iface $WIFI_INTERFACE inet dhcp" >> /etc/network/interfaces
1538
-                echo '#    wpa-ssid "essid"' >> /etc/network/interfaces
1539
-                echo '#    wpa-psk  "password"' >> /etc/network/interfaces
1540
-                echo '' >> /etc/network/interfaces
1541
-                echo '# Ethernet/RNDIS gadget (g_ether)' >> /etc/network/interfaces
1542
-                echo '# ... or on host side, usbnet and random hwaddr' >> /etc/network/interfaces
1543
-                echo '# Note on some boards, usb0 is automaticly setup with an init script' >> /etc/network/interfaces
1544
-                echo '#iface usb0 inet static' >> /etc/network/interfaces
1545
-                echo '#    address 192.168.7.2' >> /etc/network/interfaces
1546
-                echo '#    netmask 255.255.255.0' >> /etc/network/interfaces
1547
-                echo '#    network 192.168.7.0' >> /etc/network/interfaces
1548
-                echo '#    gateway 192.168.7.1' >> /etc/network/interfaces
1520
+
1521
+                echo 'auto eth0' > /etc/network/interfaces.d/static
1522
+                echo 'iface eth0 inet static' >> /etc/network/interfaces.d/static
1523
+                echo "    address ${NEW_STATIC_IP}" >> /etc/network/interfaces.d/static
1524
+                echo '    netmask 255.255.255.0' >> /etc/network/interfaces.d/static
1525
+                echo "    gateway ${NEW_STATIC_GATEWAY}" >> /etc/network/interfaces.d/static
1549 1526
             else
1550 1527
                 # wifi network
1551 1528
                 wifi_settings
@@ -2036,7 +2013,7 @@ function menu_wifi {
2036 2013
         if [ -f /etc/hostapd/hostapd.conf ]; then
2037 2014
             status_str=$'Hotspot ON'
2038 2015
         else
2039
-            if grep -q "# wifi enabled" /etc/network/interfaces; then
2016
+            if [ -f /etc/network/interfaces.d/wifi ]; then
2040 2017
                 status_str=$'Wifi ON'
2041 2018
             fi
2042 2019
         fi

+ 16
- 41
src/freedombone-image-customise 查看文件

@@ -183,14 +183,16 @@ configure_networking() {
183 183
     if [[ "$MACHINE" == "beaglebonewifi" ]]; then
184 184
         # Allow networking over USB in order to configure the
185 185
         # wifi login settings
186
-        echo 'auto lo' > $rootdir/etc/network/interfaces
187
-        echo 'iface lo inet loopback' >> $rootdir/etc/network/interfaces
188
-        echo '' >> $rootdir/etc/network/interfaces
189
-        echo 'iface usb0 inet static' >> $rootdir/etc/network/interfaces
190
-        echo '    address 192.168.7.2' >> $rootdir/etc/network/interfaces
191
-        echo '    netmask 255.255.255.252' >> $rootdir/etc/network/interfaces
192
-        echo '    network 192.168.7.0' >> $rootdir/etc/network/interfaces
193
-        echo '    gateway 192.168.7.1' >> $rootdir/etc/network/interfaces
186
+
187
+        echo '# This file describes the network interfaces available on your system' > $rootdir/etc/network/interfaces
188
+        echo '# and how to activate them. For more information, see interfaces(5).' >> $rootdir/etc/network/interfaces
189
+        echo 'source /etc/network/interfaces.d/*' >> $rootdir/etc/network/interfaces
190
+
191
+        echo 'iface usb0 inet static' >> $rootdir/etc/network/interfaces.d/usb
192
+        echo '    address 192.168.7.2' >> $rootdir/etc/network/interfaces.d/usb
193
+        echo '    netmask 255.255.255.252' >> $rootdir/etc/network/interfaces.d/usb
194
+        echo '    network 192.168.7.0' >> $rootdir/etc/network/interfaces.d/usb
195
+        echo '    gateway 192.168.7.1' >> $rootdir/etc/network/interfaces.d/usb
194 196
         return
195 197
     fi
196 198
 
@@ -199,41 +201,15 @@ configure_networking() {
199 201
     fi
200 202
 
201 203
     if [[ $GENERIC_IMAGE == "no" ]]; then
202
-        echo "# This file describes the network interfaces available on your system
203
-# and how to activate them. For more information, see interfaces(5).
204
-
205
-# The loopback network interface
206
-auto lo
207
-iface lo inet loopback
204
+        echo '# This file describes the network interfaces available on your system' > $rootdir/etc/network/interfaces
205
+        echo '# and how to activate them. For more information, see interfaces(5).' >> $rootdir/etc/network/interfaces
206
+        echo 'source /etc/network/interfaces.d/*' >> $rootdir/etc/network/interfaces
208 207
 
209
-# The primary network interface
210
-auto eth0
208
+        echo "auto eth0
211 209
 iface eth0 inet static
212 210
     address $BOX_IP_ADDRESS
213 211
     netmask 255.255.255.0
214
-    gateway $ROUTER_IP_ADDRESS
215
-    dns-nameservers $NAMESERVER1 $NAMESERVER2
216
-        # Example to keep MAC address between reboots
217
-        #hwaddress ether B5:A2:BE:3F:1A:FE
218
-
219
-        # The secondary network interface
220
-        #auto eth1
221
-        #iface eth1 inet dhcp
222
-
223
-        # WiFi Example
224
-        #auto wlan0
225
-        #iface wlan0 inet dhcp
226
-        #    wpa-ssid \"essid\"
227
-        #    wpa-psk  \"password\"
228
-
229
-        # Ethernet/RNDIS gadget (g_ether)
230
-        # ... or on host side, usbnet and random hwaddr
231
-        # Note on some boards, usb0 is automaticly setup with an init script
232
-        #iface usb0 inet static
233
-        #    address 192.168.7.2
234
-        #    netmask 255.255.255.0
235
-        #    network 192.168.7.0
236
-        #    gateway 192.168.7.1" > $rootdir/etc/network/interfaces
212
+    gateway $ROUTER_IP_ADDRESS" > $rootdir/etc/network/interfaces.d/static
237 213
 
238 214
         hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
239 215
         a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
@@ -241,8 +217,7 @@ iface eth0 inet static
241 217
         c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
242 218
         d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
243 219
         e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
244
-        sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" \
245
-            $rootdir/etc/network/interfaces
220
+        echo "hwaddress ether de:$a:$b:$c:$d:$e" > $rootdir/etc/network/interfaces.d/macaddress
246 221
     fi
247 222
 
248 223
     # configure DNS

+ 9
- 32
src/freedombone-utils-network 查看文件

@@ -51,38 +51,15 @@ function install_static_network {
51 51
         return
52 52
     fi
53 53
 
54
-    echo '# The loopback network interface' > /etc/network/interfaces
55
-    echo 'auto lo' >> /etc/network/interfaces
56
-    echo 'iface lo inet loopback' >> /etc/network/interfaces
57
-    echo '' >> /etc/network/interfaces
58
-    echo '# The primary network interface' >> /etc/network/interfaces
59
-    echo 'auto eth0' >> /etc/network/interfaces
60
-    echo 'iface eth0 inet static' >> /etc/network/interfaces
61
-    echo "    address $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/network/interfaces
62
-    echo '    netmask 255.255.255.0' >> /etc/network/interfaces
63
-    echo "    gateway $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
64
-    echo "    dns-nameservers $NAMESERVER1 $NAMESERVER2 $NAMESERVER3 $NAMESERVER4 $NAMESERVER5 $NAMESERVER6" >> /etc/network/interfaces
65
-    echo '# Example to keep MAC address between reboots' >> /etc/network/interfaces
66
-    echo '#hwaddress ether DE:AD:BE:EF:CA:FE' >> /etc/network/interfaces
67
-    echo '' >> /etc/network/interfaces
68
-    echo '# The secondary network interface' >> /etc/network/interfaces
69
-    echo '#auto eth1' >> /etc/network/interfaces
70
-    echo '#iface eth1 inet dhcp' >> /etc/network/interfaces
71
-    echo '' >> /etc/network/interfaces
72
-    echo '# WiFi Example' >> /etc/network/interfaces
73
-    echo "#auto $WIFI_INTERFACE" >> /etc/network/interfaces
74
-    echo "#iface $WIFI_INTERFACE inet dhcp" >> /etc/network/interfaces
75
-    echo '#    wpa-ssid "essid"' >> /etc/network/interfaces
76
-    echo '#    wpa-psk  "password"' >> /etc/network/interfaces
77
-    echo '' >> /etc/network/interfaces
78
-    echo '# Ethernet/RNDIS gadget (g_ether)' >> /etc/network/interfaces
79
-    echo '# ... or on host side, usbnet and random hwaddr' >> /etc/network/interfaces
80
-    echo '# Note on some boards, usb0 is automaticly setup with an init script' >> /etc/network/interfaces
81
-    echo '#iface usb0 inet static' >> /etc/network/interfaces
82
-    echo '#    address 192.168.7.2' >> /etc/network/interfaces
83
-    echo '#    netmask 255.255.255.0' >> /etc/network/interfaces
84
-    echo '#    network 192.168.7.0' >> /etc/network/interfaces
85
-    echo '#    gateway 192.168.7.1' >> /etc/network/interfaces
54
+    echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces
55
+    echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces
56
+    echo 'source /etc/network/interfaces.d/*' >> /etc/network/interfaces
57
+
58
+    echo 'auto eth0' > /etc/network/interfaces.d/static
59
+    echo 'iface eth0 inet static' >> /etc/network/interfaces.d/static
60
+    echo "    address $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/network/interfaces.d/static
61
+    echo '    netmask 255.255.255.0' >> /etc/network/interfaces.d/static
62
+    echo "    gateway $ROUTER_IP_ADDRESS" >> /etc/network/interfaces.d/static
86 63
 
87 64
     mark_completed $FUNCNAME
88 65
 }

+ 88
- 71
src/freedombone-utils-wifi 查看文件

@@ -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