... |
... |
@@ -78,7 +78,7 @@ TEMPFILES=${TEMPFILES:-""} |
78
|
78
|
TMPFILES=${TMPFILES:-""}
|
79
|
79
|
|
80
|
80
|
# Timestamp. Used for dinstall stat graphs
|
81
|
|
-function ts() {
|
|
81
|
+function log_timestamp() {
|
82
|
82
|
echo "Archive maintenance timestamp ($1): $(date +%H:%M:%S)"
|
83
|
83
|
}
|
84
|
84
|
|
... |
... |
@@ -457,12 +457,6 @@ function stage() { |
457
|
457
|
# to be elsewhere, it has to cd first!
|
458
|
458
|
cd ${configdir}
|
459
|
459
|
|
460
|
|
- # Now redirect the output into $STAGEFILE.log. In case it errors
|
461
|
|
- # out somewhere our errorhandler trap can then mail the contents
|
462
|
|
- # of $STAGEFILE.log only, instead of a whole ${PROGRAM} logfile.
|
463
|
|
- # Short error mails ftw!
|
464
|
|
- exec >> "${STAGEFILE}.log" 2>&1
|
465
|
|
-
|
466
|
460
|
if [[ -f ${LOCK_STOP} ]]; then
|
467
|
461
|
log "${LOCK_STOP} exists, exiting immediately"
|
468
|
462
|
exit 42
|
... |
... |
@@ -472,7 +466,16 @@ function stage() { |
472
|
466
|
if [[ ${error} == false ]]; then
|
473
|
467
|
set +e
|
474
|
468
|
fi
|
475
|
|
- ${FUNC} ${ARGS}
|
|
469
|
+
|
|
470
|
+ # Now redirect the output into $STAGEFILE.log. In case it errors
|
|
471
|
+ # out somewhere our errorhandler trap can then mail the contents
|
|
472
|
+ # of $STAGEFILE.log only, instead of a whole ${PROGRAM} logfile.
|
|
473
|
+ # Short error mails ftw!
|
|
474
|
+ if [[ ${TIMESTAMP} == true ]]; then
|
|
475
|
+ ${FUNC} ${ARGS} 2>&1 | tee -a "${STAGEFILE}.log" | ts "%b %d %H:%M:%S ${HOSTNAME} ${PROGRAM}[$$]: ${FUNC} "
|
|
476
|
+ else
|
|
477
|
+ ${FUNC} ${ARGS} 2>&1 | tee -a "${STAGEFILE}.log"
|
|
478
|
+ fi
|
476
|
479
|
|
477
|
480
|
# No matter what happened in the function, we make sure we have
|
478
|
481
|
# set -e default state back
|
... |
... |
@@ -488,19 +491,9 @@ function stage() { |
488
|
491
|
touch "${STAGEFILE}"
|
489
|
492
|
|
490
|
493
|
if [[ -n ${TIME} ]]; then
|
491
|
|
- ts "${TIME}"
|
|
494
|
+ log_timestamp "${TIME}"
|
492
|
495
|
fi
|
493
|
496
|
|
494
|
|
- # And the output goes back to the normal logfile
|
495
|
|
- exec >> "${LOGFILE}" 2>&1
|
496
|
|
-
|
497
|
|
- # Now we should make sure that we have a usable ${PROGRAM}.log, so
|
498
|
|
- # append the $STAGEFILE.log to it.
|
499
|
|
- if [[ ${TIMESTAMP} == true ]]; then
|
500
|
|
- /usr/bin/ts "%b %d %H:%M:%S ${HOSTNAME} ${PROGRAM}[$$]: ${FUNC} " < "${STAGEFILE}.log"
|
501
|
|
- else
|
502
|
|
- cat "${STAGEFILE}.log"
|
503
|
|
- fi
|
504
|
497
|
rm -f "${STAGEFILE}.log"
|
505
|
498
|
|
506
|
499
|
log "########## ${PROGRAM} END: ${FUNC} ##########"
|