From 9507d09f75325c6157afbb6d0d9c08396ed43810 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 15 May 2011 11:30:20 +0100 Subject: [PATCH] Add --enable-dhcp option. --- vmdebootstrap | 17 +++++++++++++++++ vmdebootstrap.8 | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/vmdebootstrap b/vmdebootstrap index fcdc774..ce163b4 100755 --- a/vmdebootstrap +++ b/vmdebootstrap @@ -54,6 +54,8 @@ class VmDebootstrap(cliapp.Application): default='stable') self.settings.add_string_list_setting(['package'], 'install PACKAGE onto system') + self.settings.add_boolean_setting(['enable-dhcp'], + 'enable DHCP on eth0') def process_args(self, args): if not self.settings['image']: @@ -74,6 +76,7 @@ class VmDebootstrap(cliapp.Application): self.debootstrap(rootdir) self.set_root_password(rootdir) self.remove_udev_persistent_rules(rootdir) + self.setup_networking(rootdir) self.install_extlinux(rootdev, rootdir) except: self.cleanup() @@ -176,6 +179,20 @@ class VmDebootstrap(cliapp.Application): else: logging.debug('not removing non-existent %s' % pathname) + 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('allow-hotplug eth0\n') + f.write('iface eth0 inet dhcp\n') + + f.close() + def install_extlinux(self, rootdev, rootdir): self.message('Installing extlinux') diff --git a/vmdebootstrap.8 b/vmdebootstrap.8 index ca173c7..229c451 100644 --- a/vmdebootstrap.8 +++ b/vmdebootstrap.8 @@ -115,6 +115,13 @@ Install .I PACKAGE on the system. Can be given multiple times. +.TP +.BR \-\-enable-dhcp +Create an +.I /etc/network/interfaces +file that sets up DHCP on the eth0 interface. +This means the system booted from the image will bring up networking +automatically in typical environments. .SH EXAMPLE To create an image for the stable release of Debian: .nf -- 2.39.5