From a9c43678db7671a1c575f197299695de446dcee1 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 07:24:32 +0200 Subject: made smtp auth optional --- start-munin.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index c3aa70b..954a112 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -3,15 +3,23 @@ NODES=${NODES:-} SNMP_NODES=${SNMP_NODES:-} MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} +MAIL_CONF_PATH='/var/lib/munin/.mailrc' -if [ -n "${SMTP_USERNAME}" -a -n "${SMTP_PASSWORD}" -a -n "${SMTP_HOST}" -a -n "${SMTP_PORT}" ] ; then - cat > /var/lib/munin/.mailrc <> "${MAIL_CONF_PATH}" <> "${MAIL_CONF_PATH}" < Date: Wed, 1 Jun 2016 08:14:11 +0200 Subject: made tls optional --- start-munin.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index 954a112..bed2e80 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -4,13 +4,19 @@ SNMP_NODES=${SNMP_NODES:-} MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' +SMTP_USE_TLS=false truncate -s 0 "${MAIL_CONF_PATH}" -if [ -n "${SMTP_HOST}" -a -n "${SMTP_PORT}" ] ; then +if [ "${SMTP_USE_TLS}" = true ] ; then cat >> "${MAIL_CONF_PATH}" <> "${MAIL_CONF_PATH}" < Date: Wed, 1 Jun 2016 08:27:17 +0200 Subject: added smtp_always_send parameter; documented smtp_always_send and smtp_use_tls parameters --- start-munin.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index bed2e80..e994128 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -5,6 +5,7 @@ MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' SMTP_USE_TLS=false +SMTP_ALWAYS_SEND=true truncate -s 0 "${MAIL_CONF_PATH}" @@ -33,6 +34,9 @@ grep -q 'contact.mail' /etc/munin/munin.conf; rc=$? if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then echo "Setup alert email from ${ALERT_SENDER} to ${ALERT_RECIPIENT}" echo 'contact.mail.command mail -r '${ALERT_SENDER}' -s "[${var:group};${var:host}] -> ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}"' ${ALERT_RECIPIENT} >> /etc/munin/munin.conf + if [ "${SMTP_ALWAYS_SEND}" = true ] ; then + echo 'contact.mail.always_send warning critical' >> /etc/munin/munin.conf + fi fi [ -e /etc/munin/htpasswd.users ] || htpasswd -b -c /etc/munin/htpasswd.users "$MUNIN_USER" "$MUNIN_PASSWORD" -- cgit v1.2.1 From a1fe06d2383628d71e265acc9be544159a413cc1 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 08:58:24 +0200 Subject: fixed smtp_use_tls and smtp_alway_send parameter value overrides --- start-munin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index e994128..a7209f7 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -4,8 +4,8 @@ SNMP_NODES=${SNMP_NODES:-} MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' -SMTP_USE_TLS=false -SMTP_ALWAYS_SEND=true +SMTP_USE_TLS=${SMTP_USE_TLS:-false} +SMTP_ALWAYS_SEND=${SMTP_ALWAYS_SEND:-true} truncate -s 0 "${MAIL_CONF_PATH}" -- cgit v1.2.1 From c88f6adeb932998772b12545b7ace69578275150 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 09:03:54 +0200 Subject: exported smtp_message as configuration parameter --- start-munin.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index a7209f7..58b3d0a 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -6,6 +6,8 @@ MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' SMTP_USE_TLS=${SMTP_USE_TLS:-false} SMTP_ALWAYS_SEND=${SMTP_ALWAYS_SEND:-true} +SMTP_MESSAGE_DEFAULT='[${var:group};${var:host}] -> ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}' +SMTP_MESSAGE="${SMTP_MESSAGE:-$SMTP_MESSAGE_DEFAULT}" truncate -s 0 "${MAIL_CONF_PATH}" @@ -33,7 +35,7 @@ fi grep -q 'contact.mail' /etc/munin/munin.conf; rc=$? if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then echo "Setup alert email from ${ALERT_SENDER} to ${ALERT_RECIPIENT}" - echo 'contact.mail.command mail -r '${ALERT_SENDER}' -s "[${var:group};${var:host}] -> ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}"' ${ALERT_RECIPIENT} >> /etc/munin/munin.conf + echo "contact.mail.command mail -r ${ALERT_SENDER} -s ${SMTP_MESSAGE} ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf if [ "${SMTP_ALWAYS_SEND}" = true ] ; then echo 'contact.mail.always_send warning critical' >> /etc/munin/munin.conf fi -- cgit v1.2.1 From 55e3dc2f06721d697935bdc0a820352675b8b185 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 09:37:03 +0200 Subject: fixed quoting of smtp_message environment variable --- start-munin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index 58b3d0a..235a7e4 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -35,7 +35,7 @@ fi grep -q 'contact.mail' /etc/munin/munin.conf; rc=$? if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then echo "Setup alert email from ${ALERT_SENDER} to ${ALERT_RECIPIENT}" - echo "contact.mail.command mail -r ${ALERT_SENDER} -s ${SMTP_MESSAGE} ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf +echo "contact.mail.command mail -r ${ALERT_SENDER} -s \'${SMTP_MESSAGE}\' ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf if [ "${SMTP_ALWAYS_SEND}" = true ] ; then echo 'contact.mail.always_send warning critical' >> /etc/munin/munin.conf fi -- cgit v1.2.1 From 5ebec8d1b9fe51d074b351e1cfe0a307d086bc48 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 09:53:36 +0200 Subject: removed unnecessary escaping of the smtp message env. var --- start-munin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index 235a7e4..8a050de 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -35,7 +35,7 @@ fi grep -q 'contact.mail' /etc/munin/munin.conf; rc=$? if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then echo "Setup alert email from ${ALERT_SENDER} to ${ALERT_RECIPIENT}" -echo "contact.mail.command mail -r ${ALERT_SENDER} -s \'${SMTP_MESSAGE}\' ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf + echo "contact.mail.command mail -r ${ALERT_SENDER} -s '${SMTP_MESSAGE}' ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf if [ "${SMTP_ALWAYS_SEND}" = true ] ; then echo 'contact.mail.always_send warning critical' >> /etc/munin/munin.conf fi -- cgit v1.2.1