mail_wrap_script.sh: don't put failure in subject when it is not a failure

This commit is contained in:
Alice Gaudon 2021-01-08 15:04:39 +01:00
parent bc90f87636
commit e32c555f59
1 changed files with 5 additions and 1 deletions

View File

@ -54,9 +54,13 @@ OUTPUT=$(cat /tmp/$FILE_ID.log)
rm /tmp/$FILE_ID.log
# Send mail in case of error
if [ $ALWAYS_SEND -ne 0 ] || [ $ERR -ne 0 ] && [ "$ERR" != "$IGNORE_EXIT_CODE" ]; then
if [ $ERR -ne 0 ] && [ "$ERR" != "$IGNORE_EXIT_CODE" ]; then
echo "Sending error mail"
echo -e "An error occured during the execution of $SCRIPT ($ERR).\n\n\n$(ps $PPID)\n\n$OUTPUT" | $(dirname $0)/mail.sh "$(hostname) $SCRIPT failure"
echo "Sent"
exit 1
elif [ $ALWAYS_SEND -ne 0 ]; then
echo "Sending log mail"
echo -e "Logging execution of $SCRIPT ($ERR).\n\n\n$(ps $PPID)\n\n$OUTPUT" | $(dirname $0)/mail.sh "$(hostname) $SCRIPT log"
echo "Sent"
fi