]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Only configure console if serial-console is set
authorNeil Williams <codehelp@debian.org>
Sat, 2 May 2015 19:29:02 +0000 (20:29 +0100)
committerNeil Williams <codehelp@debian.org>
Sat, 2 May 2015 19:29:02 +0000 (20:29 +0100)
Closes: #782304
Adapted patch from Jan Gerber <j@mailb.org>

vmdebootstrap

index 4d0ce90bbf6c16d18f18de99a03f983d72d5e2d7..8d90dd4f58166a50f6c7ddc74b126ec896ae7ebd 100755 (executable)
@@ -599,6 +599,18 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
             with open(inittab, 'a') as f:
                 f.write('\nS0:23:respawn:%s\n' % serial_command)
 
+    def _grub_serial_console(self, rootdir):
+        cmdline = 'GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=tty1 console=ttyS0,38400n8"'
+        terminal = 'GRUB_TERMINAL="serial gfxterm"'
+        command = 'GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --parity=no --stop=1"'
+        grub_cfg = os.path.join(rootdir, 'etc', 'default', 'grub')
+        logging.debug("Allowing serial output in grub config %s", grub_cfg)
+        with open(grub_cfg, 'a+') as cfg:
+            cfg.write("# %s serial support\n" % os.path.basename(__file__))
+            cfg.write("%s\n" % cmdline)
+            cfg.write("%s\n" % terminal)
+            cfg.write("%s\n" % command)
+
     def install_grub2(self, rootdev, rootdir):
         self.message("Configuring grub2")
         # rely on kpartx using consistent naming to map loop0p1 to loop0
@@ -609,17 +621,9 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
                      '%s' % os.path.join(rootdir, 'proc')])
         self.runcmd(['mount', '/sys', '-t', 'sysfs', '-obind',
                      '%s' % os.path.join(rootdir, 'sys')])
+        if self.settings['serial-console']:
+            self._grub_serial_console(rootdir)
 
-        cmdline = 'GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=tty1 console=ttyS0,38400n8"'
-        terminal = 'GRUB_TERMINAL="serial gfxterm"'
-        command = 'GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --parity=no --stop=1"'
-        grub_cfg = os.path.join(rootdir, 'etc', 'default', 'grub')
-        logging.debug("Allowing serial output in grub config %s", grub_cfg)
-        with open(grub_cfg, 'a+') as cfg:
-            cfg.write("# %s serial support\n" % os.path.basename(__file__))
-            cfg.write("%s\n" % cmdline)
-            cfg.write("%s\n" % terminal)
-            cfg.write("%s\n" % command)
         try:
             self.runcmd(['chroot', rootdir, 'update-grub'])
             self.runcmd(['chroot', rootdir, 'grub-install', install_dev])