diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ftpsync | 16 | ||||
-rwxr-xr-x | bin/runmirrors | 52 |
2 files changed, 34 insertions, 34 deletions
diff --git a/bin/ftpsync b/bin/ftpsync index b5a174a..ebd527d 100755 --- a/bin/ftpsync +++ b/bin/ftpsync @@ -111,6 +111,7 @@ cleanup() { rm -f "${LOCK}"; } +# Check rsyncs return value check_rsync() { ret=$1 @@ -118,14 +119,13 @@ check_rsync() { # 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 + case "${ret}" in 0) return 0;; 24) return 0;; *) - error "ERROR: $msg" - return 1 - ;; + error "ERROR: ${msg}" + return 1 + ;; esac } @@ -248,7 +248,7 @@ CALLBACKUSER=${CALLBACKUSER:-"archvsync"} CALLBACKHOST=${CALLBACKHOST:-"none"} CALLBACKKEY=${CALLBACKKEY:-"none"} -# General excludes. Dont list architecture specific stuff here, use ARCH_EXCLUDE for that! +# General excludes. Don't list architecture specific stuff here, use ARCH_EXCLUDE for that! EXCLUDE=${EXCLUDE:-""} # The temp directory used by rsync --delay-updates is not @@ -342,10 +342,12 @@ while [ -e "${UPDATEREQUIRED}" ]; do if [ "xtruex" = "x${SYNCSTAGE1}x"] || [ "xtruex" = "x${SYNCALL}x"]; then log "Running stage1: ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS1} ${EXCLUDE} ${SOURCE_EXCLUDE} ${RSYNCPTH}::${RSYNC_PATH} ${TO}" + set +e # Step one, sync everything except Packages/Releases ${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS1} ${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}" else @@ -365,11 +367,13 @@ while [ -e "${UPDATEREQUIRED}" ]; do 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}" + 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}" else diff --git a/bin/runmirrors b/bin/runmirrors index d9e7bf1..8ce2919 100755 --- a/bin/runmirrors +++ b/bin/runmirrors @@ -34,13 +34,13 @@ if [ -n "$1" ]; then fi # Read our config file -. ${BASEDIR}/etc/${NAME}.conf +. "${BASEDIR}/etc/${NAME}.conf" # Make sure some variables are always in the environment export HOME LOGNAME USER PATH BASEDIR # Source our common functions -. ${BASEDIR}/etc/common +. "${BASEDIR}/etc/common" # Set sane defaults if the configfile didn't do that for us. # The directory for our logfiles @@ -51,8 +51,6 @@ LOG=${LOG:-"${LOGDIR}/${NAME}.log"} LOCKDIR=${LOCKDIR:-"${BASEDIR}/locks"} # How to rotate the log SAVELOG=${SAVELOG:-"savelog -t -c 14"} -# Amount of delay between mirrors if the mirror file contains a DELAY -DELAY=${DELAY:-"60"} # Our mirrorfile MIRRORS=${MIRRORS:-"${BASEDIR}/etc/${NAME}.mirror"} # used by log() @@ -65,19 +63,18 @@ cd ${BASEDIR} umask 022 # Make sure we have our log and lock directories -mkdir -p ${LOGDIR} -mkdir -p ${LOCKDIR} +mkdir -p "${LOGDIR}" +mkdir -p "${LOCKDIR}" trap 'log "Mirrorpush done" >> ${LOG}; ${SAVELOG} "${LOG}" > /dev/null' EXIT log "Pushing leaf mirrors" >> ${LOG} -if [ -n "${HOOK1}" ]; then - log "Running hook1: ${HOOK1}" >> ${LOG} - ${HOOK1} - result=$? - log "Back from hook1, got returncode ${result}" >> ${LOG} -fi +HOOK=( + HOOKNR=1 + HOOKSCR=${HOOK1} +) +hook $HOOK # From here on we do *NOT* want to exit on errors. We don't want to # stop pushing mirrors just because we can't reach one of them. @@ -85,19 +82,19 @@ set +e # Built up our list of 2-stage mirrors. PUSHLOCKS="" -egrep '^staged' ${MIRRORS} | +egrep '^staged' "${MIRRORS}" | while read MTYPE MLNAME MHOSTNAME MUSER MPROTO MKEYFILE; do PUSHLOCKS="${PUSHLOCKS} ${LOCKDIR}/${MLNAME}.stage1" done # Now read our mirrorfile and push the mirrors defined in there. # We use grep to easily sort out all lines having a # in front of them or are empty. -egrep -v '^[[:space:]]*(#|$)' ${MIRRORS} | +egrep -v '^[[:space:]]*(#|$)' "${MIRRORS}" | while read MTYPE MLNAME MHOSTNAME MUSER MPROTO MKEYFILE; do if [ "x${MTYPE}x" = "xDELAYx" ]; then # We should wait a bit. - log "Delay of ${DELAY} seconds requested, sleeping" >> ${LOG} - sleep ${DELAY} + log "Delay of ${MLNAME} requested, sleeping" >> "${LOG}" + sleep ${MLNAME} continue fi @@ -131,19 +128,18 @@ while read MTYPE MLNAME MHOSTNAME MUSER MPROTO MKEYFILE; do signal "${SIGNAL_OPTS}" & log "Trigger for ${MLNAME} done" >> ${LOG} - if [ -n "${HOOK2}" ]; then - log "Running hook2: ${HOOK2}" >> ${LOG} - ${HOOK1} - result=$? - log "Back from hook2, got returncode ${result}" >> ${LOG} - fi + HOOK=( + HOOKNR=2 + HOOKSCR=${HOOK2} + ) + hook $HOOK + set +e done -if [ -n "${HOOK3}" ]; then - log "Running hook3: ${HOOK3}" >> ${LOG} - ${HOOK3} - result=$? - log "Back from hook3, got returncode ${result}" >> ${LOG} -fi +HOOK=( + HOOKNR=3 + HOOKSCR=${HOOK3} +) +hook $HOOK exit 0 |