]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
add --serial-console option
authorLars Wirzenius <liw@liw.fi>
Tue, 20 Dec 2011 16:22:43 +0000 (16:22 +0000)
committerLars Wirzenius <liw@liw.fi>
Tue, 20 Dec 2011 16:22:43 +0000 (16:22 +0000)
vmdebootstrap

index 05178ea36765c3a694a9df0004cd2e8d67396db7..b6d6a48ce5a7cea5af156cd0b826b3fc00804043 100755 (executable)
@@ -61,6 +61,8 @@ class VmDebootstrap(cliapp.Application):
         self.settings.string_list(['user'],
                                   'create USER with PASSWORD',
                                   metavar='USER/PASSWORD')
+        self.settings.boolean(['serial-console'], 
+                              'configure image to use a serial console')
 
     def process_args(self, args):
         if not self.settings['image']:
@@ -272,13 +274,23 @@ timeout 1
 
 label linux
 kernel %(kernel)s
-append initrd=%(initrd)s root=UUID=%(uuid)s ro quiet
+append initrd=%(initrd)s root=UUID=%(uuid)s ro quiet %(kserial)s
+%(extserial)s
 ''' % {
     'kernel': kernel_image,
     'initrd': initrd_image,
     'uuid': uuid,
+    'kserial': 
+        'console=ttyS0,115200' if self.settings['serial-console'] else '',
+    'extserial': 'serial 0 115200' if self.settings['serial-console'] else '',
 })
         f.close()
+        
+        if self.settings['serial-console']:
+            logging.debug('adding getty to serial console')
+            inittab = os.path.join(rootdir, 'etc/inittab')
+            with open(inittab, 'a') as f:
+                f.write('\nS0:23:respawn:/sbin/getty -L ttyS0 115200 vt100\n')
 
         self.runcmd(['extlinux', '--install', rootdir])
         self.runcmd(['sync'])