]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Adds image_type config and kvmx-create ask whether to overwrite existing images
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 13 Jun 2018 21:43:12 +0000 (18:43 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 13 Jun 2018 21:43:12 +0000 (18:43 -0300)
kvmx-create
kvmxfile

index a00f78c51e0674e444457bc2333ae9156ae21cf3..aca74e61835a8cfba4afe3dbad61d9c9da758ac6 100755 (executable)
@@ -149,8 +149,11 @@ kvmx_config
 
 # Check
 if [ -e "$image" ]; then
-  echo "error: $image already exists."
-  exit 1
+  kvm_user_config overwrite n "WARNING: $image already exists. Overwrite the installation? (y/n)"
+
+  if [ "$overwrite" != "y" ]; then
+    exit 1
+  fi
 fi
 
 # Ensure base folder exists
@@ -230,10 +233,16 @@ function kvmx_create_custom {
     kvmx_install_package $req
   done
 
-  echo "Creating image..."
-  #kvmx_sudo_run dd if=/dev/zero of=$image bs=$size count=1
-  kvmx_sudo_run qemu-img create -f raw $image $size
-  device="`sudo losetup --find --show $image`"
+  if [ ! -z "$image_type" ] || [ "$image_type" == "file" ]; then
+    echo "Creating image file..."
+    #kvmx_sudo_run dd if=/dev/zero of=$image bs=$size count=1
+    kvmx_sudo_run qemu-img create -f raw $image $size
+    device="`sudo losetup --find --show $image`"
+  else if [ -e "$image" ]; then
+    device="$image"
+  else
+    echo "$BASENAME: image device $image does not exist"
+  fi
 
   echo "Partitioning image at $device..."
   kvmx_sudo_run parted -s -- $device mklabel gpt
index 30aa9f70fce9666adf96a609528c60a272aee1d0..a3983678acba66b0590eb463a49a67a19c48ca9c 100644 (file)
--- a/kvmxfile
+++ b/kvmxfile
@@ -117,6 +117,9 @@ xrandr="0"
 # Where datafiles are stored: just set this if you know what you're doing
 #datadir="$HOME/.local/share/kvmx/$VM"
 
+# Image type: file or device (kvmx-create only)
+image_type="file"
+
 # Image size
 size="10G"