mirror of
https://github.com/deajan/obackup.git
synced 2025-01-12 23:23:53 +01:00
Reverted using eval in SendAlert
This commit is contained in:
parent
2d95d4e64b
commit
b91f80702e
@ -8,7 +8,7 @@ PROGRAM_VERSION=2.0-pre
|
|||||||
PROGRAM_BUILD=2016033101
|
PROGRAM_BUILD=2016033101
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
## FUNC_BUILD=2016033102
|
## FUNC_BUILD=2016033103
|
||||||
## 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
|
||||||
@ -209,9 +209,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
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mutt) -x -s \"$subject\" $DESTINATION_MAILS $attachment_command"
|
echo "$MAIL_ALERT_MSG" | $(type -p mutt) -x -s "$subject" $DESTINATION_MAILS $attachment_command
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mutt) !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mutt) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -224,18 +222,14 @@ function SendAlert {
|
|||||||
if [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V | grep "GNU" > /dev/null; then
|
if [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V | grep "GNU" > /dev/null; then
|
||||||
attachment_command="-A $ALERT_LOG_FILE"
|
attachment_command="-A $ALERT_LOG_FILE"
|
||||||
elif [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V > /dev/null; then
|
elif [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V > /dev/null; then
|
||||||
attachment_command="-a $ALERT_LOG_FILE"
|
attachment_command="-a$ALERT_LOG_FILE"
|
||||||
else
|
else
|
||||||
attachment_command=""
|
attachment_command=""
|
||||||
fi
|
fi
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mail) $attachment_command -s \"$subject\" $DESTINATION_MAILS"
|
echo "$MAIL_ALERT_MSG" | $(type -p mail) $attachment_command -s "$subject" $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mail) with attachments !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mail) with attachments !!!" "WARN"
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mail) -s \"$subject\" $DESTINATION_MAILS"
|
echo "$MAIL_ALERT_MSG" | $(type -p mail) -s "$subject" $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mail) without attachments !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mail) without attachments !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -249,9 +243,7 @@ function SendAlert {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if type sendmail > /dev/null 2>&1 ; then
|
if type sendmail > /dev/null 2>&1 ; then
|
||||||
cmd="echo -e \"Subject:$subject\r\n$MAIL_ALERT_MSG\" | $(type -p sendmail) $DESTINATION_MAILS"
|
echo -e "Subject:$subject\r\n$MAIL_ALERT_MSG" | $(type -p sendmail) $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p sendmail) !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p sendmail) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -277,9 +269,7 @@ function SendAlert {
|
|||||||
|
|
||||||
# pfSense specific
|
# pfSense specific
|
||||||
if [ -f /usr/local/bin/mail.php ]; then
|
if [ -f /usr/local/bin/mail.php ]; then
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | /usr/local/bin/mail.php -s=\"$subject\""
|
echo "$MAIL_ALERT_MSG" | /usr/local/bin/mail.php -s="$subject"
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN"
|
Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -289,7 +279,7 @@ function SendAlert {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# If function has not returned 0 yet, assume it's critical that no alert can be sent
|
# 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, sendemail or pfSense mail.php found)." "ERROR" # Is not marked critical because execution must continue
|
Logger "Cannot send alert (neither mutt, mail, sendmail, sendemail or pfSense mail.php could be used)." "ERROR" # Is not marked critical because execution must continue
|
||||||
|
|
||||||
# Delete tmp log file
|
# Delete tmp log file
|
||||||
if [ -f "$ALERT_LOG_FILE" ]; then
|
if [ -f "$ALERT_LOG_FILE" ]; then
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
## FUNC_BUILD=2016033102
|
## FUNC_BUILD=2016033103
|
||||||
## 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
|
||||||
@ -199,9 +199,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
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mutt) -x -s \"$subject\" $DESTINATION_MAILS $attachment_command"
|
echo "$MAIL_ALERT_MSG" | $(type -p mutt) -x -s "$subject" $DESTINATION_MAILS $attachment_command
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mutt) !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mutt) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -214,18 +212,14 @@ function SendAlert {
|
|||||||
if [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V | grep "GNU" > /dev/null; then
|
if [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V | grep "GNU" > /dev/null; then
|
||||||
attachment_command="-A $ALERT_LOG_FILE"
|
attachment_command="-A $ALERT_LOG_FILE"
|
||||||
elif [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V > /dev/null; then
|
elif [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V > /dev/null; then
|
||||||
attachment_command="-a $ALERT_LOG_FILE"
|
attachment_command="-a$ALERT_LOG_FILE"
|
||||||
else
|
else
|
||||||
attachment_command=""
|
attachment_command=""
|
||||||
fi
|
fi
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mail) $attachment_command -s \"$subject\" $DESTINATION_MAILS"
|
echo "$MAIL_ALERT_MSG" | $(type -p mail) $attachment_command -s "$subject" $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mail) with attachments !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mail) with attachments !!!" "WARN"
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mail) -s \"$subject\" $DESTINATION_MAILS"
|
echo "$MAIL_ALERT_MSG" | $(type -p mail) -s "$subject" $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mail) without attachments !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mail) without attachments !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -239,9 +233,7 @@ function SendAlert {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if type sendmail > /dev/null 2>&1 ; then
|
if type sendmail > /dev/null 2>&1 ; then
|
||||||
cmd="echo -e \"Subject:$subject\r\n$MAIL_ALERT_MSG\" | $(type -p sendmail) $DESTINATION_MAILS"
|
echo -e "Subject:$subject\r\n$MAIL_ALERT_MSG" | $(type -p sendmail) $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p sendmail) !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p sendmail) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -267,9 +259,7 @@ function SendAlert {
|
|||||||
|
|
||||||
# pfSense specific
|
# pfSense specific
|
||||||
if [ -f /usr/local/bin/mail.php ]; then
|
if [ -f /usr/local/bin/mail.php ]; then
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | /usr/local/bin/mail.php -s=\"$subject\""
|
echo "$MAIL_ALERT_MSG" | /usr/local/bin/mail.php -s="$subject"
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN"
|
Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -279,7 +269,7 @@ function SendAlert {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# If function has not returned 0 yet, assume it's critical that no alert can be sent
|
# 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, sendemail or pfSense mail.php found)." "ERROR" # Is not marked critical because execution must continue
|
Logger "Cannot send alert (neither mutt, mail, sendmail, sendemail or pfSense mail.php could be used)." "ERROR" # Is not marked critical because execution must continue
|
||||||
|
|
||||||
# Delete tmp log file
|
# Delete tmp log file
|
||||||
if [ -f "$ALERT_LOG_FILE" ]; then
|
if [ -f "$ALERT_LOG_FILE" ]; then
|
||||||
|
26
obackup.sh
26
obackup.sh
@ -8,7 +8,7 @@ PROGRAM_VERSION=2.0-pre
|
|||||||
PROGRAM_BUILD=2016033101
|
PROGRAM_BUILD=2016033101
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
## FUNC_BUILD=2016033102
|
## FUNC_BUILD=2016033103
|
||||||
## 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
|
||||||
@ -198,9 +198,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
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mutt) -x -s \"$subject\" $DESTINATION_MAILS $attachment_command"
|
echo "$MAIL_ALERT_MSG" | $(type -p mutt) -x -s "$subject" $DESTINATION_MAILS $attachment_command
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mutt) !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mutt) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -213,18 +211,14 @@ function SendAlert {
|
|||||||
if [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V | grep "GNU" > /dev/null; then
|
if [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V | grep "GNU" > /dev/null; then
|
||||||
attachment_command="-A $ALERT_LOG_FILE"
|
attachment_command="-A $ALERT_LOG_FILE"
|
||||||
elif [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V > /dev/null; then
|
elif [ "$mail_no_attachment" -eq 0 ] && $(type -p mail) -V > /dev/null; then
|
||||||
attachment_command="-a $ALERT_LOG_FILE"
|
attachment_command="-a$ALERT_LOG_FILE"
|
||||||
else
|
else
|
||||||
attachment_command=""
|
attachment_command=""
|
||||||
fi
|
fi
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mail) $attachment_command -s \"$subject\" $DESTINATION_MAILS"
|
echo "$MAIL_ALERT_MSG" | $(type -p mail) $attachment_command -s "$subject" $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mail) with attachments !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mail) with attachments !!!" "WARN"
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | $(type -p mail) -s \"$subject\" $DESTINATION_MAILS"
|
echo "$MAIL_ALERT_MSG" | $(type -p mail) -s "$subject" $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p mail) without attachments !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p mail) without attachments !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -238,9 +232,7 @@ function SendAlert {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if type sendmail > /dev/null 2>&1 ; then
|
if type sendmail > /dev/null 2>&1 ; then
|
||||||
cmd="echo -e \"Subject:$subject\r\n$MAIL_ALERT_MSG\" | $(type -p sendmail) $DESTINATION_MAILS"
|
echo -e "Subject:$subject\r\n$MAIL_ALERT_MSG" | $(type -p sendmail) $DESTINATION_MAILS
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via $(type -p sendmail) !!!" "WARN"
|
Logger "Cannot send alert email via $(type -p sendmail) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -266,9 +258,7 @@ function SendAlert {
|
|||||||
|
|
||||||
# pfSense specific
|
# pfSense specific
|
||||||
if [ -f /usr/local/bin/mail.php ]; then
|
if [ -f /usr/local/bin/mail.php ]; then
|
||||||
cmd="echo \"$MAIL_ALERT_MSG\" | /usr/local/bin/mail.php -s=\"$subject\""
|
echo "$MAIL_ALERT_MSG" | /usr/local/bin/mail.php -s="$subject"
|
||||||
Logger "Mail cmd: $cmd" "DEBUG"
|
|
||||||
eval $cmd
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN"
|
Logger "Cannot send alert email via /usr/local/bin/mail.php (pfsense) !!!" "WARN"
|
||||||
else
|
else
|
||||||
@ -278,7 +268,7 @@ function SendAlert {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# If function has not returned 0 yet, assume it's critical that no alert can be sent
|
# 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, sendemail or pfSense mail.php found)." "ERROR" # Is not marked critical because execution must continue
|
Logger "Cannot send alert (neither mutt, mail, sendmail, sendemail or pfSense mail.php could be used)." "ERROR" # Is not marked critical because execution must continue
|
||||||
|
|
||||||
# Delete tmp log file
|
# Delete tmp log file
|
||||||
if [ -f "$ALERT_LOG_FILE" ]; then
|
if [ -f "$ALERT_LOG_FILE" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user