diff options
Diffstat (limited to 'kvmx')
-rwxr-xr-x | kvmx | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -27,8 +27,8 @@ VM="$2" GLOBAL_USER_CONFIG_FOLDER="$HOME/.config/kvmx" GLOBAL_USER_CONFIG_FILE="$HOME/.config/kvmxconfig" -# Set application base -function __kvmx_set_app_base { +# Get the application base +function kvmx_app_base { local dest local base @@ -47,13 +47,15 @@ function __kvmx_set_app_base { # Deal with relative or absolute links if [ "`basename $dest`" == "$dest" ]; then - export APP_BASE="$base" + APP_BASE="$base" else - export APP_BASE="$dest" + APP_BASE="$dest" fi else - export APP_BASE="`dirname $0`" + APP_BASE="`dirname $0`" fi + + echo $APP_BASE } # Build a SSH command @@ -72,11 +74,18 @@ function __kvmx_create_config_entry { # Initialize function __kvmx_initialize { - __kvmx_set_app_base + if [ "$ACTION" == "app_base" ]; then + return + fi + + # Load basic functions + export APP_BASE="`$DIRNAME/kvmx app_base`" + source $APP_BASE/lib/kvmx/functions || exit 1 # Alias to be used in config files KVMX_BASE="$APP_BASE" + # Stop processing here for some actions if [ "$ACTION" == "init" ] || [ "$ACTION" == "list" ]; then return fi @@ -98,7 +107,7 @@ function __kvmx_initialize { fi # Load and check guest config - if [ "$ACTION" != "init" ] && [ "$ACTION" != "list" ] && [ "$ACTION" != "ls" ] && [ "$ACTION" != "edit" ] && [ "$ACTION" != "usage" ]; then + if [ "$ACTION" != "ls" ] && [ "$ACTION" != "edit" ] && [ "$ACTION" != "usage" ]; then if [ ! -e "$GLOBAL_USER_CONFIG_FOLDER/$VM" ]; then if [ -e "kvmxfile" ]; then # Existing kvmxfile but not registered at the global user config @@ -720,7 +729,7 @@ function kvmx_rotate_sshkeys { # Generate new keypair mkdir -p "$STORAGE/ssh" SSHKEY="$STORAGE/ssh/$VM.key" - $DIRNAME/kvmx-keygen $SSHKEY.new "$user@`basename $image .img`" + __kvmx_ssh_keygen $SSHKEY.new "$user@`basename $image .img`" # Replace pubkey on server echo "touch ~/.ssh/authorized_keys.new && chmod 600 ~/.ssh/authorized_keys.new" | kvmx_ssh |