]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Default image file on kvmx-create
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 31 Mar 2017 12:58:28 +0000 (09:58 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 31 Mar 2017 12:58:28 +0000 (09:58 -0300)
kvmx-create

index fed029232b90e614b8a4c997eb90031cb5d77a36..4ea87556e1564684be031f2828d51bf101d3dba1 100755 (executable)
@@ -21,6 +21,7 @@
 # Parameters
 BASENAME="`basename $0`"
 DIRNAME="`dirname $0`"
+GLOBAL_USER_CONFIG_FILE="$HOME/.config/kvmxconfig"
 
 # Load configuration
 function kvmx_config_load {
@@ -94,10 +95,10 @@ function kvmx_sudo_run {
 
 # Make sure there is provision config.
 function kvmx_config {
-  kvmx_user_config   image             /var/cache/qemu/debian/box.img   "Destination image (ending in .img)"
-  kvmx_user_config   size              3G                               "Image size"
-  kvmx_user_config   format            qcow2                            "Image format: raw or qcow2"
-  kvmx_user_config   method            custom                           "Bootstrap method: custom or vmdeboostrap"
+  if [ -e "$GLOBAL_USER_CONFIG_FILE" ]; then
+    source $GLOBAL_USER_CONFIG_FILE
+  fi
+
   kvmx_user_config   hostname          machine                          "Hostname"
   kvmx_user_config   domain            example.org                      "Domain"
   kvmx_user_config   arch              amd64                            "System arch"
@@ -107,6 +108,17 @@ function kvmx_config {
   kvmx_user_config   ssh_custom        y                                "Setup a custom SSH keypair (y/n)"
   kvmx_user_config   user              user                             "Initial user name"
   kvmx_user_config   password          $RANDOM                          "Initial user password"
+
+  if [ ! -z "$image_base" ]; then
+    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)"
+  fi
+
+  kvmx_user_config   size              3G                               "Image size"
+  kvmx_user_config   format            qcow2                            "Image format: raw or qcow2"
+  kvmx_user_config   method            custom                           "Bootstrap method: custom or vmdeboostrap"
 }
 
 # Load config file
@@ -244,7 +256,7 @@ function kvmx_create_custom {
   # Initial user
   kvmx_sudo_run chroot $WORK/ useradd $user -G sudo -s /bin/bash
 
-  if [ "$ssh_support" == "y" ];
+  if [ "$ssh_support" == "y" ]; then
     if [ "$ssh_custom" == "y" ]; then
       privkey="`dirname $image`/ssh/`basename $image .img`.key"
       pubkey="${privkey}.pub"