From 0ff32d1b9736da827f0476951b72a07b20d49cdf Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 13 Jun 2018 20:58:42 -0300 Subject: Fix image packing and dest folder permissions at kvmx-create --- kvmx-create | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'kvmx-create') diff --git a/kvmx-create b/kvmx-create index 0375cf6..e98f29a 100755 --- a/kvmx-create +++ b/kvmx-create @@ -366,18 +366,24 @@ EOF # Umount image kvmx_sudo_run umount $WORK kvmx_sudo_run rmdir $WORK - kvmx_sudo_run losetup -d $device - # Image conversion - if [ "$format" == "qcow2" ]; then - echo "Converting raw image to qcow2..." - kvmx_sudo_run mv $image $image.raw - kvmx_sudo_run qemu-img convert -O qcow2 -p $compression ${image}.raw $image - kvmx_sudo_run rm ${image}.raw + # Pack guest image + if [ -z "$image_type" ] || [ "$image_type" == "file" ]; then + kvmx_sudo_run losetup -d $device + + # Image conversion + if [ "$format" == "qcow2" ]; then + echo "Converting raw image to qcow2..." + kvmx_sudo_run mv $image $image.raw + kvmx_sudo_run qemu-img convert -O qcow2 -p $compression ${image}.raw $image + kvmx_sudo_run rm ${image}.raw + fi fi # Fix permissions - kvmx_sudo_run chown -R `whoami`. `dirname $image` + if [ "`whoami`" != "root" ]; then + kvmx_sudo_run chown -R `whoami`. `dirname $image` + fi } # Second stage procedure -- cgit v1.2.3