]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Fix image packing and dest folder permissions at kvmx-create
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 13 Jun 2018 23:58:42 +0000 (20:58 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 13 Jun 2018 23:58:42 +0000 (20:58 -0300)
kvmx-create

index 0375cf6d027b7a13e6d78c6cabc8e3683712b650..e98f29a950a3fe36678a5bb0143786267e3d237e 100755 (executable)
@@ -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