Parcourir la source

Transition to network manager interfaces directory

Bob Mottram il y a 7 ans
Parent
révision
34003a4de8

+ 21
- 44
src/freedombone-controlpanel Voir le fichier

1441
 
1441
 
1442
     NEW_STATIC_IP=
1442
     NEW_STATIC_IP=
1443
     NEW_STATIC_GATEWAY=
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
     fi
1447
     fi
1448
 
1448
 
1449
     # get the IP for the box
1449
     # get the IP for the box
1482
 
1482
 
1483
     if [[ "$NEW_STATIC_GATEWAY" == *"."* && "$NEW_STATIC_IP" == *"."* ]]; then
1483
     if [[ "$NEW_STATIC_GATEWAY" == *"."* && "$NEW_STATIC_IP" == *"."* ]]; then
1484
         ip_addresses_have_changed=
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
         fi
1492
         fi
1491
         if [ $ip_addresses_have_changed ]; then
1493
         if [ $ip_addresses_have_changed ]; then
1492
             write_config_param "NETWORK_IS_STATIC" "1"
1494
             write_config_param "NETWORK_IS_STATIC" "1"
1508
                 esac
1510
                 esac
1509
             fi
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
             if [ ! $static_wifi_address ]; then
1517
             if [ ! $static_wifi_address ]; then
1512
                 # wired network
1518
                 # wired network
1513
                 remove_wifi_startup_script
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
             else
1526
             else
1550
                 # wifi network
1527
                 # wifi network
1551
                 wifi_settings
1528
                 wifi_settings
2036
         if [ -f /etc/hostapd/hostapd.conf ]; then
2013
         if [ -f /etc/hostapd/hostapd.conf ]; then
2037
             status_str=$'Hotspot ON'
2014
             status_str=$'Hotspot ON'
2038
         else
2015
         else
2039
-            if grep -q "# wifi enabled" /etc/network/interfaces; then
2016
+            if [ -f /etc/network/interfaces.d/wifi ]; then
2040
                 status_str=$'Wifi ON'
2017
                 status_str=$'Wifi ON'
2041
             fi
2018
             fi
2042
         fi
2019
         fi

+ 16
- 41
src/freedombone-image-customise Voir le fichier

183
     if [[ "$MACHINE" == "beaglebonewifi" ]]; then
183
     if [[ "$MACHINE" == "beaglebonewifi" ]]; then
184
         # Allow networking over USB in order to configure the
184
         # Allow networking over USB in order to configure the
185
         # wifi login settings
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
         return
196
         return
195
     fi
197
     fi
196
 
198
 
199
     fi
201
     fi
200
 
202
 
201
     if [[ $GENERIC_IMAGE == "no" ]]; then
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
 iface eth0 inet static
209
 iface eth0 inet static
212
     address $BOX_IP_ADDRESS
210
     address $BOX_IP_ADDRESS
213
     netmask 255.255.255.0
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
         hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
214
         hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
239
         a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
215
         a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
241
         c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
217
         c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
242
         d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
218
         d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
243
         e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
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
     fi
221
     fi
247
 
222
 
248
     # configure DNS
223
     # configure DNS

+ 9
- 32
src/freedombone-utils-network Voir le fichier

51
         return
51
         return
52
     fi
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
     mark_completed $FUNCNAME
64
     mark_completed $FUNCNAME
88
 }
65
 }

+ 88
- 71
src/freedombone-utils-wifi Voir le fichier

39
 # repo for atheros AR9271 wifi driver
39
 # repo for atheros AR9271 wifi driver
40
 ATHEROS_WIFI_REPO="https://github.com/qca/open-ath9k-htc-firmware.git"
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
 # Debian stretch has a problem where the formerly predictable wlan0 and eth0
48
 # Debian stretch has a problem where the formerly predictable wlan0 and eth0
43
 # device names get assigned random names. This is a hacky workaround.
49
 # device names get assigned random names. This is a hacky workaround.
44
 # Also adding net.ifnames=0 to kernel options on bootloader may work.
50
 # Also adding net.ifnames=0 to kernel options on bootloader may work.
