]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Enable networking in source directory
authorNeil Williams <codehelp@debian.org>
Sun, 28 Jun 2015 11:04:22 +0000 (12:04 +0100)
committerNeil Williams <codehelp@debian.org>
Sun, 28 Jun 2015 11:49:26 +0000 (12:49 +0100)
To allow customisation in /etc/network/interfaces.d/,
ensure that /etc/network/interfaces looks into the
source directory and put the initial config in
a setup file in the source directory.

vmdebootstrap
vmdebootstrap.8.in

index bc5b887b97ebfe6f127310e31dffc925aff86bd6..4895147457cb7ee06fddc42281b5bd9af5d66e6c 100755 (executable)
@@ -624,16 +624,20 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
     def setup_networking(self, rootdir):
         self.message('Setting up networking')
 
     def setup_networking(self, rootdir):
         self.message('Setting up networking')
 
-        f = open(os.path.join(rootdir, 'etc', 'network', 'interfaces'), 'w')
-        f.write('auto lo\n')
-        f.write('iface lo inet loopback\n')
-
-        if self.settings['enable-dhcp']:
-            f.write('\n')
-            f.write('auto eth0\n')
-            f.write('iface eth0 inet dhcp\n')
-
-        f.close()
+        if not os.path.exists(os.path.join(rootdir, 'etc', 'network', 'interfaces')):
+            with open(os.path.join(
+                rootdir, 'etc', 'network', 'interfaces'), 'w') as netfile:
+                netfile.write('source-directory /etc/network/interfaces.d\n')
+
+        with open(os.path.join(
+            rootdir, 'etc', 'network', 'interfaces.d', 'setup'), 'w') as eth:
+            eth.write('auto lo\n')
+            eth.write('iface lo inet loopback\n')
+
+            if self.settings['enable-dhcp']:
+                eth.write('\n')
+                eth.write('auto eth0\n')
+                eth.write('iface eth0 inet dhcp\n')
 
     def append_serial_console(self, rootdir):
         if self.settings['serial-console']:
 
     def append_serial_console(self, rootdir):
         if self.settings['serial-console']:
index 34dfe024c0a78f3f324c924d094c036e98185335..e1cd3ff3e968d2f17e2cf83d4fe88bbb0aee4762 100644 (file)
@@ -65,6 +65,24 @@ and log into it via its console to configure it.
 The image has an empty root password and will not have networking
 configured by default. Set the root password before you configure
 networking.
 The image has an empty root password and will not have networking
 configured by default. Set the root password before you configure
 networking.
+.SH NETWORKING
+The \-\-enable\-networking option uses the /etc/network/interfaces.d/
+source directory, with the default settings for
+.B lo
+and
+.B eth0
+being added to /etc/network/interfaces.d/setup. Other networking
+configuration can be specified using a customisation script.
+Localhost settings would be:
+ auto lo
+ iface lo inet loopback
+
+If \-\-enable\-dhcp is specified, these settings are also included
+into /etc/network/interfaces.d/setup:
+
+ auto eth0
+ iface eth0 inet dhcp
+
 .SH BOOTLOADERS
 Unless the \-\-no\-extlinux or \-\-grub options are specified, the
 image will use
 .SH BOOTLOADERS
 Unless the \-\-no\-extlinux or \-\-grub options are specified, the
 image will use