diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-06-13 18:43:12 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-06-13 18:43:12 -0300 |
commit | b60e8245f323f792b01e0dd15435ee076e1a07bb (patch) | |
tree | 016114754c92912a9075d13d196a08c5543b2772 /kvmx-create | |
parent | bc5a65b517273a3bc59ecd27fed5fce29fa7a6cb (diff) | |
download | kvmx-b60e8245f323f792b01e0dd15435ee076e1a07bb.tar.gz kvmx-b60e8245f323f792b01e0dd15435ee076e1a07bb.tar.bz2 |
Adds image_type config and kvmx-create ask whether to overwrite existing images
Diffstat (limited to 'kvmx-create')
-rwxr-xr-x | kvmx-create | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/kvmx-create b/kvmx-create index a00f78c..aca74e6 100755 --- a/kvmx-create +++ b/kvmx-create @@ -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 |