mail_wrap_script.sh: add --always-send flag
This commit is contained in:
parent
fd57e42957
commit
bb8cf9ffa8
@ -3,14 +3,25 @@
|
|||||||
# Default values
|
# Default values
|
||||||
IGNORE_EXIST_CODE=0
|
IGNORE_EXIST_CODE=0
|
||||||
SCRIPT="-1"
|
SCRIPT="-1"
|
||||||
|
ALWAYS_SEND=0
|
||||||
|
|
||||||
# Get arguments
|
# Get arguments
|
||||||
while [ $# -gt 1 ]; do
|
while [ $# -gt 1 ]; do
|
||||||
|
# single ARG
|
||||||
ARG_NAME=$1
|
ARG_NAME=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
case $ARG_NAME in
|
||||||
|
--always-send)
|
||||||
|
ALWAYS_SEND=1
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# ARG + VALUE
|
||||||
ARG_VALUE=$1
|
ARG_VALUE=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
case $ARG_NAME in
|
case $ARG_NAME in
|
||||||
--ignore-exit-code)
|
--ignore-exit-code)
|
||||||
IGNORE_EXIT_CODE=$ARG_VALUE
|
IGNORE_EXIT_CODE=$ARG_VALUE
|
||||||
@ -43,7 +54,7 @@ OUTPUT=$(cat /tmp/$FILE_ID.log)
|
|||||||
rm /tmp/$FILE_ID.log
|
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 [ $ALWAYS_SEND -ne 0 ] || [ $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 "$(hostname) $SCRIPT failure"
|
||||||
echo "Sent"
|
echo "Sent"
|
||||||
|
Loading…
Reference in New Issue
Block a user