aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkvmx15
1 files changed, 13 insertions, 2 deletions
diff --git a/kvmx b/kvmx
index 7329b8c..0a0d1c5 100755
--- a/kvmx
+++ b/kvmx
@@ -141,6 +141,11 @@ function __kvmx_initialize {
fi
fi
+ if [ ! -h "$GLOBAL_USER_CONFIG_FOLDER/$VM" ]; then
+ echo "error: $GLOBAL_USER_CONFIG_FOLDER/$VM is not a symlink"
+ exit 1
+ fi
+
# Box and folder config
KVMXFILE="`readlink $GLOBAL_USER_CONFIG_FOLDER/$VM`"
KVMX_PROJECT_FOLDER="`dirname $KVMXFILE`"
@@ -653,8 +658,14 @@ 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
+ sed -i -e "s|image=\"$image\"|image=\"$new_image\"|g" $FOLDER/kvmxfile
+ sed -i -e "s|hostname=\"$VM\"|hostname=\"$DEST\"|g" $FOLDER/kvmxfile
+
+ # Rename keypair if exists
+ if [ -e "$FOLDER/ssh/$VM.key" ]; then
+ mv $FOLDER/ssh/$VM.key $FOLDER/ssh/$DEST.key
+ mv $FOLDER/ssh/$VM.key.pub $FOLDER/ssh/$DEST.key.pub
+ fi
}
# Edit guest config