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 <matt.devillier@puri.sm>
This commit is contained in:
Matt DeVillier 2020-02-28 18:54:14 -06:00
parent 0afa599491
commit 0b970b745e
No known key found for this signature in database
GPG Key ID: 2BBB776A35B978FD

View File

@ -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
;;