summaryrefslogtreecommitdiff
path: root/lib/common-functions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common-functions')
-rwxr-xr-xlib/common-functions20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/common-functions b/lib/common-functions
index b64af00..8b842ff 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -871,12 +871,6 @@ failsafe_sftp() {
trial_counter=20
trap 'rm -rf --one-file-system "${temp_dir}"' EXIT
cat > "${temp_dir}/input"
- if [ -n "${master_mirror_sftp_root}" ]; then
- sed -i '
- /^\(rm\|rename\) / s@"\([^"]\+\)"@"'"${master_mirror_sftp_root}"'/\1"@g
- /^ln / s@"\([^"]\+\)"$@"'"${master_mirror_sftp_root}"'/\1"@
- ' "${temp_dir}/input"
- fi
sed -n '
s/^rm "\([^"]\+\)"$/- \1/
s/^ln\( [^"]\S*\)* "[^"]\+" "\([^"]\+\)"$/+ \2/
@@ -885,7 +879,10 @@ failsafe_sftp() {
p
' "${temp_dir}/input" > \
"${temp_dir}/expectations"
- if ${master_mirror_sftp_command} < "${temp_dir}/input"; then
+ if sed '
+ 1 i cd "'"${master_mirror_sftp_root}"'"
+ ' "${temp_dir}/input" \
+ | ${master_mirror_sftp_command}; then
# we're done
exit 0
fi
@@ -901,13 +898,18 @@ failsafe_sftp() {
# - succeeding sftp command to create listing (e.g. all expected
# files are found)
# - no unexpected files were found
- if ${master_mirror_sftp_command} < \
- "${temp_dir}/input" && \
+ if sed '
+ 1 i cd "'"${master_mirror_sftp_root}"'"
+ ' "${temp_dir}/input" \
+ | ${master_mirror_sftp_command} && \
sed '
s/^+ \(\S\+\)$/ls -1 "\1"/
s,^- \(\S\+/\)[^/]\+$,ls -1 "\1",
' "${temp_dir}/expectations" | \
sort -u | \
+ sed '
+ 1 i cd "'"${master_mirror_sftp_root}"'"
+ ' "${temp_dir}/input" | \
${master_mirror_sftp_command} > "${temp_dir}/check" && \
! grep -qxF "$(
sed -n '