From 2686c836c6aa8abfb6ee605c3bd2987d1028b701 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Mon, 27 May 2019 11:45:09 -0500 Subject: [PATCH] gui-init: ensure /boot is sane first thing Before anything else, ensure that a default boot device is set. If not, prompt the user to set one. If set, ensure that /boot can be mounted successfully; else prompt the user to select a new boot device. Signed-off-by: Matt DeVillier --- initrd/bin/gui-init | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/initrd/bin/gui-init b/initrd/bin/gui-init index 8c441965..904c0d2c 100755 --- a/initrd/bin/gui-init +++ b/initrd/bin/gui-init @@ -8,10 +8,23 @@ CONFIG_BOOT_GUI_MENU_NAME='Heads Boot Menu' mount_boot() { + # ensure default boot device is set + if [ ! -e "$CONFIG_BOOT_DEV" ]; then + if (whiptail $CONFIG_ERROR_BG_COLOR --clear --title "ERROR: $CONFIG_BOOT_DEV missing!" \ + --yesno "The /boot device $CONFIG_BOOT_DEV could not be found!\n\nYou will need to configure the correct device for /boot.\n\nWould you like to configure the /boot device now?" 30 90) then + config-gui.sh + fi # Mount local disk if it is not already mounted - if ! grep -q /boot /proc/mounts ; then - mount -o ro /boot \ - || recovery "Unable to mount /boot" + elif ! grep -q /boot /proc/mounts ; then + mount -o ro /boot + if [ $? -ne 0 ]; then + if (whiptail $CONFIG_ERROR_BG_COLOR --clear --title 'ERROR: Cannot mount /boot' \ + --yesno "The /boot partition at $CONFIG_BOOT_DEV could not be mounted!\n\nWould you like to configure the /boot device now?" 30 90) then + config-gui.sh + else + recovery "Unable to mount /boot" + fi + fi fi } verify_global_hashes() @@ -104,6 +117,9 @@ update_totp() /bin/reboot } +# ensure /boot is sane and mount it before anything else +mount_boot + last_half=X while true; do MAIN_MENU_OPTIONS=""