]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
bootloaders: Enable serial console for GRUB if enabled
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Feb 2023 18:28:42 +0000 (18:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Feb 2023 18:28:42 +0000 (18:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/__init__.py
src/python/bootloaders.py

index 03edb7e7fbeb536a810c4a59d7ba6349101c1ba3..16c4d84050ed00921c9ac6e37581555cd6e6ab91 100644 (file)
@@ -79,6 +79,9 @@ class Bricklayer(object):
 
                        # Default timezone
                        "timezone" : "UTC",
+
+                       # Enable the serial console
+                       "serial-console" : False,
                }
 
                # Read OS information
index 665daebf851bfe39e1aa2ea34df51bb0b2106204..883edfc5f88802a870d5fe1774143ae5fbe849ae 100644 (file)
@@ -135,8 +135,16 @@ class Grub(Bootloader):
                        "GRUB_DISABLE_RECOVERY" : "true",
                }
 
-               # XXX Handle serial console
-               conf["GRUB_TERMINAL_OUTPUT"] = "\"console\""
+               # Enable the serial console
+               if self.bricklayer.settings.get("serial-console"):
+                       conf |= {
+                               "GRUB_TERMINAL_OUTPUT" : "\"serial console\"",
+                               "GRUB_SERIAL_COMMAND"  : "\"serial --unit=0 --speed=115200\”"
+                       }
+
+               # Otherwise enable a generic VGA console
+               else:
+                       conf["GRUB_TERMINAL_OUTPUT"] = "\"console\""
 
                # Write everything to file
                with self.bricklayer.open("/etc/default/grub", "w") as f: