From 7da1425438dc42ac4f9e63ca85bb8fde0925d7b3 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 12 Dec 2013 12:55:39 +0100 Subject: [PATCH] Merge force-text-mode-console into the bootloader script 52-force-text-mode-console, running after 51-bootloader, calls grub2-mkconfig (on Ubuntu that will happen via the update-grub call). This call will overwrite all the changes that 51-bootloader did to the grub.cfg. By merging the 52-force-text-mode-console code into 51-bootloader we avoid that. This also means that 51-bootloader will now call grub2-mkconfig regardless of whether there is already and existing grub2 configuration or not (52-force-text-mode-console did that in the past anyway). Additionally this commit enables the force to textmode code for openSUSE (was previously only working correctly for Ubuntu and Fedora). Closes-Bug: #1260323 Change-Id: Ida8e1a69df22d41ad70eb7154707c50613b536a8 --- elements/vm/finalise.d/51-bootloader | 33 +++++++++++-------- .../vm/finalise.d/52-force-text-mode-console | 26 --------------- 2 files changed, 20 insertions(+), 39 deletions(-) delete mode 100755 elements/vm/finalise.d/52-force-text-mode-console diff --git a/elements/vm/finalise.d/51-bootloader b/elements/vm/finalise.d/51-bootloader index 4079db41..11fd053e 100755 --- a/elements/vm/finalise.d/51-bootloader +++ b/elements/vm/finalise.d/51-bootloader @@ -120,24 +120,31 @@ function install_grub2 { # This might be better factored out into a per-distro 'install-bootblock' # helper. - if [ -f "/boot/grub/grub.cfg" ] ; then - GRUB_CFG=/boot/grub/grub.cfg - elif [ -f "/boot/grub2/grub.cfg" ] ; then + if [ -d /boot/grub2 ]; then GRUB_CFG=/boot/grub2/grub.cfg + elif [ -d /boot/grub ]; then + GRUB_CFG=/boot/grub/grub.cfg fi - # If GRUB configuration file does not exist, generate one - if [ ! $GRUB_CFG ]; then - if [ -d /boot/grub2 ]; then - GRUB_CFG=/boot/grub2/grub.cfg - elif [ -d /boot/grub ]; then - GRUB_CFG=/boot/grub/grub.cfg - fi - grub2-mkconfig -o $GRUB_CFG - fi; - DIST=`lsb_release -is` [ -n "$DIST" ] + echo 'GRUB_TERMINAL=console' >>/etc/default/grub + echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub + GRUB_MKCONFIG="grub2-mkconfig -o $GRUB_CFG" + case $DIST in + 'Ubuntu'|'Debian') + sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub + GRUB_MKCONFIG=update-grub + ;; + 'Fedora') + echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub + ;; + 'openSUSE project') + sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub + ;; + esac + $GRUB_MKCONFIG + RELEASE=`lsb_release -cs` [ -n "$RELEASE" ] # grub-mkconfig generates a config with the device in it, diff --git a/elements/vm/finalise.d/52-force-text-mode-console b/elements/vm/finalise.d/52-force-text-mode-console deleted file mode 100755 index a647e00d..00000000 --- a/elements/vm/finalise.d/52-force-text-mode-console +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -e - -# If lsb_release is missing, just do nothing. -DISTRO=`lsb_release -si` || true - -GRUBFILE="" - -echo 'GRUB_TERMINAL=console' >>/etc/default/grub -echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub - -case $DISTRO in - 'Ubuntu'|'Debian') - sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub - update-grub - ;; - 'Fedora') - # By default the F19 cloud image is using extlinux to boot the image - if [ -f /boot/grub2/grub.cfg ]; then - echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >/etc/default/grub - sed -i -e 's/terminal_output gfxterm/terminal_output console/' /boot/grub2/grub.cfg - grub2-mkconfig -o /boot/grub2/grub.cfg - fi - ;; -esac