From b4f4a122c8fa69ffed02f93b6bf2cb70785f8cfb Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 22 Mar 2016 12:43:01 +0100 Subject: [PATCH] Added pfSense mail support and fixed FreeBSD install.sh --- dev/debug_osync.sh | 18 ++++++++++++++++-- dev/ofunctions.sh | 18 ++++++++++++++++-- osync.sh | 18 ++++++++++++++++-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/dev/debug_osync.sh b/dev/debug_osync.sh index c38232b..02e1f7d 100755 --- a/dev/debug_osync.sh +++ b/dev/debug_osync.sh @@ -11,7 +11,7 @@ PROGRAM_VERSION=1.1-dev PROGRAM_BUILD=2016031002 IS_STABLE=no -## FUNC_BUILD=2016032002 +## FUNC_BUILD=2016032201 ## 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 @@ -170,6 +170,7 @@ function SendAlert { local mail_no_attachment= local attachment_command= + local subject= if [ "$DESTINATION_MAILS" == "" ]; then return 0 @@ -273,8 +274,21 @@ function SendAlert { fi fi + # pfSense specific + if [ -f /usr/local/bin/mail.php ]; then + cmd="echo \"$MAIL_ALERT_MSG\" | /usr/local/bin/mail.php subject=\"$subject\"" + Logger "Mail cmd: $cmd" "DEBUG" + eval $cmd + if [ $? != 0 ]; then + Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN" + else + Logger "Sent alert mail using pfSense mail.php." "NOTICE" + return 0 + fi + fi + # If function has not returned 0 yet, assume it's critical that no alert can be sent - Logger "Cannot send alert (neither mutt, mail, sendmail nor sendemail found)." "ERROR" # Is not marked critical because execution must continue + Logger "Cannot send alert (neither mutt, mail, sendmail, sendemail or pfSense mail.php found)." "ERROR" # Is not marked critical because execution must continue # Delete tmp log file if [ -f "$ALERT_LOG_FILE" ]; then diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 79ee896..e3d5d9f 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -1,4 +1,4 @@ -## FUNC_BUILD=2016032002 +## FUNC_BUILD=2016032201 ## 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 @@ -157,6 +157,7 @@ function SendAlert { local mail_no_attachment= local attachment_command= + local subject= if [ "$DESTINATION_MAILS" == "" ]; then return 0 @@ -260,8 +261,21 @@ function SendAlert { fi fi + # pfSense specific + if [ -f /usr/local/bin/mail.php ]; then + cmd="echo \"$MAIL_ALERT_MSG\" | /usr/local/bin/mail.php subject=\"$subject\"" + Logger "Mail cmd: $cmd" "DEBUG" + eval $cmd + if [ $? != 0 ]; then + Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN" + else + Logger "Sent alert mail using pfSense mail.php." "NOTICE" + return 0 + fi + fi + # If function has not returned 0 yet, assume it's critical that no alert can be sent - Logger "Cannot send alert (neither mutt, mail, sendmail nor sendemail found)." "ERROR" # Is not marked critical because execution must continue + Logger "Cannot send alert (neither mutt, mail, sendmail, sendemail or pfSense mail.php found)." "ERROR" # Is not marked critical because execution must continue # Delete tmp log file if [ -f "$ALERT_LOG_FILE" ]; then diff --git a/osync.sh b/osync.sh index eff718c..c837253 100755 --- a/osync.sh +++ b/osync.sh @@ -11,7 +11,7 @@ PROGRAM_VERSION=1.1-dev PROGRAM_BUILD=2016031002 IS_STABLE=no -## FUNC_BUILD=2016032002 +## FUNC_BUILD=2016032201 ## 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 @@ -159,6 +159,7 @@ function SendAlert { local mail_no_attachment= local attachment_command= + local subject= if [ "$DESTINATION_MAILS" == "" ]; then return 0 @@ -262,8 +263,21 @@ function SendAlert { fi fi + # pfSense specific + if [ -f /usr/local/bin/mail.php ]; then + cmd="echo \"$MAIL_ALERT_MSG\" | /usr/local/bin/mail.php subject=\"$subject\"" + Logger "Mail cmd: $cmd" "DEBUG" + eval $cmd + if [ $? != 0 ]; then + Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN" + else + Logger "Sent alert mail using pfSense mail.php." "NOTICE" + return 0 + fi + fi + # If function has not returned 0 yet, assume it's critical that no alert can be sent - Logger "Cannot send alert (neither mutt, mail, sendmail nor sendemail found)." "ERROR" # Is not marked critical because execution must continue + Logger "Cannot send alert (neither mutt, mail, sendmail, sendemail or pfSense mail.php found)." "ERROR" # Is not marked critical because execution must continue # Delete tmp log file if [ -f "$ALERT_LOG_FILE" ]; then