From 244de9de94a6c0302d2f9dbd4f3146e91b0155a3 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Tue, 10 Dec 2019 09:53:24 -0600 Subject: [PATCH 1/3] gui-init: remove double-prompt for checksum update Not need to prompt the user twice for the same action Signed-off-by: Matt DeVillier --- initrd/bin/gui-init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/initrd/bin/gui-init b/initrd/bin/gui-init index 522021f2..5cbca8c8 100755 --- a/initrd/bin/gui-init +++ b/initrd/bin/gui-init @@ -47,7 +47,7 @@ verify_global_hashes() elif [ ! -f $TMP_HASH_FILE ]; then if (whiptail $CONFIG_ERROR_BG_COLOR --clear --title 'ERROR: Missing Hash File!' \ --yesno "The file containing hashes for /boot is missing!\n\nIf you are setting this system up for the first time, select Yes to update\nyour list of checksums.\n\nOtherwise this could indicate a compromise and you should select No to\nreturn to the main menu.\n\nWould you like to update your checksums now?" 30 90) then - prompt_update_checksums + update_checksums fi return 1 else @@ -74,7 +74,7 @@ verify_global_hashes() fi if (whiptail $CONFIG_ERROR_BG_COLOR --clear --title 'ERROR: Boot Hash Mismatch' --yesno "$TEXT" 30 90) then - prompt_update_checksums + update_checksums fi return 1 fi From 0afa5994917c9e2f520caae06d6a20e30c8c8ba1 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Thu, 27 Feb 2020 14:39:13 -0600 Subject: [PATCH 2/3] Fix eval of DEV_NUM_PARTITIONS Using 'let' in these scripts fails when evaluating to zero for some reason, so replace with '$(())' which works as intended. Test: Boot device selection menu shown properly when new/unpartitioned drive installed. Signed-off-by: Matt DeVillier --- initrd/bin/config-gui.sh | 2 +- initrd/etc/functions | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/initrd/bin/config-gui.sh b/initrd/bin/config-gui.sh index 37b4808b..6b22e87b 100755 --- a/initrd/bin/config-gui.sh +++ b/initrd/bin/config-gui.sh @@ -36,7 +36,7 @@ while true; do > /tmp/boot_device_list.txt for i in `cat /tmp/disklist.txt`; do # remove block device from list if numeric partitions exist, since not bootable - let DEV_NUM_PARTITIONS=`ls -1 $i* | wc -l`-1 + DEV_NUM_PARTITIONS=$((`ls -1 $i* | wc -l`-1)) if [ ${DEV_NUM_PARTITIONS} -eq 0 ]; then echo $i >> /tmp/boot_device_list.txt else diff --git a/initrd/etc/functions b/initrd/etc/functions index 3ccf7bc7..a5935f61 100755 --- a/initrd/etc/functions +++ b/initrd/etc/functions @@ -322,7 +322,7 @@ detect_boot_device() > /tmp/boot_device_list for i in `cat /tmp/disklist`; do # remove block device from list if numeric partitions exist, since not bootable - let DEV_NUM_PARTITIONS=`ls -1 $i* | wc -l`-1 + DEV_NUM_PARTITIONS=$((`ls -1 $i* | wc -l`-1)) if [ ${DEV_NUM_PARTITIONS} -eq 0 ]; then echo $i >> /tmp/boot_device_list else From 0b970b745e9239a5bf24ef3fe0bb0683a477365b Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Fri, 28 Feb 2020 18:54:14 -0600 Subject: [PATCH 3/3] config-gui: clean up boot device selection When a new /boot device is selected, wait until after successfully mounting the newly-selected device before updating CONFIG_BOOT_DEV. Also, don't assume /boot already mounted, as this can cause a false failure and prevent mounting of the newly-selected device. Lastly, tidy up the error output in case mounting /boot fails. Signed-off-by: Matt DeVillier --- initrd/bin/config-gui.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/initrd/bin/config-gui.sh b/initrd/bin/config-gui.sh index 6b22e87b..f1fce23a 100755 --- a/initrd/bin/config-gui.sh +++ b/initrd/bin/config-gui.sh @@ -52,18 +52,21 @@ while true; do SELECTED_FILE=$FILE fi - replace_config /etc/config.user "CONFIG_BOOT_DEV" "$SELECTED_FILE" - combine_configs - + # unmount /boot if needed + if grep -q /boot /proc/mounts ; then + umount /boot 2>/dev/null + fi # mount newly selected /boot device - if ! ( umount /boot 2>/tmp/error && \ - mount -o ro $SELECTED_FILE /boot 2>/tmp/error ); then + if ! mount -o ro $SELECTED_FILE /boot 2>/tmp/error ; then ERROR=`cat /tmp/error` whiptail $CONFIG_ERROR_BG_COLOR --title 'ERROR: unable to mount /boot' \ - --msgbox "Unable to un/re-mount /boot:\n\n$ERROR" 16 60 + --msgbox " $ERROR\n\n" 16 60 exit 1 fi + replace_config /etc/config.user "CONFIG_BOOT_DEV" "$SELECTED_FILE" + combine_configs + whiptail --title 'Config change successful' \ --msgbox "The /boot device was successfully changed to $SELECTED_FILE" 16 60 ;;