]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Guess image name by hostname first if no image param is found
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 4 Apr 2017 13:41:40 +0000 (10:41 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 4 Apr 2017 13:41:40 +0000 (10:41 -0300)
kvmx
kvmx-create

diff --git a/kvmx b/kvmx
index 59827544b037bc202c75453d1b425b21b5de645a..44ecdd290b350194fb637c207d5edde328855a04 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -128,7 +128,17 @@ function __kvmx_initialize {
         image_base="$HOME/.local/share/kvmx"
       fi
 
-      image="$image_base/$VM/box.img"
+      # There might be trouble managing the guest when project folder name is different from
+      # hostname and no image param is set (kvmx-create puts image in one
+      # place, kvmx expects in the other). So we try to guess first the image by hostname
+      # and then by guest name. Note that it might be possible to have conflicts if there
+      # are machines with hostnames set to the name os other machines. But here we hope that
+      # the user is not messing that much ;)
+      if [ ! -z "$hostname" ] && [ -e "$image_base/$hostname/box.img" ]; then
+        image="$image_base/$hostname/box.img"
+      else
+        image="$image_base/$VM/box.img"
+      fi
     fi
 
     # Box and folder config
index 16349c04cc9f6f0a495497d1312fa66d5d76a6ea..36d3795f9516d8948c1f1bf79cc4eb1cdd308c09 100755 (executable)
@@ -119,7 +119,7 @@ function kvmx_config {
     image="$image_base/$hostname/box.img"
   else
     image_base="$HOME/.local/share/kvmx"
-    kvmx_user_config image             $image_base/debian/box.img       "Destination image (ending in .img)"
+    kvmx_user_config image             $image_base/$hostname/box.img    "Destination image (ending in .img)"
   fi
 
   kvmx_user_config   size              3G                               "Image size"