From 9dd16c6d24620ce69d506677f300cc54babf9067 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 21 Aug 2014 12:32:59 +0200 Subject: [PATCH] installer+grub: Fix serial console support with GRUB2. --- config/grub2/default | 4 +--- src/installer/hw.h | 2 ++ src/installer/main.c | 33 ++++++++++++++++++++------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/config/grub2/default b/config/grub2/default index 603e78f2f0..a8b8f7805e 100644 --- a/config/grub2/default +++ b/config/grub2/default @@ -1,7 +1,5 @@ GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved -# GRUB_TERMINAL="serial console" -# GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200" -GRUB_CMDLINE_LINUX="quiet rhgb" +GRUB_CMDLINE_LINUX="panic=10" GRUB_DISABLE_RECOVERY="true" diff --git a/src/installer/hw.h b/src/installer/hw.h index bfafbe455e..ea98e2f09e 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -50,6 +50,8 @@ #define RAID_METADATA "1.0" +#define SERIAL_BAUDRATE 115200 + #define BYTES2MB(x) ((x) / 1024 / 1024) #define MB2BYTES(x) ((unsigned long long)(x) * 1024 * 1024) diff --git a/src/installer/main.c b/src/installer/main.c index bb73fc24c0..254aae8ea5 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -600,23 +600,22 @@ int main(int argc, char *argv[]) { // Installing bootloader... statuswindow(60, 4, title, _("Installing the bootloader...")); - rc = hw_install_bootloader(destination, logfile); - if (rc) { - errorbox(_("Unable to install the bootloader.")); - goto EXIT; - } - - newtPopWindow(); - /* Serial console ? */ if (serialconsole) { /* grub */ - replace("/harddisk/boot/grub/grub.conf", "splashimage", "#splashimage"); - replace("/harddisk/boot/grub/grub.conf", "#serial", "serial"); - replace("/harddisk/boot/grub/grub.conf", "#terminal", "terminal"); - replace("/harddisk/boot/grub/grub.conf", " panic=10 ", " console=ttyS0,115200n8 panic=10 "); + FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/default/grub", "a"); + if (!f) { + errorbox(_("Unable to open /etc/default/grub for writing.")); + goto EXIT; + } - /*inittab*/ + fprintf(f, "GRUB_TERMINAL=\"serial console\"\n"); + fprintf(f, "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=%d\"\n", SERIAL_BAUDRATE); + fclose(f); + + replace(DESTINATION_MOUNT_PATH "/etc/default/grub", "panic=10", "panic=10 console=ttyS0,115200n8"); + + /* inittab */ replace("/harddisk/etc/inittab", "1:2345:respawn:", "#1:2345:respawn:"); replace("/harddisk/etc/inittab", "2:2345:respawn:", "#2:2345:respawn:"); replace("/harddisk/etc/inittab", "3:2345:respawn:", "#3:2345:respawn:"); @@ -626,6 +625,14 @@ int main(int argc, char *argv[]) { replace("/harddisk/etc/inittab", "#7:2345:respawn:", "7:2345:respawn:"); } + rc = hw_install_bootloader(destination, logfile); + if (rc) { + errorbox(_("Unable to install the bootloader.")); + goto EXIT; + } + + newtPopWindow(); + /* Set marker that the user has already accepted the gpl */ mysystem(logfile, "/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted"); -- 2.39.2