mail_wrap_script.sh: improve handling of too long mail body
This commit is contained in:
parent
e7769419b1
commit
8164888ad9
@ -56,11 +56,25 @@ rm /tmp/$FILE_ID.log
|
|||||||
# Send mail in case of error
|
# Send mail in case of error
|
||||||
if [ $ERR -ne 0 ] && [ "$ERR" != "$IGNORE_EXIT_CODE" ]; then
|
if [ $ERR -ne 0 ] && [ "$ERR" != "$IGNORE_EXIT_CODE" ]; then
|
||||||
echo "Sending error mail"
|
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 -e "An error occured during the execution of $SCRIPT ($ERR).\n\n\n$(ps $PPID)\n\n$OUTPUT" | $(dirname $0)/mail.sh "[E] $(hostname) $SCRIPT"
|
||||||
echo "Sent"
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Sent"
|
||||||
|
else
|
||||||
|
echo "Could not send mail, sending safe-body mail..."
|
||||||
|
echo -e "An error occured during the execution of $SCRIPT ($ERR).\n\n\n$(ps $PPID)\n\n(Could not send full output, see dead.letter)" | $(dirname $0)/mail.sh "[E+M] $(hostname) $SCRIPT"
|
||||||
|
echo "Sent"
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
elif [ $ALWAYS_SEND -ne 0 ]; then
|
elif [ $ALWAYS_SEND -ne 0 ]; then
|
||||||
echo "Sending log mail"
|
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 -e "Logging execution of $SCRIPT ($ERR).\n\n\n$(ps $PPID)\n\n$OUTPUT" | $(dirname $0)/mail.sh "[I] $(hostname) $SCRIPT"
|
||||||
echo "Sent"
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Sent"
|
||||||
|
else
|
||||||
|
echo "Could not send mail, sending safe-body mail..."
|
||||||
|
echo -e "Logging execution of $SCRIPT ($ERR).\n\n\n$(ps $PPID)\n\n(Could not send full output, see dead.letter)" | $(dirname $0)/mail.sh "[I/M] $(hostname) $SCRIPT"
|
||||||
|
echo "Sent"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user