check rsync scp

This commit is contained in:
anki-code 2020-02-12 22:10:48 +03:00
parent 383f3913a0
commit 46aea5891f
2 changed files with 8 additions and 1 deletions

View file

@ -11,3 +11,6 @@ fi
echo xxh_home_realpath=$xxh_home_realpath
echo xxh_version=$xxh_version
echo bash=`command -v bash`
echo rsync=`command -v rsync`
echo scp=`command -v scp`

6
xxh
View file

@ -166,6 +166,10 @@ if host_info['xxh_version'] == '':
print(f'Unknown answer from host when getting version for directory {host_xxh_home}')
exit(1)
if host_info['scp'] == '' and host_info['rsync'] == '':
print(f"There are no rsync or scp on target host. Sad but files can't be uploaded.")
exit(1)
host_xxh_home = host_info['xxh_home_realpath']
host_xonsh_bin = os.path.join(host_xxh_home, xonsh_bin)
host_xonshrc = os.path.join(host_xxh_home, 'xonshrc.xsh')
@ -242,7 +246,7 @@ if opt.install:
rsync -e @(f"ssh {' '.join(ssh_arguments)}") -az --info=progress2 --include ".*" @(local_xxh_home_path)/ @(host):@(host_xxh_home)/
rsync -e @(f"ssh {' '.join(ssh_arguments)}") -az --info=progress2 --include ".*" @(package_dir_path)/ @(host):@(host_xxh_home)/
elif which('scp'):
print("Upload using scp. To increase speed install rsync!")
print("Upload using scp. Note: install rsync on local and remote host to increase speed.")
scp_host = f"{host}:{host_xxh_home}/"
scp @(ssh_arguments) -r -C @([] if opt.verbose else ['-q']) @(local_xxh_home_path)/* @(scp_host)
scp @(ssh_arguments) -r -C @([] if opt.verbose else ['-q']) @(package_dir_path)/* @(scp_host)