summaryrefslogtreecommitdiff
path: root/vmdebootstrap
diff options
context:
space:
mode:
authorNeil Williams <codehelp@debian.org>2015-06-28 12:04:22 +0100
committerNeil Williams <codehelp@debian.org>2015-06-28 12:49:26 +0100
commitb4cda981224455188d4ba9d76a4005f3e5555d48 (patch)
treec10992d90157cc9c05f700d431c51f2f4005fd76 /vmdebootstrap
parent9497e6223cdf59eab22ee5b43b61aa9c91a93cda (diff)
downloadvmdebootstrap-b4cda981224455188d4ba9d76a4005f3e5555d48.tar.gz
Enable networking in source directory
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.
Diffstat (limited to 'vmdebootstrap')
-rwxr-xr-xvmdebootstrap24
1 files changed, 14 insertions, 10 deletions
diff --git a/vmdebootstrap b/vmdebootstrap
index bc5b887..4895147 100755
--- a/vmdebootstrap
+++ b/vmdebootstrap
@@ -624,16 +624,20 @@ class VmDebootstrap(cliapp.Application): # pylint: disable=too-many-public-meth
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']: