summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Jaspert <joerg@debian.org>2008-10-21 22:49:27 +0200
committerJoerg Jaspert <joerg@debian.org>2008-10-21 22:49:27 +0200
commit9933097c021fe61b2bb342e07405dcf55ea8f138 (patch)
tree6c5c32dde454f2f19e742369f95b74e914ed9220
parent505b17640c5b1acd6515c0daf4a24cd4e955d9a3 (diff)
ftpsync, runmirrors
small fixes and "" at some places Signed-off-by: Joerg Jaspert <joerg@debian.org>
-rwxr-xr-xbin/ftpsync16
-rwxr-xr-xbin/runmirrors52
-rw-r--r--etc/ftpsync.conf.sample2
-rw-r--r--etc/runmirrors.mirror.sample7
4 files changed, 39 insertions, 38 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
diff --git a/etc/ftpsync.conf.sample b/etc/ftpsync.conf.sample
index 21e9aa4..734a343 100644
--- a/etc/ftpsync.conf.sample
+++ b/etc/ftpsync.conf.sample
@@ -4,7 +4,7 @@ RSYNC_USER=USER
RSYNC_PASSWORD=PASSWORD
RSYNC_PATH="debian-all"
PROGRAM=ftpsync
-MAILTO="somewhere@example.com"
+MAILTO="root"
ERRORSONLY="false"
# Hook scripts can be run at various places during the sync.
# Leave them blank if you don't want any
diff --git a/etc/runmirrors.mirror.sample b/etc/runmirrors.mirror.sample
index e529376..3d31ec7 100644
--- a/etc/runmirrors.mirror.sample
+++ b/etc/runmirrors.mirror.sample
@@ -27,6 +27,7 @@
# finish stage1 before stage2 gets pushed.
#
# One special value is allowed: DELAY
-# This word has to be on a line itself, nothing else, not even
-# whitespace. It will trigger a pause of $DELAY seconds between the two
-# mirrors. Per default DELAY is set to 60.
+# This word has to be on a line itself, followed by a space and a number.
+# nothing else, not even whitespace. It will trigger a pause of $number
+# seconds between the two mirrors. If no number is given it defaults to
+# 60 seconds.