summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Jaspert <joerg@debian.org>2008-11-19 00:02:23 +0100
committerJoerg Jaspert <joerg@debian.org>2008-11-19 00:02:23 +0100
commitdccfc56c5a745f8a7a52fa3525b3af2ea6d0ba44 (patch)
tree74433cf2ce305c2edbafbd3a5f2c438641520a0e
parent891717e7bbb56e3400f05d32ac5d0be90ee4cacb (diff)
savelog
savelog on our own Signed-off-by: Joerg Jaspert <joerg@debian.org>
-rwxr-xr-xbin/ftpsync12
-rwxr-xr-xbin/runmirrors6
-rw-r--r--etc/common14
-rw-r--r--etc/ftpsync.conf.sample4
-rw-r--r--etc/runmirrors.conf.sample5
5 files changed, 28 insertions, 13 deletions
diff --git a/bin/ftpsync b/bin/ftpsync
index 7958ae7..878741c 100755
--- a/bin/ftpsync
+++ b/bin/ftpsync
@@ -32,7 +32,7 @@ BASEDIR=${BASEDIR:-"${HOME}"}
# Script version. DO NOT CHANGE, *unless* you change the master copy maintained
# by Joerg Jaspert and the Debian mirroradm group.
# This is used to track which mirror is using which script version.
-VERSION="23"
+VERSION="0815"
# Source our common functions
. "${BASEDIR}/etc/common"
@@ -114,9 +114,9 @@ cleanup() {
fi
fi
- ${SAVELOG} "${LOGDIR}/rsync-${NAME}.log"
- ${SAVELOG} "${LOGDIR}/rsync-${NAME}.error"
- ${SAVELOG} "$LOG" > /dev/null
+ savelog "${LOGDIR}/rsync-${NAME}.log"
+ savelog "${LOGDIR}/rsync-${NAME}.error"
+ savelog "$LOG" > /dev/null
rm -f "${LOCK}"
}
@@ -233,8 +233,8 @@ ERRORSONLY=${ERRORSONLY:-"true"}
# Want full logs, ie. including the rsync one?
FULLLOGS=${FULLLOGS:-"false"}
-# How to rotate our log
-SAVELOG=${SAVELOG:-"savelog -t -c 14"}
+# How many logfiles to keep
+LOGROTATE=${LOGROTATE:14}
# Our lockfile
LOCK=${LOCK:-"${TO}/Archive-Update-in-Progress-${MIRRORNAME}"}
diff --git a/bin/runmirrors b/bin/runmirrors
index 676bff7..5c2a6b7 100755
--- a/bin/runmirrors
+++ b/bin/runmirrors
@@ -47,8 +47,8 @@ LOGDIR=${LOGDIR:-"${BASEDIR}/log"}
LOG=${LOG:-"${LOGDIR}/${NAME}.log"}
# Our lockfile directory
LOCKDIR=${LOCKDIR:-"${BASEDIR}/locks"}
-# How to rotate the log
-SAVELOG=${SAVELOG:-"savelog -t -c 14"}
+# How many logfiles to keep
+LOGROTATE=${LOGROTATE:14}
# Our mirrorfile
MIRRORS=${MIRRORS:-"${BASEDIR}/etc/${NAME}.mirror"}
# used by log()
@@ -80,7 +80,7 @@ umask 022
mkdir -p "${LOGDIR}"
mkdir -p "${LOCKDIR}"
-trap 'log "Mirrorpush done" >> ${LOG}; ${SAVELOG} "${LOG}" > /dev/null' EXIT
+trap 'log "Mirrorpush done" >> ${LOG}; savelog "${LOG}" > /dev/null' EXIT
log "Pushing leaf mirrors" >> ${LOG}
diff --git a/etc/common b/etc/common
index 6a8d7a2..54340ee 100644
--- a/etc/common
+++ b/etc/common
@@ -158,3 +158,17 @@ get2stage() {
}
}
+# Rotate logfiles
+savelog() {
+ torotate="$1"
+ count=${2:-"${LOGROTATE}"}
+ echo "Rotation $torotate a $count times"
+ while [ ${count} -gt 0 ]; do
+ prev=$(( count - 1 ))
+ if [ -e "${torotate}.${prev}" ]; then
+ mv "${torotate}.${prev}" "${torotate}.${count}"
+ fi
+ count=$prev
+ done
+ mv "${torotate}" "${torotate}.0"
+}
diff --git a/etc/ftpsync.conf.sample b/etc/ftpsync.conf.sample
index b1e8dc8..3f597dd 100644
--- a/etc/ftpsync.conf.sample
+++ b/etc/ftpsync.conf.sample
@@ -72,8 +72,8 @@
#HUB=false
## We do create three logfiles for every run. To save space we rotate them, this
-## defines how.
-#SAVELOG="savelog -t -c 14"
+## defines how many we keep
+#LOGROTATE=14
## Our own lockfile (only one sync should run at any time)
#LOCK="${TO}/Archive-Update-in-Progress-${MIRRORNAME}"
diff --git a/etc/runmirrors.conf.sample b/etc/runmirrors.conf.sample
index c7f5788..4892728 100644
--- a/etc/runmirrors.conf.sample
+++ b/etc/runmirrors.conf.sample
@@ -18,8 +18,9 @@
## Our lockfile directory
#LOCKDIR="${BASEDIR}/locks"
-## How to rotate the log
-#SAVELOG="savelog -t -c 14"
+## We do create a logfile for every run. To save space we rotate it, this
+## defines how many we keep
+#LOGROTATE=14
## Our mirrorfile
#MIRRORS="${BASEDIR}/etc/${NAME}.mirror"