Make helper try to umount $target on errors
authorNikos Skalkotos <skalkoto@grnet.gr>
Fri, 7 Oct 2011 08:40:09 +0000 (11:40 +0300)
committerNikos Skalkotos <skalkoto@grnet.gr>
Fri, 7 Oct 2011 08:40:09 +0000 (11:40 +0300)
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

snf-image-helper/snf-image-helper.in

index d454e36..89e4078 100644 (file)
@@ -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@"