Commit 3bb66fac authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

helper: Fix a bug triggered by corrupted images

Fix a bug in get_partition_to_resize where the script would not stop
if the get_partition_table function failed, leading to bash syntax
errors.
parent 271fbdfd
......@@ -336,6 +336,9 @@ get_partition_to_resize() {
dev="$1"
table=$(get_partition_table "$dev")
if [ -z "$table" ]; then
return 0
fi
if [ $(get_partition_count "$table") -eq 0 ]; then
return 0
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment