From bb427191b7923bc97775132182b8c3cd57646c35 Mon Sep 17 00:00:00 2001 From: Jason Levine Date: Thu, 23 Feb 2017 14:40:00 -0500 Subject: add support for multiple munin usernames and passwords use openssl to generate htpasswd file remove apache2-utils dependency update readme regarding username/password support --- start-munin.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) mode change 100644 => 100755 start-munin.sh (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh old mode 100644 new mode 100755 index fda929c..4ab8e1c --- a/start-munin.sh +++ b/start-munin.sh @@ -1,8 +1,8 @@ #!/bin/bash NODES=${NODES:-} SNMP_NODES=${SNMP_NODES:-} -MUNIN_USER=${MUNIN_USER:-user} -MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} +MUNIN_USERS=${MUNIN_USERS:-user} +MUNIN_PASSWORDS=${MUNIN_PASSWORDS:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' SMTP_USE_TLS=${SMTP_USE_TLS:-false} SMTP_ALWAYS_SEND=${SMTP_ALWAYS_SEND:-true} @@ -47,7 +47,16 @@ if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then fi fi -[ -e /etc/munin/htpasswd.users ] || htpasswd -b -c /etc/munin/htpasswd.users "$MUNIN_USER" "$MUNIN_PASSWORD" +# generate the Munin auth username/password file +if [ ! -f /etc/munin/htpasswd.users ]; then + uc = 0 + IFS=' ' read -ra ARR_USERS <<< "$MUNIN_USERS" + IFS=' ' read -ra ARR_PASSWORDS <<< "$MUNIN_PASSWORDS" + for u in "${ARR_USERS[@]}"; do + printf "${u}:`openssl passwd -apr1 ${ARR_PASSWORDS[uc]}`\n" >> /etc/munin/htpasswd.users + (( uc++ )) + done +fi # generate node list for NODE in $NODES -- cgit v1.2.1 From 09e12a6d4fc01f9252de5cbf869cfa55ea1aaf23 Mon Sep 17 00:00:00 2001 From: Jason Levine Date: Mon, 27 Feb 2017 09:38:16 -0500 Subject: fix readme to reflect need to quote command-line, space-separated username/password env vars add backward compatibility for previous MUNIN_USER and MUNIN_PASSWORD env vars --- 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 4ab8e1c..fef4449 100755 --- a/start-munin.sh +++ b/start-munin.sh @@ -1,8 +1,8 @@ #!/bin/bash NODES=${NODES:-} SNMP_NODES=${SNMP_NODES:-} -MUNIN_USERS=${MUNIN_USERS:-user} -MUNIN_PASSWORDS=${MUNIN_PASSWORDS:-password} +MUNIN_USERS=${MUNIN_USERS:-${MUNIN_USER:-user}} +MUNIN_PASSWORDS=${MUNIN_PASSWORDS:-${MUNIN_PASSWORD:-password}} MAIL_CONF_PATH='/var/lib/munin/.mailrc' SMTP_USE_TLS=${SMTP_USE_TLS:-false} SMTP_ALWAYS_SEND=${SMTP_ALWAYS_SEND:-true} -- cgit v1.2.1