diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-09-22 07:57:49 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-09-22 07:57:49 -0300 |
commit | 08f894b655dc38dc0427119d5d2ec863d9566917 (patch) | |
tree | 518b82f454a111806d310c6a5d2afb21ffd10229 | |
parent | de275dd604bb2431e0e31955851885c30261dc2d (diff) | |
download | kvmx-08f894b655dc38dc0427119d5d2ec863d9566917.tar.gz kvmx-08f894b655dc38dc0427119d5d2ec863d9566917.tar.bz2 |
Replace kvmx_rsync with kvmx_rsync_from and kvmx_rsync_to
-rwxr-xr-x | kvmx | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -609,7 +609,7 @@ function kvmx_reboot { } # Rsync files to the guest -function kvmx_rsync { +function kvmx_rsync_to { if ! kvmx_running; then echo "$BASENAME: guest $VM is not running" exit 1 @@ -617,8 +617,33 @@ function kvmx_rsync { ORIG="$3" DEST="$4" + + # Fix ~/ path + if echo $DEST | grep -q -e "^$HOME"; then + DEST="$(echo $DEST | sed -e "s|^$HOME|/home/$SSH_LOGIN|")" + fi + + SSH="`cat $SSHFILE`" + rsync -av --delete -e "$SSH_COMMAND -o Port=$SSH" --rsync-path "sudo rsync" $ORIG/ 127.0.0.1:$DEST/ +} + +# Rsync files to the guest +function kvmx_rsync_from { + if ! kvmx_running; then + echo "$BASENAME: guest $VM is not running" + exit 1 + fi + + ORIG="$3" + DEST="$4" + + # Fix ~/ path + if echo $ORIG | grep -q -e "^$HOME"; then + ORIG="$(echo $ORIG | sed -e "s|^$HOME|/home/$SSH_LOGIN|")" + fi + SSH="`cat $SSHFILE`" - rsync -av -e "$SSH_COMMAND -o Port=$SSH" --rsync-path "sudo rsync" $ORIG/ 127.0.0.1:$DEST/ + rsync -av --delete -e "$SSH_COMMAND -o Port=$SSH" --rsync-path "sudo rsync" 127.0.0.1:$ORIG/ $DEST/ } # Copy files from the guest @@ -881,7 +906,7 @@ function kvmx_provision { DEST="/usr/local/share/kvmx/provision/" echo "sudo mkdir -p `dirname $DEST`" | kvmx_ssh - rsync -av -e "$SSH_COMMAND -o Port=$SSH" $provision_rsync_opts --rsync-path "sudo rsync" $ORIG/ 127.0.0.1:$DEST/ + rsync -av --delete -e "$SSH_COMMAND -o Port=$SSH" $provision_rsync_opts --rsync-path "sudo rsync" $ORIG/ 127.0.0.1:$DEST/ if [ ! -z "$provision_rsync" ]; then ORIG="`echo $provision_rsync | cut -d ' ' -f 1`" |