From: Joerg Jaspert Date: Wed, 3 Jun 2009 23:09:01 +0000 (+0200) Subject: dinstall X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ef771eacbecca81d996aad0971c80378f7ce249;p=dak dinstall 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 --- diff --git a/config/debian/cron.dinstall b/config/debian/cron.dinstall index cf96d6d3..7b0e38e4 100755 --- a/config/debian/cron.dinstall +++ b/config/debian/cron.dinstall @@ -59,7 +59,7 @@ function cleanup() { # 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 } ######################################################################## @@ -446,8 +446,9 @@ function stage() { 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 @@ -464,6 +465,11 @@ function stage() { # 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 @@ -480,12 +486,20 @@ function stage() { # Make sure we are always at the same place. cd ${configdir} - touch "${stagedir}/${FUNC}" + touch "${STAGEFILE}" 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