diff options
author | Christian Breunig <christian@breunig.cc> | 2023-04-02 10:07:18 +0200 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2023-04-02 10:07:18 +0200 |
commit | f34e9028252034cf17dbf380a2cded8bf14c71c2 (patch) | |
tree | d39e60b2b76911914a3e9998dd8dd87ee9c0582c | |
parent | 51df898e5647969cec679719b34b2f5b51318fa1 (diff) | |
download | vyatta-cfg-system-f34e9028252034cf17dbf380a2cded8bf14c71c2.tar.gz vyatta-cfg-system-f34e9028252034cf17dbf380a2cded8bf14c71c2.zip |
T5136: properly unmount filesystems after installation
-rwxr-xr-x | scripts/install/install-functions | 24 | ||||
-rwxr-xr-x | scripts/install/install-image-existing | 9 |
2 files changed, 31 insertions, 2 deletions
diff --git a/scripts/install/install-functions b/scripts/install/install-functions index b3ec42c1..feeeb489 100755 --- a/scripts/install/install-functions +++ b/scripts/install/install-functions @@ -86,10 +86,10 @@ tolower () { } # Validates a user response. Returns the response if valid. -# Returns the default is the user just hits enter. +# Returns the default is the user just hits enter. # Returns nothing if not valid. Default parameter is $1. # Options are in $2. If options are defined return must be a member -# of the enum. +# of the enum. get_response () { local ldefault=$(tolower "$1") local loptions=$(tolower "$2") @@ -370,6 +370,26 @@ EOF return 1 } +# try to unmount. log any errors and return the appropriate status. +# $1: arguments for umount +try_unmount () +{ + args="$*" + output=$(eval "umount $args 2>&1") + status=$? + if [ $status == 0 ]; then + return 0 + fi + # error + cat <<EOF +Error trying to unmount a partition/directory. +Please see $INSTALL_LOG for details. +EOF + lecho 'Error trying to unmount a partition/directory.' + lecho "umount $args\n$output" + return 1 +} + # Find 2 drives of the same size. get_size_raid () { diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing index d00d7735..abbd1421 100755 --- a/scripts/install/install-image-existing +++ b/scripts/install/install-image-existing @@ -278,6 +278,15 @@ if [ -e "$DEF_GRUB" ]; then fi fi +# unmount filesystems +if ! try_unmount "--read-only $INST_ROOT $READ_ROOT"; then + rm -rf $REL_ROOT + failure_exit 'Failed to unmount new squashfs image.' +fi + +# sync underlaying filesystems +sync + logger -p local3.warning -t "SystemImage" "System Image $NEWNAME has been added and made the default boot image" echo 'Done.' |