diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-03-30 16:48:02 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-03-30 16:48:02 -0300 |
commit | e66c84f346b34916a9ac65d263c9951c5c36b918 (patch) | |
tree | ec0347109de6569d97cb918610c2e32936ae7a07 | |
parent | b5b32a5de70576b162efaf930b5d7237824e0433 (diff) | |
download | kvmx-e66c84f346b34916a9ac65d263c9951c5c36b918.tar.gz kvmx-e66c84f346b34916a9ac65d263c9951c5c36b918.tar.bz2 |
Register a new guest on kvmx up for existing kvmxfile
-rwxr-xr-x | kvmx | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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 |