From: Nikos Skalkotos Date: Fri, 7 Oct 2011 08:40:09 +0000 (+0300) Subject: Make helper try to umount $target on errors X-Git-Tag: v0.1~24 X-Git-Url: https://code.grnet.gr/git/snf-image/commitdiff_plain/0468a748cf8dce1c5dd92c8b7ce6f9397d7a4cda Make helper try to umount $target on errors Since the mount and umount commands are tasks, if a task fails, the filesystem may have been left mounted. For this case, I've created a trap that tries to umount the filesystem --- diff --git a/snf-image-helper/snf-image-helper.in b/snf-image-helper/snf-image-helper.in index d454e36..89e4078 100644 --- a/snf-image-helper/snf-image-helper.in +++ b/snf-image-helper/snf-image-helper.in @@ -67,6 +67,10 @@ if [ -z "$RUN_PARTS" ]; then log_error "run-parts programe is missing from the system" fi +# If something goes wrong with the tasks, try to umount the target filesystem +# in case it is left mounted... +trap '{ umount $target; }' ERR + echo "Execute all snf-image tasks...." $RUN_PARTS -v --exit-on-error "@tasksdir@"