put all log created by the varios functions into files named after
their stage lockfile. At the end of the function, redirect log
back to the global LOGFILE, after their stage logfile got appended to
it.
Use the stage logfile in the ERRtrap, so whenever an error happen the
stuff that gets mailed is the short part that happens to be around the
error, not the whole long stuff the complete dinstall log happens to be.
Signed-off-by: Joerg Jaspert <joerg@debian.org>
# If we error out this one is called, *FOLLOWED* by cleanup above
function onerror() {
ERRDATE=$(date "+%Y.%m.%d-%H:%M:%S")
# If we error out this one is called, *FOLLOWED* by cleanup above
function onerror() {
ERRDATE=$(date "+%Y.%m.%d-%H:%M:%S")
- cat "$LOGFILE" | mail -s "ATTENTION ATTENTION! dinstall error at ${ERRDATE} (Be quiet, Brain, or I'll stab you with a Q-tip)" cron@ftp-master.debian.org
+ cat "${STAGEFILE}.log" | mail -s "ATTENTION ATTENTION! dinstall error at ${ERRDATE} in ${STAGEFILE} - (Be quiet, Brain, or I'll stab you with a Q-tip)" cron@ftp-master.debian.org
}
########################################################################
}
########################################################################
ARGS='GO[@]'
local "${!ARGS}"
ARGS='GO[@]'
local "${!ARGS}"
- if [ -f "${stagedir}/${FUNC}" ]; then
- stamptime=$(/usr/bin/stat -c %Z "${stagedir}/${FUNC}")
+ STAGEFILE="${stagedir}/${FUNC}"
+ if [ -f "${STAGEFILE}" ]; then
+ stamptime=$(/usr/bin/stat -c %Z "${STAGEFILE}")
unixtime=$(date +%s)
difference=$(( $unixtime - $stamptime ))
if [ ${difference} -ge 14400 ]; then
unixtime=$(date +%s)
difference=$(( $unixtime - $stamptime ))
if [ ${difference} -ge 14400 ]; then
# it has to cd first!
cd ${configdir}
# it has to cd first!
cd ${configdir}
+ # Now redirect the output into $STAGEFILE.log. In case it errors out somewhere our
+ # errorhandler trap can then mail the contents of $STAGEFILE.log only, instead of a whole
+ # dinstall logfile. Short error mails ftw!
+ exec >> "${STAGEFILE}.log" 2>&1
+
if [ -f "${LOCK_STOP}" ]; then
log "${LOCK_STOP} exists, exiting immediately"
exit 42
if [ -f "${LOCK_STOP}" ]; then
log "${LOCK_STOP} exists, exiting immediately"
exit 42
# Make sure we are always at the same place.
cd ${configdir}
# Make sure we are always at the same place.
cd ${configdir}
- touch "${stagedir}/${FUNC}"
if [ -n "${TIME}" ]; then
ts "${TIME}"
fi
if [ -n "${TIME}" ]; then
ts "${TIME}"
fi
+ # And the output goes back to the normal logfile
+ exec >> "$LOGFILE" 2>&1
+
+ # Now we should make sure that we have a usable dinstall.log, so append the $STAGEFILE.log
+ # to it.
+ cat "${STAGEFILE}.log" >> "${LOGFILE}"
+ rm -f "${STAGEFILE}.log"
+
if [ -f "${LOCK_STOP}" ]; then
log "${LOCK_STOP} exists, exiting immediately"
exit 42
if [ -f "${LOCK_STOP}" ]; then
log "${LOCK_STOP} exists, exiting immediately"
exit 42