mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-09 05:56:58 +02:00
Merge pull request #161 from flatcar-linux/t-lo/add-rsync-upload
release_util.sh: add rsync:// upload
This commit is contained in:
commit
6882ea2d7c
@ -51,24 +51,27 @@ check_gsutil_opts() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${FLAGS_upload_root}" ]]; then
|
if [[ -n "${FLAGS_upload_root}" ]]; then
|
||||||
if [[ "${FLAGS_upload_root}" != gs://* ]]; then
|
if [[ "${FLAGS_upload_root}" != gs://* ]] \
|
||||||
die_notrace "--upload_root must be a gs:// URL"
|
&& [[ "${FLAGS_upload_root}" != rsync://* ]] ; then
|
||||||
|
die_notrace "--upload_root must be a gs:// or rsync:// URL"
|
||||||
fi
|
fi
|
||||||
# Make sure the path doesn't end with a slash
|
# Make sure the path doesn't end with a slash
|
||||||
UPLOAD_ROOT="${FLAGS_upload_root%%/}"
|
UPLOAD_ROOT="${FLAGS_upload_root%%/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${FLAGS_torcx_upload_root}" ]]; then
|
if [[ -n "${FLAGS_torcx_upload_root}" ]]; then
|
||||||
if [[ "${FLAGS_torcx_upload_root}" != gs://* ]]; then
|
if [[ "${FLAGS_torcx_upload_root}" != gs://* ]] \
|
||||||
die_notrace "--torcx_upload_root must be a gs:// URL"
|
&& [[ "${FLAGS_torcx_upload_root}" != rsync://* ]] ; then
|
||||||
|
die_notrace "--torcx_upload_root must be a gs:// or rsync:// URL"
|
||||||
fi
|
fi
|
||||||
# Make sure the path doesn't end with a slash
|
# Make sure the path doesn't end with a slash
|
||||||
TORCX_UPLOAD_ROOT="${FLAGS_torcx_upload_root%%/}"
|
TORCX_UPLOAD_ROOT="${FLAGS_torcx_upload_root%%/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${FLAGS_upload_path}" ]]; then
|
if [[ -n "${FLAGS_upload_path}" ]]; then
|
||||||
if [[ "${FLAGS_upload_path}" != gs://* ]]; then
|
if [[ "${FLAGS_upload_path}" != gs://* ]] \
|
||||||
die_notrace "--upload_path must be a gs:// URL"
|
&& [[ "${FLAGS_upload_path}" != rsync://* ]] ; then
|
||||||
|
die_notrace "--upload_path must be a gs:// or rsync:// URL"
|
||||||
fi
|
fi
|
||||||
# Make sure the path doesn't end with a slash
|
# Make sure the path doesn't end with a slash
|
||||||
UPLOAD_PATH="${FLAGS_upload_path%%/}"
|
UPLOAD_PATH="${FLAGS_upload_path%%/}"
|
||||||
@ -105,8 +108,27 @@ upload_files() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
info "Uploading ${msg} to ${local_upload_path}"
|
info "Uploading ${msg} to ${local_upload_path}"
|
||||||
|
|
||||||
|
if [[ "${local_upload_path}" = 'rsync://'* ]]; then
|
||||||
|
local rsync_upload_path="${local_upload_path#rsync://}"
|
||||||
|
local sshcmd="ssh -o BatchMode=yes "
|
||||||
|
sshcmd="$sshcmd -o StrictHostKeyChecking=no"
|
||||||
|
sshcmd="$sshcmd -o UserKnownHostsFile=/dev/null"
|
||||||
|
sshcmd="$sshcmd -o NumberOfPasswordPrompts=0"
|
||||||
|
|
||||||
|
# ensure the target path exists
|
||||||
|
local sshuserhost="${rsync_upload_path%:*}"
|
||||||
|
local destpath="${rsync_upload_path#*:}"
|
||||||
|
${sshcmd} "${sshuserhost}" \
|
||||||
|
"mkdir -p ${destpath}/${extra_upload_suffix}"
|
||||||
|
|
||||||
|
# now sync
|
||||||
|
rsync -Pav -e "${sshcmd}" "$@" \
|
||||||
|
"${rsync_upload_path}/${extra_upload_suffix}"
|
||||||
|
else
|
||||||
gsutil ${GSUTIL_OPTS} cp -R "$@" \
|
gsutil ${GSUTIL_OPTS} cp -R "$@" \
|
||||||
"${local_upload_path}/${extra_upload_suffix}"
|
"${local_upload_path}/${extra_upload_suffix}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user