summaryrefslogtreecommitdiffstats
path: root/start-munin.sh
diff options
context:
space:
mode:
authorSoulou <leo.unbek@gmail.com>2017-03-03 10:14:12 +0100
committerGitHub <noreply@github.com>2017-03-03 10:14:12 +0100
commit1ed62c531f44712bc7f86ed8f8bcf1afa8d01132 (patch)
tree03d9460f30aca25e514593e1c43d4db350f2fa57 /start-munin.sh
parent73d0b3879b90fb48a9177a03382cfd132ab5c431 (diff)
parent09e12a6d4fc01f9252de5cbf869cfa55ea1aaf23 (diff)
downloadmunin-1ed62c531f44712bc7f86ed8f8bcf1afa8d01132.tar.gz
munin-1ed62c531f44712bc7f86ed8f8bcf1afa8d01132.tar.bz2
munin-1ed62c531f44712bc7f86ed8f8bcf1afa8d01132.tar.xz
munin-1ed62c531f44712bc7f86ed8f8bcf1afa8d01132.zip
Merge pull request #8 from delfuego/master
add support for multiple munin usernames and passwords
Diffstat (limited to 'start-munin.sh')
-rwxr-xr-x[-rw-r--r--]start-munin.sh15
1 files changed, 12 insertions, 3 deletions
diff --git a/start-munin.sh b/start-munin.sh
index fda929c..fef4449 100644..100755
--- 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:-${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}
@@ -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