aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-03-09 22:52:49 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-03-09 22:52:49 -0300
commitfa8b1d95d85350e76b2a1f07953b5801b9eeadba (patch)
tree43b1300ab1df867c8d61fee7505306eaa7e91a01
parent3924a146c54ebe0ca19ef1aaace05ebf043738bc (diff)
downloadkvmx-fa8b1d95d85350e76b2a1f07953b5801b9eeadba.tar.gz
kvmx-fa8b1d95d85350e76b2a1f07953b5801b9eeadba.tar.bz2
Fine tuning
-rw-r--r--README.md2
-rwxr-xr-xkvmx36
2 files changed, 19 insertions, 19 deletions
diff --git a/README.md b/README.md
index a64544d..2f53583 100644
--- 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 38ddfba..0ac2776 100755
--- 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