diff options
author | Bob Gilligan <gilligan@vyatta.com> | 2010-12-22 02:33:29 -0800 |
---|---|---|
committer | Bob Gilligan <gilligan@vyatta.com> | 2010-12-22 02:33:29 -0800 |
commit | d8dfabfd0422de3b2af240ce2c4631af51fe1dd0 (patch) | |
tree | 5a899ee32f2bae6a60b27e2b62742cd8805704a2 /scripts/install/install-image-existing | |
parent | 09ea3f3593793a86d997f918d3f3b0fa79355d94 (diff) | |
download | vyatta-cfg-quagga-d8dfabfd0422de3b2af240ce2c4631af51fe1dd0.tar.gz vyatta-cfg-quagga-d8dfabfd0422de3b2af240ce2c4631af51fe1dd0.zip |
Add more error recovery and disk space checking.
Diffstat (limited to 'scripts/install/install-image-existing')
-rwxr-xr-x | scripts/install/install-image-existing | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing index de58233e..39299507 100755 --- a/scripts/install/install-image-existing +++ b/scripts/install/install-image-existing @@ -109,6 +109,19 @@ if [ -d $BOOT_DIR/$NEWNAME ]; then fi fi +# +# Check to make sure we have enough space to install image... +# +space_avail=`df -k / | tail -1 | awk '{ print $4 }'` +space_needed=`du -s ${CD_ROOT}/live | awk '{ print $1 }'` + +if [ $space_avail -le $space_needed ]; then + echo "We do not have enough disk space to install this image!" + echo "We need $space_needed KB, but we only have $space_avail KB." + echo "Exiting..." + exit 1 +fi + # start the install echo "Installing \"$NEWNAME\" image." @@ -134,6 +147,7 @@ cp --no-dereference --preserve=all $boot_files $REL_ROOT/ >&/dev/null # mount copied squashfs if ! try_mount "-o loop,ro $target_squash $READ_ROOT"; then + rm -rf $REL_ROOT failure_exit 'Failed to mount new squashfs image.' fi @@ -141,6 +155,7 @@ fi margs="-t unionfs -o noatime,dirs=$RW_DIR=rw:$READ_ROOT=ro unionfs" margs="$margs $INST_ROOT" if ! try_mount "$margs"; then + rm -rf $REL_ROOT failure_exit 'Failed to set up root directory for postinst.' fi @@ -152,13 +167,24 @@ if ! grep -q 'tmpfs /var/run ' $PI_FSTAB >&/dev/null; then echo 'tmpfs /var/run tmpfs nosuid,nodev 0 0' >$PI_FSTAB fi +# +# Check to make sure we have enough space to copy the config and data dirs... +# +space_avail=`df -k / | tail -1 | awk '{ print $4 }'` +if [ -e $${VYATTA_CFG_DIR}/data ]; then + space_needed_data=`du -s ${VYATTA_CFG_DIR}/data | awk '{ print $1 }'` +else + space_needed_data=0 +fi +space_needed_configdata=`du -s ${VYATTA_CFG_DIR} | awk '{ print $1 }'` +space_needed_config=$(($space_needed_configdata - $space_needed_data)) + # save current config dir if needed -if [ -f "$VYATTA_CFG_DIR/config.boot" ]; then +if [ $space_avail -gt $space_needed_configdata ]; then resp='' while [ -z "$resp" ]; do echo 'Would you like to save the current configuration ' - echo 'directory and use the current start-up configuration ' - echo -n 'for the new version? (Yes/No) [Yes]: ' + echo -n 'directory and config file? (Yes/No) [Yes]: ' resp=$(get_response "Yes" "Yes No Y N") if [ "$resp" == 'yes' ] || [ "$resp" == 'y' ]; then echo 'Copying current configuration...' @@ -170,6 +196,16 @@ if [ -f "$VYATTA_CFG_DIR/config.boot" ]; then chmod -R 775 $ndir fi done +else + echo 'There is not enough space to save the current configuration directory.' + echo -n 'Would you like to continue without saving it? (Yes/No) [Yes]: ' + resp=$(get_response "Yes" "Yes No Y N") + if [ "$resp" == 'yes' ] || [ "$resp" == 'y' ]; then + echo "OK. Proceeding without saving current config directory." + else + rm -rf $REL_ROOT + failure_exit "OK. Exiting." + fi fi if [ -d /etc/ssh ]; then |