From 53913be96b3a85986558bab16a76bb01e3f52a5e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 22 Sep 2017 10:23:22 -0300 Subject: Shorthands for rsync and scp actions --- kvmx | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/kvmx b/kvmx index 5bbaa76..d52cc8a 100755 --- a/kvmx +++ b/kvmx @@ -618,6 +618,14 @@ function kvmx_rsync_to { ORIG="$3" DEST="$4" + if [ -z "$DEST" ]; then + # Error + #exit 1 + + # Assume same as origin + DEST="$ORIG" + fi + # Fix ~/ path if echo $DEST | grep -q -e "^$HOME"; then DEST="$(echo $DEST | sed -e "s|^$HOME|/home/$SSH_LOGIN|")" @@ -637,6 +645,14 @@ function kvmx_rsync_from { ORIG="$3" DEST="$4" + if [ -z "$DEST" ]; then + # Error + #exit 1 + + # Assume same as origin + DEST="$ORIG" + fi + # Fix ~/ path if echo $ORIG | grep -q -e "^$HOME"; then ORIG="$(echo $ORIG | sed -e "s|^$HOME|/home/$SSH_LOGIN|")" @@ -655,10 +671,13 @@ function kvmx_scp_from { ORIG="$3" DEST="$4" - SSH="`cat $SSHFILE`" if [ -z "$DEST" ]; then - exit 1 + # Error + #exit 1 + + # Assume same as origin + DEST="$ORIG" fi # Fix ~/ path @@ -666,6 +685,7 @@ function kvmx_scp_from { ORIG="$(echo $ORIG | sed -e "s|^$HOME|/home/$SSH_LOGIN|")" fi + SSH="`cat $SSHFILE`" $SCP_COMMAND -o Port=$SSH 127.0.0.1:$ORIG $DEST } @@ -678,10 +698,13 @@ function kvmx_scp_to { ORIG="$3" DEST="$4" - SSH="`cat $SSHFILE`" if [ -z "$DEST" ]; then - exit 1 + # Error + #exit 1 + + # Assume same as origin + DEST="$ORIG" fi # Fix ~/ path @@ -689,6 +712,7 @@ function kvmx_scp_to { DEST="$(echo $DEST | sed -e "s|^$HOME|/home/$SSH_LOGIN|")" fi + SSH="`cat $SSHFILE`" $SCP_COMMAND -o Port=$SSH $ORIG 127.0.0.1:$DEST } -- cgit v1.2.3