From 0b970b745e9239a5bf24ef3fe0bb0683a477365b Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Fri, 28 Feb 2020 18:54:14 -0600 Subject: [PATCH] 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 ;;