]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Fine tuning
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 10 Mar 2017 01:52:49 +0000 (22:52 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 10 Mar 2017 01:52:49 +0000 (22:52 -0300)
README.md
kvmx

index a64544d5bafe5c5f20ac08c0e1db88cc6bd766bb..2f53583b4022bc37fb51afbb12a863cc5d631a05 100644 (file)
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ Simply clone it and add to your `$PATH`:
 ## Basic usage
 
     kvmx init [project-name] [project-folder] # initialize
-    kvmx edit [project-name]                  # customize
+    kvmx edit [project-name]                  # optional customization
     kvmx up   [project-name]                  # bring it up!
 
 If no project name is specified, the current folder name is assumed as the project name.
diff --git a/kvmx b/kvmx
index 38ddfbac6fc2a7ff2eaa46f5a1270719857fa11e..0ac2776cabddc4724e004c165942c9fc1b57118c 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -12,19 +12,17 @@ GLOBAL_USER_CONFIG_FOLDER="$HOME/.config/kvmx"
 
 # Run spice client
 function kvmx_spice {
-  if [ "$run_spice_client" == "1" ]; then
-    # https://lists.freedesktop.org/archives/spice-devel/2013-September/014643.html
-    SPICE_NOGRAB=1 spicec --host localhost --port $PORT &
-    #spicy -h localhost -p $PORT
-    #remote-viewer spice://localhost:$PORT
+  # https://lists.freedesktop.org/archives/spice-devel/2013-September/014643.html
+  SPICE_NOGRAB=1 spicec --host localhost --port $PORT &
+  #spicy -h localhost -p $PORT
+  #remote-viewer spice://localhost:$PORT
 
-    # Give time to boot
-    sleep 5
+  # Give time to boot
+  sleep 5
 
-    # Fix window titles
-    if which /usr/bin/xdotool &> /dev/null; then
-      xdotool search --name "SPICEc:0" set_window --name $VM
-    fi
+  # Fix window titles
+  if which /usr/bin/xdotool &> /dev/null; then
+    xdotool search --name "SPICEc:0" set_window --name $VM
   fi
 }
 
@@ -79,7 +77,9 @@ function kvmx_up {
   echo $PORT > $PORTFILE
   echo $SSH  > $SSHFILE
 
-  kvmx_spice
+  if [ "$run_spice_client" == "1" ]; then
+    kvmx_spice
+  fi
 }
 
 # Display usage
@@ -255,6 +255,7 @@ function kvmx_init {
   # Copy config from template
   if [ ! -e "$FOLDER/kvmxfile" ]; then
     cp $DIRNAME/kvmxfile $FOLDER/
+    sed -i -e "s|hostname=\"machine\"|hostname=\"$VM\"|g" $FOLDER/kvmxfile
   fi
 
   # Create config entry
@@ -298,6 +299,7 @@ function kvmx_clone {
   # Update config file
   new_image="$FOLDER/`basename $image`"
   sed -i -e "s|image=\"$image\"|image=\"$new_image\"|g" $GLOBAL_USER_CONFIG_FOLDER/$DEST
+  sed -i -e "s|hostname=\"$VM\"|hostname=\"$DEST\"|g"   $GLOBAL_USER_CONFIG_FOLDER/$DEST
 }
 
 # Edit guest config
@@ -325,19 +327,17 @@ function kvmx_stop {
 function kvmx_destroy {
   kvmx_stop
 
-  #rm -f $image
-  rm -f $PIDFILE
-  rm -f $SSHFILE
-  rm -f $PORTFILE
-  rm -f $LOGFILE
+  rm -f  $image
+  rm -rf $STATE_DIR
 
-  echo "$BASENAME: please inspect and remove `dirname $image` manually."
+  echo "$BASENAME: removed image and state files, but not the whole`dirname $image` folder."
 }
 
 # Purge a guest and all its configuration
 function kvmx_purge {
   kvmx_destroy
   rm -f $GLOBAL_USER_CONFIG_FOLDER/$VM
+  echo "$BASENAME: removed $GLOBAL_USER_CONFIG_FOLDER/$VM config."
 }
 
 # Provision a machine