Skip to content

Commit

Permalink
Merge pull request #1046 from wenningerk/alert_cleanup
Browse files Browse the repository at this point in the history
fix: alert-helpers: some fixes in pcmk_smtp_helper.sh
  • Loading branch information
kgaillot committed Jun 6, 2016
2 parents 9b418ac + b5dc005 commit 1a05449
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions extra/alerts/pcmk_smtp_helper.sh
Expand Up @@ -33,20 +33,28 @@
# </alerts>
# </configuration>

email_recipient="${CRM_alert_recipient}"

email_client_default="sendmail"
email_sender_default="hacluster"
email_recipient_default="root"

: ${email_client=${email_client_default}}
: ${email_sender=${email_sender_default}}
: ${email_recipient=${email_recipient_default}}

node_name=`uname -n`
cluster_name=`crm_attribute --query -n cluster-name -q`
email_body=`env | grep CRM_alert_`

if [ -z ${email_sender##*@*} ]; then
if [ ! -z "${email_sender##*@*}" ]; then
email_sender="${email_sender}@${node_name}"
fi

if [ ! -z "${email_recipient##*@*}" ]; then
email_recipient="${email_recipient}@${node_name}"
fi

if [ -z ${CRM_alert_version} ]; then
email_subject="Pacemaker version 1.1.15 is required for smtp-helper"

Expand Down Expand Up @@ -85,10 +93,13 @@ else

esac

if [ ! -z ${email_subject} ]; then
if [ ! -z "${email_subject}" ]; then
case $email_client in
sendmail)
sendmail -F "${email_sender}" "${CRM_alert_recipient}" <<__EOF__
sendmail -t -r ${email_sender} <<__EOF__
From: ${email_sender}
To: ${email_recipient}
Return-Path: ${email_sender}
Subject: ${email_subject}
${email_body}
Expand All @@ -97,4 +108,5 @@ __EOF__
*)
;;
esac
fi
fi

0 comments on commit 1a05449

Please sign in to comment.