summaryrefslogtreecommitdiff
path: root/bin/ftpsync
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ftpsync')
-rwxr-xr-xbin/ftpsync61
1 files changed, 52 insertions, 9 deletions
diff --git a/bin/ftpsync b/bin/ftpsync
index db8ad55..2c41702 100755
--- a/bin/ftpsync
+++ b/bin/ftpsync
@@ -268,6 +268,10 @@ LOGROTATE=${LOGROTATE:-14}
LOCK=${LOCK:-"${TO}/Archive-Update-in-Progress-${MIRRORNAME}"}
# timeout for the lockfile, in case we have bash older than v4 (and no /proc)
LOCKTIMEOUT=${LOCKTIMEOUT:-3600}
+# sleeping time when an AUIP file is found but is not ours
+UIPSLEEP=${UIPSLEEP:-1200}
+# retries whenever an upstream (or possibly stale) AUIP file is found
+UIPRETRIES=${UIPRETRIES:-3}
# Do we need another rsync run?
UPDATEREQUIRED="${TO}/Archive-Update-Required-${MIRRORNAME}"
# Trace file for mirror stats and checks (make sure we get full hostname)
@@ -475,6 +479,8 @@ fi
export RSYNC_PASSWORD
export RSYNC_PROXY
+UPDATE_RETRIES=0
+
while [ -e "${UPDATEREQUIRED}" ]; do
log "Running mirrorsync, update is required, ${UPDATEREQUIRED} exists"
@@ -517,17 +523,54 @@ while [ -e "${UPDATEREQUIRED}" ]; do
# if we want stage2 *or* all
if [ "xtruex" = "x${SYNCSTAGE2}x" ] || [ "xtruex" = "x${SYNCALL}x" ]; then
- log "Running stage2: ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} ${RSYNCPTH}::${RSYNC_PATH} ${TO}"
+ upstream_uip=false
+ for aupfile in "${TO}/Archive-Update-in-Progress-"*; do
+ case "$aupfile" in
+ "${TO}/Archive-Update-in-Progress-*")
+ error "Lock file is missing, this should not happen"
+ ;;
+ "${LOCK}")
+ :
+ ;;
+ *)
+ if [ -f "$aupfile" ]; then
+ # Remove the file, it will be synced again if
+ # upstream is still not done
+ rm -f "$aupfile"
+ else
+ log "AUIP file '$aupfile' is not really a file, weird"
+ fi
+ upstream_uip=true
+ ;;
+ esac
+ done
+
+ if [ "xtruex" = "x${upstream_uip}x" ]; then
+ log "Upstream archive update in progress, skipping stage2"
+ if [ ${UPDATE_RETRIES} -lt ${UIPRETRIES} ]; then
+ log "Retrying update in ${UIPSLEEP}"
+ touch "${UPDATEREQUIRED}"
+ UPDATE_RETRIES=$(($UPDATE_RETRIES+1))
+ sleep "${UIPSLEEP}"
+ result=0
+ else
+ error "Update has been retried ${UPDATEREQUIRED} times, aborting"
+ log "Perhaps upstream is still updating or there's a stale AUIP file"
+ result=1
+ fi
+ else
+ log "Running stage2: ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} ${RSYNCPTH}::${RSYNC_PATH} ${TO}"
- set +e
- # We are lucky, it worked. Now do step 2 and sync again, this time including
- # the packages/releases files
- ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} \
- ${RSYNCPTH}::${RSYNC_PATH} "${TO}" >>"${LOGDIR}/rsync-${NAME}.log" 2>>"${LOGDIR}/rsync-${NAME}.error"
- result=$?
- set -e
+ set +e
+ # We are lucky, it worked. Now do step 2 and sync again, this time including
+ # the packages/releases files
+ ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS2} ${EXCLUDE} ${SOURCE_EXCLUDE} \
+ ${RSYNCPTH}::${RSYNC_PATH} "${TO}" >>"${LOGDIR}/rsync-${NAME}.log" 2>>"${LOGDIR}/rsync-${NAME}.error"
+ result=$?
+ set -e
- log "Back from rsync with returncode ${result}"
+ log "Back from rsync with returncode ${result}"
+ fi
else
# Fake a good resultcode
result=0