From e66c84f346b34916a9ac65d263c9951c5c36b918 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 30 Mar 2017 16:48:02 -0300 Subject: Register a new guest on kvmx up for existing kvmxfile --- kvmx | 21 ++++++++++++++++++--- 1 file 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 -- cgit v1.2.3