]> arthur.barton.de Git - backup-script.git/blobdiff - bin/backup-script-wrapper
backup-script-wrapper: Show non-zero exit code in mail subject
[backup-script.git] / bin / backup-script-wrapper
index 482609fa0ea65b6b58722818ccb063c6eb0810d1..8d160e494ee09705725589401f06b7a042bb19e5 100755 (executable)
@@ -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