X-Git-Url: https://code.grnet.gr/git/snf-image/blobdiff_plain/de7269cd86072e13f91fefe1fb96f3f2446b0063..876aef198b58c5904738d3fcd9cf31f244e87f37:/snf-image-helper/tasks/80UmountImage.in diff --git a/snf-image-helper/tasks/80UmountImage.in b/snf-image-helper/tasks/80UmountImage.in index 5b6b497..52dbb4b 100644 --- a/snf-image-helper/tasks/80UmountImage.in +++ b/snf-image-helper/tasks/80UmountImage.in @@ -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: @@ -10,11 +27,23 @@ 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" + +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