Merge branch 'feature-docs-rearrangement' into develop
[snf-image] / snf-image-helper / tasks / 80UmountImage.in
index fde3e27..52dbb4b 100644 (file)
@@ -1,5 +1,22 @@
 #! /bin/bash
 
+# Copyright (C) 2011 GRNET S.A. 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
 ### BEGIN TASK INFO
 # Provides:            UmountImage
 # RunBefore:
 set -e
 . "@commondir@/common.sh"
 
+trap task_cleanup EXIT
+report_task_start
+
 if [ ! -d "$SNF_IMAGE_TARGET" ]; then
-       log_error "Target dir:\`$SNF_IMAGE_TARGET' is missing"
+    log_error "Target dir:\`$SNF_IMAGE_TARGET' is missing"
 fi
 
-umount "$SNF_IMAGE_TARGET"
+umount_all "$SNF_IMAGE_TARGET"
 
-cleanup
-trap - EXIT
+if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "windows" ]; then
+    # Sleep for a second after umounting windows file systems just to be on
+    # the safe side. The ntfs driver is over fuse and umount with fuse is not
+    # synchronous. Since the helper VM gets killed using a sysrq call, there
+    # is a 0.0000000001% posibility that the altered data are not written back
+    # to the disk when the OS dies, unless you wait a little bit.
+    sleep 1
+fi
 
 exit 0