]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Add --enable-dhcp option.
authorLars Wirzenius <liw@liw.fi>
Sun, 15 May 2011 10:30:20 +0000 (11:30 +0100)
committerLars Wirzenius <liw@liw.fi>
Sun, 15 May 2011 10:30:20 +0000 (11:30 +0100)
vmdebootstrap
vmdebootstrap.8

index fcdc774fe18e0e9e9ff5950f082db650d7bc34cb..ce163b4f47a474112e4087e8b68d5f2adf18c05c 100755 (executable)
@@ -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')
 
index ca173c7fea9b504237d4c64f83d0aaddc33bec23..229c451589c6cfb99d27fd239e57f7d73cb38005 100644 (file)
@@ -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