aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkvmx21
1 files changed, 18 insertions, 3 deletions
diff --git a/kvmx b/kvmx
index 3055595..d706669 100755
--- a/kvmx
+++ b/kvmx
@@ -61,6 +61,15 @@ function __kvmx_ssh_command {
SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=FATAL -o ProxyCommand=none -i $1"
}
+# Create a guest entry at the global user config folder
+function __kvmx_create_config_entry {
+ if [ -z "$FOLDER" ]; then
+ return 1
+ fi
+
+ ( cd $GLOBAL_USER_CONFIG_FOLDER && ln -s $FOLDER/kvmxfile $VM )
+}
+
# Initialize
function __kvmx_initialize {
__kvmx_set_app_base
@@ -91,8 +100,14 @@ function __kvmx_initialize {
# Load and check guest config
if [ "$ACTION" != "init" ] && [ "$ACTION" != "list" ] && [ "$ACTION" != "ls" ] && [ "$ACTION" != "edit" ] && [ "$ACTION" != "usage" ]; then
if [ ! -e "$GLOBAL_USER_CONFIG_FOLDER/$VM" ]; then
- echo "$BASENAME: config not found: $GLOBAL_USER_CONFIG_FOLDER/$VM"
- exit 1
+ if [ -e "kvmxfile" ]; then
+ # Existing kvmxfile but not registered at the global user config
+ FOLDER="$(pwd)"
+ __kvmx_create_config_entry
+ else
+ echo "$BASENAME: config not found: $GLOBAL_USER_CONFIG_FOLDER/$VM"
+ exit 1
+ fi
else
source $GLOBAL_USER_CONFIG_FOLDER/$VM
fi
@@ -531,7 +546,7 @@ function kvmx_init {
fi
# Create config entry
- ( cd $GLOBAL_USER_CONFIG_FOLDER && ln -s $FOLDER/kvmxfile $VM )
+ __kvmx_create_config_entry
}
# Clone a guest