summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorStephen Gran <steve@lobefin.net>2008-10-20 21:56:27 +0100
committerJoerg Jaspert <joerg@debian.org>2008-10-20 23:04:00 +0200
commit505b17640c5b1acd6515c0daf4a24cd4e955d9a3 (patch)
tree6cd4d7d0827fe6ee50c37e3cca6d6fd806288989 /bin
parentd6a1d1c306889262b7d74532ae0658e4f0e046fd (diff)
Reuse some code, and change to case statement Signed-off-by: Stephen Gran <steve@lobefin.net>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ftpsync30
1 files changed, 20 insertions, 10 deletions
diff --git a/bin/ftpsync b/bin/ftpsync
index bcca3d9..b5a174a 100755
--- a/bin/ftpsync
+++ b/bin/ftpsync
@@ -111,6 +111,24 @@ cleanup() {
rm -f "${LOCK}";
}
+check_rsync() {
+
+ ret=$1
+ msg=$2
+
+ # 24 - vanished source files. Ignored, that should be the target of $UPDATEREQUIRED
+ # and us re-running. If it's not, uplink is broken anyways.
+
+ case "$1" in
+ 0) return 0;;
+ 24) return 0;;
+ *)
+ error "ERROR: $msg"
+ return 1
+ ;;
+ esac
+}
+
########################################################################
########################################################################
@@ -335,12 +353,7 @@ while [ -e "${UPDATEREQUIRED}" ]; do
result=0
fi # Sync stage 1?
- # 24 - vanished source files. Ignored, that should be the target of $UPDATEREQUIRED
- # and us re-running. If it's not, uplink is broken anyways.
- if [ $result -ne 0 ] && [ $result -ne 24 ]; then
- error "ERROR: Sync step 1 went wrong, got errorcode ${result}. Logfile: ${LOG}. Aborting"
- exit 3
- fi
+ check_rsync $result "Sync step 1 went wrong, got errorcode ${result}. Logfile: ${LOG}" || exit 3
HOOK=(
HOOKNR=2
@@ -364,10 +377,7 @@ while [ -e "${UPDATEREQUIRED}" ]; do
result=0
fi # Sync stage 2?
- if [ $result -ne 0 ] && [ $result -ne 24 ]; then
- error "ERROR: Sync step 2 went wrong, got errorcode ${result}. Logfile: ${LOG}"
- exit 4
- fi
+ check_rsync $result "Sync step 2 went wrong, got errorcode ${result}. Logfile: ${LOG}" || exit 4
HOOK=(
HOOKNR=3