65
     NETWORK_IS_STATIC=0
71
     NETWORK_IS_STATIC=0
66
     read_config_param "NETWORK_IS_STATIC"
72
     read_config_param "NETWORK_IS_STATIC"
67
     if [ ${NETWORK_IS_STATIC} -eq 0 ]; then
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
     else
76
     else
71
         read_config_param "LOCAL_NETWORK_STATIC_IP_ADDRESS"
77
         read_config_param "LOCAL_NETWORK_STATIC_IP_ADDRESS"
72
         read_config_param "ROUTER_IP_ADDRESS"
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
     fi
83
     fi
79
 }
84
 }
80
 
85
 
240
 
245
 
241
     rm /etc/hostapd/hostapd.conf
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
     else
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
     fi
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
     wpa_action ${WIFI_INTERFACE} stop
268
     wpa_action ${WIFI_INTERFACE} stop
252
     wpa_cli -i ${WIFI_INTERFACE} terminate
269
     wpa_cli -i ${WIFI_INTERFACE} terminate
294
     echo '## Accept all MAC address ###' >> /etc/hostapd/hostapd.conf
311
     echo '## Accept all MAC address ###' >> /etc/hostapd/hostapd.conf
295
     echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
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
         fi
322
         fi
301
     fi
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
     systemctl restart network-manager
336
     systemctl restart network-manager
320
-    #ifconfig $WIFI_INTERFACE up
321
     ifup $WIFI_INTERFACE
337
     ifup $WIFI_INTERFACE
322
     systemctl restart hostapd
338
     systemctl restart hostapd
323
 }
339
 }
332
 
348
 
333
 function wifi_original_network_settings {
349
 function wifi_original_network_settings {
334
     remove_config_param "NETWORK_IS_STATIC"
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
     fi
359
     fi
338
 }
360
 }
339
 
361
 
343
 
365
 
344
     wifi_store_original_network_settings
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
     wifi_static_network_interface
374
     wifi_static_network_interface
358
 
375
 
359
     wpa_passphrase "$ssid" "$passphrase" > $WIFI_CONFIG
376
     wpa_passphrase "$ssid" "$passphrase" > $WIFI_CONFIG
360
 
377
 
361
     systemctl restart network-manager
378
     systemctl restart network-manager
362
-    #ifconfig ${WIFI_INTERFACE} up
363
     ifup $WIFI_INTERFACE
379
     ifup $WIFI_INTERFACE
364
 }
380
 }
365
 
381
 
368
 
384
 
369
     wifi_store_original_network_settings
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
     wifi_static_network_interface
394
     wifi_static_network_interface
383
 
395
 
384
     echo 'ctrl_interface=/run/wpa_supplicant' > $WIFI_CONFIG
396
     echo 'ctrl_interface=/run/wpa_supplicant' > $WIFI_CONFIG
394
     echo '}' >> $WIFI_CONFIG
406
     echo '}' >> $WIFI_CONFIG
395
 
407
 
396
     systemctl restart network-manager
408
     systemctl restart network-manager
397
-    #ifconfig ${WIFI_INTERFACE} up
398
     ifup $WIFI_INTERFACE
409
     ifup $WIFI_INTERFACE
399
 }
410
 }
400
 
411
 
410
 
421
 
411
     wifi_store_original_network_settings
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
     wifi_static_network_interface
431
     wifi_static_network_interface
425
 
432
 
426
     # remove wpa_supplicant.conf if it exists
433
     # remove wpa_supplicant.conf if it exists
577
 function disable_wifi {
584
 function disable_wifi {
578
     if [[ ${1} == 'yes' || ${1} == 'y' ]]; then
585
     if [[ ${1} == 'yes' || ${1} == 'y' ]]; then
579
         hotspot_off
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
         remove_config_param "WIFI_INTERFACE"
600
         remove_config_param "WIFI_INTERFACE"
584
         wpa_action ${WIFI_INTERFACE} stop
601
         wpa_action ${WIFI_INTERFACE} stop
585
         wpa_cli -i ${WIFI_INTERFACE} terminate
602
         wpa_cli -i ${WIFI_INTERFACE} terminate