mirror of
https://github.com/flatcar/scripts.git
synced 2026-02-09 09:41:56 +01:00
remote_access: Add some helper command for copying with rsync
It's nice to be able to use rsync for copies (much faster). Add a few helper functions for doing this, handling fallback to just using tar to send. BUG=None TEST=Use in a future CL Change-Id: I74c481520fc785138875ab6d5ffdaf9935a0b6d1 Reviewed-on: https://gerrit.chromium.org/gerrit/39392 Tested-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Mandeep Singh Baines <msb@chromium.org> Commit-Ready: Doug Anderson <dianders@chromium.org>
This commit is contained in:
parent
5a21b44a37
commit
4e6783879c
@ -44,12 +44,36 @@ remote_cp_to() {
|
||||
return ${PIPESTATUS[0]}
|
||||
}
|
||||
|
||||
# Raw rsync access to the remote
|
||||
# Use like: remote_rsync_raw -a /path/from/ root@${FLAGS_remote}:/path/to/
|
||||
remote_rsync_raw() {
|
||||
rsync -e "ssh -p ${FLAGS_ssh_port} $(ssh_connect_settings) \
|
||||
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY" \
|
||||
"$@"
|
||||
}
|
||||
|
||||
# Copies a list of remote files specified in file $1 to local location
|
||||
# $2. Directory paths in $1 are collapsed into $2.
|
||||
remote_rsync_from() {
|
||||
rsync -e "ssh -p ${FLAGS_ssh_port} $(ssh_connect_settings) \
|
||||
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY" \
|
||||
--no-R --files-from=$1 root@${FLAGS_remote}:/ $2
|
||||
remote_rsync_raw --no-R --files-from="$1" root@${FLAGS_remote}:/ "$2"
|
||||
}
|
||||
|
||||
# Send a directory from $1 to $2 on remote host
|
||||
#
|
||||
# Tries to use rsync -a but will fall back to tar if the remote doesn't
|
||||
# have rsync.
|
||||
#
|
||||
# Use like: remote_send_to /build/board/lib/modules/ /lib/modules/
|
||||
remote_send_to() {
|
||||
if [ ! -d "$1" ]; then
|
||||
die "$1 must be a directory"
|
||||
fi
|
||||
|
||||
if remote_sh rsync --version >/dev/null 2>&1; then
|
||||
remote_rsync_raw -a "$1/" root@${FLAGS_remote}:"$2/"
|
||||
else
|
||||
tar -C "$1" -cz . | remote_sh tar -C "$2" -xz
|
||||
fi
|
||||
}
|
||||
|
||||
_remote_sh() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user