提交 0ef771ea 编写于 作者: J Joerg Jaspert

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: NJoerg Jaspert <joerg@debian.org>
上级 327a206b
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册