summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Paillard <spaillard@debian.org>2013-04-29 23:52:14 +0200
committerSimon Paillard <spaillard@debian.org>2013-05-01 01:23:16 +0200
commita37134881c4192415fd13c2981393eed3bf393ad (patch)
tree65e94a6f14926ce23cd37e8c5e6cd27c13726645
parent9ddbe78f2723ae6766d0f13d6941fb2c3a22609d (diff)
Move reusable code to function rsync_protocol
-rwxr-xr-xbin/ftpsync14
-rw-r--r--etc/common9
2 files changed, 13 insertions, 10 deletions
diff --git a/bin/ftpsync b/bin/ftpsync
index 23d7eb0..db8ad55 100755
--- a/bin/ftpsync
+++ b/bin/ftpsync
@@ -290,21 +290,15 @@ RSYNC=${RSYNC:-rsync}
RSYNC_FILTER=${RSYNC_FILTER:-"--filter=protect_Archive-Update-in-Progress-${MIRRORNAME} --filter=protect_${TRACE} --filter=protect_Archive-Update-Required-${MIRRORNAME}"}
# limit I/O bandwidth. Value is KBytes per second, unset or 0 is unlimited
RSYNC_BW=${RSYNC_BW:-0}
+RSYNC_PROTOCOL=$(rsync_protocol)
# Set the delete method to --delete-delay if protocol version is 30 or
# greater (meaning rsync 3.0.0 or greater is used). Use --delete-after
# otherwise.
-RSYNC_DELETE_METHOD=${RSYNC_DELETE_METHOD:-auto}
-if [ "xautox" = "x${RSYNC_DELETE_METHOD}x" ]; then
+if [ 30 -le $RSYNC_PROTOCOL ]; then
+ RSYNC_DELETE_METHOD=delay
+else
RSYNC_DELETE_METHOD=after
-
- RSYNC_VERSION="$(${RSYNC} --version)"
- if [[ $RSYNC_VERSION =~ (protocol[ ]+version[ ]+([0-9]+)) ]]; then
- if [ 30 -le ${BASH_REMATCH[2]} ]; then
- RSYNC_DELETE_METHOD=delay
- fi
- fi
- unset RSYNC_VERSION
fi
# Default rsync options for *every* rsync call
diff --git a/etc/common b/etc/common
index 0501240..de3cfac 100644
--- a/etc/common
+++ b/etc/common
@@ -232,3 +232,12 @@ savelog() {
done
mv "${torotate}" "${torotate}.0"
}
+
+# Return rsync version
+rsync_protocol() {
+ RSYNC_VERSION="$(${RSYNC} --version)"
+ if [[ $RSYNC_VERSION =~ (protocol[ ]+version[ ]+([0-9]+)) ]]; then
+ echo ${BASH_REMATCH[2]}
+ fi
+ unset RSYNC_VERSION
+}