From d1fa151025d6284c557f1e92bfb94a6f94f225f1 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Tue, 18 Aug 2015 11:22:05 +0200 Subject: [PATCH] backup-script-wrapper: Show non-zero exit code in mail subject --- bin/backup-script-wrapper | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/backup-script-wrapper b/bin/backup-script-wrapper index 482609f..8d160e4 100755 --- a/bin/backup-script-wrapper +++ b/bin/backup-script-wrapper @@ -25,6 +25,7 @@ HOST=`hostname -f` TMP=`mktemp /tmp/$NAME.XXXXXXXX` || exit 1 LOGFILE="/var/log/backup-script.log" DELIMITER="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +SUBJECT="$NAME results" PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" export PATH @@ -47,7 +48,14 @@ else echo "(Can't write logfile: \"$LOGFILE\"!)" fi -cat "$TMP" | mail -s "$HOST: $NAME results" "$MAILTO" +case "$r" in + 0) + ;; + *) + SUBJECT="$SUBJECT - with ERRORS!" +esac + +cat "$TMP" | mail -s "$HOST: $SUBJECT" "$MAILTO" rm -f "$TMP" exit $r -- 2.39.2