m/installer: log to tty0 and ttyS0
Without this we only log to whatever the default system console is.
Change-Id: I64b43f8617f3b8752332209b511ea470848c4481
Reviewed-on: https://review.monogon.dev/c/monogon/+/1381
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/metropolis/installer/main.go b/metropolis/installer/main.go
index 520bc89..7dc1da9 100644
--- a/metropolis/installer/main.go
+++ b/metropolis/installer/main.go
@@ -178,20 +178,13 @@
return nil
}
-// panicf is a replacement for log.panicf that doesn't print the error message
-// before calling panic.
-func panicf(format string, v ...interface{}) {
- s := fmt.Sprintf(format, v...)
- panic(s)
-}
-
func main() {
// Reboot on panic after a delay. The error string will have been printed
// before recover is called.
defer func() {
if r := recover(); r != nil {
- fmt.Println(r)
- fmt.Println("The installation could not be finalized. Please reboot to continue.")
+ logf("Fatal error: %v", r)
+ logf("The installation could not be finalized. Please reboot to continue.")
syscall.Pause()
}
}()
@@ -200,6 +193,12 @@
if err := mountPseudoFS(); err != nil {
panicf("While mounting pseudo-filesystems: %v", err)
}
+
+ go logPiper()
+ logf("Metropolis Installer")
+ logf("Copyright (c) 2023 The Monogon Project Authors")
+ logf("")
+
// Read the installer ESP UUID from efivarfs.
espUuid, err := efivarfs.ReadLoaderDevicePartUUID()
if err != nil {
@@ -292,7 +291,7 @@
// Use osimage to partition the target block device and set up its ESP.
// Create will return an EFI boot entry on success.
- fmt.Printf("Installing to %s\n", tgtBlkdevPath)
+ logf("Installing to %s...", tgtBlkdevPath)
be, err := osimage.Create(&installParams)
if err != nil {
panicf("While installing: %v", err)
@@ -327,6 +326,6 @@
// Reboot.
unix.Sync()
- fmt.Println("Installation completed. Rebooting.")
+ logf("Installation completed. Rebooting.")
unix.Reboot(unix.LINUX_REBOOT_CMD_RESTART)
}