mirror of
https://github.com/deajan/obackup.git
synced 2024-12-26 15:33:41 +01:00
Fixed bogus double log alert sending
This commit is contained in:
parent
cfd76c0c4c
commit
2c55108ba6
@ -1,6 +1,6 @@
|
|||||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||||
|
|
||||||
## FUNC_BUILD=2016082601
|
## FUNC_BUILD=2016082602
|
||||||
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
||||||
|
|
||||||
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
|
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
|
||||||
@ -227,6 +227,7 @@ function SendAlert {
|
|||||||
local mail_no_attachment=
|
local mail_no_attachment=
|
||||||
local attachment_command=
|
local attachment_command=
|
||||||
local subject=
|
local subject=
|
||||||
|
local body=
|
||||||
|
|
||||||
# Windows specific settings
|
# Windows specific settings
|
||||||
local encryption_string=
|
local encryption_string=
|
||||||
@ -256,7 +257,7 @@ function SendAlert {
|
|||||||
mail_no_attachment=0
|
mail_no_attachment=0
|
||||||
fi
|
fi
|
||||||
#TODO(low): Change tail -n 50 to end of fil up to last script begin
|
#TODO(low): Change tail -n 50 to end of fil up to last script begin
|
||||||
MAIL_ALERT_MSG="$MAIL_ALERT_MSG"$'\n\n'$(tail -n 50 "$LOG_FILE")
|
body="$MAIL_ALERT_MSG"$'\n\n'$(tail -n 50 "$LOG_FILE")
|
||||||
if [ $ERROR_ALERT -eq 1 ]; then
|
if [ $ERROR_ALERT -eq 1 ]; then
|
||||||
subject="Error alert for $INSTANCE_ID"
|
subject="Error alert for $INSTANCE_ID"
|
||||||
elif [ $WARN_ALERT -eq 1 ]; then
|
elif [ $WARN_ALERT -eq 1 ]; then
|
||||||
@ -275,7 +276,7 @@ function SendAlert {
|
|||||||
attachment_command="-a $ALERT_LOG_FILE"
|
attachment_command="-a $ALERT_LOG_FILE"
|
||||||
fi
|
fi
|
||||||
if type mutt > /dev/null 2>&1 ; then
|
if type mutt > /dev/null 2>&1 ; then
|
||||||
echo "$MAIL_ALERT_MSG" | $(type -p mutt) -x -s "$subject" $DESTINATION_MAILS $attachment_command
|
echo "$body" | $(type -p mutt) -x -s "$subject" $DESTINATION_MAILS $attachment_command
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert mail via $(type -p mutt) !!!" "WARN"
|
Logger "Cannot send alert mail via $(type -p mutt) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -292,10 +293,10 @@ function SendAlert {
|
|||||||
else
|
else
|
||||||
attachment_command=""
|
attachment_command=""
|
||||||
fi
|
fi
|
||||||
echo "$MAIL_ALERT_MSG" | $(type -p mail) $attachment_command -s "$subject" $DESTINATION_MAILS
|
echo "$body" | $(type -p mail) $attachment_command -s "$subject" $DESTINATION_MAILS
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert mail via $(type -p mail) with attachments !!!" "WARN"
|
Logger "Cannot send alert mail via $(type -p mail) with attachments !!!" "WARN"
|
||||||
echo "$MAIL_ALERT_MSG" | $(type -p mail) -s "$subject" $DESTINATION_MAILS
|
echo "$body" | $(type -p mail) -s "$subject" $DESTINATION_MAILS
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert mail via $(type -p mail) without attachments !!!" "WARN"
|
Logger "Cannot send alert mail via $(type -p mail) without attachments !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -309,7 +310,7 @@ function SendAlert {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if type sendmail > /dev/null 2>&1 ; then
|
if type sendmail > /dev/null 2>&1 ; then
|
||||||
echo -e "Subject:$subject\r\n$MAIL_ALERT_MSG" | $(type -p sendmail) $DESTINATION_MAILS
|
echo -e "Subject:$subject\r\n$body" | $(type -p sendmail) $DESTINATION_MAILS
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert mail via $(type -p sendmail) !!!" "WARN"
|
Logger "Cannot send alert mail via $(type -p sendmail) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -332,7 +333,7 @@ function SendAlert {
|
|||||||
if [ "$SMTP_USER" != "" ] && [ "$SMTP_USER" != "" ]; then
|
if [ "$SMTP_USER" != "" ] && [ "$SMTP_USER" != "" ]; then
|
||||||
auth_string="-auth -user \"$SMTP_USER\" -pass \"$SMTP_PASSWORD\""
|
auth_string="-auth -user \"$SMTP_USER\" -pass \"$SMTP_PASSWORD\""
|
||||||
fi
|
fi
|
||||||
$(type mailsend.exe) -f $SENDER_MAIL -t "$DESTINATION_MAILS" -sub "$subject" -M "$MAIL_ALERT_MSG" -attach "$attachment" -smtp "$SMTP_SERVER" -port "$SMTP_PORT" $encryption_string $auth_string
|
$(type mailsend.exe) -f $SENDER_MAIL -t "$DESTINATION_MAILS" -sub "$subject" -M "$body" -attach "$attachment" -smtp "$SMTP_SERVER" -port "$SMTP_PORT" $encryption_string $auth_string
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send mail via $(type mailsend.exe) !!!" "WARN"
|
Logger "Cannot send mail via $(type mailsend.exe) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -348,7 +349,7 @@ function SendAlert {
|
|||||||
else
|
else
|
||||||
SMTP_OPTIONS=""
|
SMTP_OPTIONS=""
|
||||||
fi
|
fi
|
||||||
$(type -p sendemail) -f $SENDER_MAIL -t "$DESTINATION_MAILS" -u "$subject" -m "$MAIL_ALERT_MSG" -s $SMTP_SERVER $SMTP_OPTIONS > /dev/null 2>&1
|
$(type -p sendemail) -f $SENDER_MAIL -t "$DESTINATION_MAILS" -u "$subject" -m "$body" -s $SMTP_SERVER $SMTP_OPTIONS > /dev/null 2>&1
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert mail via $(type -p sendemail) !!!" "WARN"
|
Logger "Cannot send alert mail via $(type -p sendemail) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -359,7 +360,7 @@ function SendAlert {
|
|||||||
|
|
||||||
# pfSense specific
|
# pfSense specific
|
||||||
if [ -f /usr/local/bin/mail.php ]; then
|
if [ -f /usr/local/bin/mail.php ]; then
|
||||||
echo "$MAIL_ALERT_MSG" | /usr/local/bin/mail.php -s="$subject"
|
echo "$body" | /usr/local/bin/mail.php -s="$subject"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert mail via /usr/local/bin/mail.php (pfsense) !!!" "WARN"
|
Logger "Cannot send alert mail via /usr/local/bin/mail.php (pfsense) !!!" "WARN"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user