helper: Fix a bug triggered by corrupted images
[snf-image] / snf-image-helper / snf-image-helper.in
index 2ac51e2..7429743 100644 (file)
@@ -109,12 +109,17 @@ if [ -z "$SNF_IMAGE_PROPERTY_EXCLUDE_ALL_TASKS" ]; then
         log_error "Required image property \`ROOT_PARTITION' is missing or empty."
     fi
 
-    export SNF_IMAGE_RESIZE_PART="$(get_partition_to_resize "$SNF_IMAGE_DEV")"
-
     if [[ ! "$SNF_IMAGE_PROPERTY_OSFAMILY" =~ ^(linux|windows|freebsd)$ ]]; then
         log_error "Supported values for OSFAMILY property are: linux|windows|freebsd"
     fi
 
+    SNF_IMAGE_RESIZE_PART="$(get_partition_to_resize "$SNF_IMAGE_DEV")"
+    if [ -z "$SNF_IMAGE_RESIZE_PART" ]; then
+        exit 0
+    fi
+
+    export SNF_IMAGE_RESIZE_PART
+
     # If something goes wrong with the tasks, try to umount the disk file
     # systems that are still mounted.
     trap '{ umount_all "$target"; }' ERR