1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-23 02:27:05 +00:00

Add Munin

removed testing source

fixed typo & dns

oh cat

more fixes

forgot root

more nginx stuff

nginx munin.conf fix

more fixes

set dns record
This commit is contained in:
Norman 2015-01-28 16:10:44 +01:00
parent 624cc7876a
commit f78cff225b
3 changed files with 94 additions and 0 deletions

68
setup/munin.sh Normal file
View File

@ -0,0 +1,68 @@
#!/bin/bash
# Munin: resource monitoring tool
#################################################
source setup/functions.sh # load our functions
source /etc/mailinabox.conf # load global vars
# install Munin
apt_install munin munin-plugins-extra
# edit config
cat > /etc/munin/munin.conf <<EOF;
dbdir /var/lib/munin
htmldir /var/cache/munin/www
logdir /var/log/munin
rundir /var/run/munin
tmpldir /etc/munin/templates
includedir /etc/munin/munin-conf.d
# a simple host tree
[$PRIMARY_HOSTNAME]
address 127.0.0.1
use_node_name yes
# send alerts to the following address
contacts admin
contact.admin.command mail -s "Munin notification ${var:host}" administrator@$PRIMARY_HOSTNAME
contact.admin.always_send warning critical
EOF
# set subdomain
DOMAIN=${PRIMARY_HOSTNAME#[[:alpha:]]*.}
hide_output curl -d "" --user $(</var/lib/mailinabox/api.key): http://127.0.0.1:10222/dns/set/munin.$DOMAIN
# write nginx config
cat > /etc/nginx/conf.d/munin.conf <<EOF;
# Redirect all HTTP to HTTPS.
server {
listen 80;
listen [::]:80;
server_name munin.$DOMAIN;
root /tmp/invalid-path-nothing-here;
rewrite ^/(.*)$ https://munin.$DOMAIN/$1 permanent;
}
server {
listen 443 ssl;
server_name munin.$DOMAIN;
ssl_certificate $STORAGE_ROOT/ssl/ssl_certificate.pem;
ssl_certificate_key $STORAGE_ROOT/ssl/ssl_private_key.pem;
include /etc/nginx/nginx-ssl.conf;
auth_basic "Authenticate";
auth_basic_user_file /etc/nginx/htpasswd;
root /var/cache/munin/www;
location = /robots.txt {
log_not_found off;
access_log off;
}
}
EOF

View File

@ -125,6 +125,7 @@ source setup/webmail.sh
source setup/owncloud.sh source setup/owncloud.sh
source setup/zpush.sh source setup/zpush.sh
source setup/management.sh source setup/management.sh
source setup/munin.sh
# Write the DNS and nginx configuration files. # Write the DNS and nginx configuration files.
sleep 5 # wait for the daemon to start sleep 5 # wait for the daemon to start
@ -134,6 +135,9 @@ curl -s -d POSTDATA --user $(</var/lib/mailinabox/api.key): http://127.0.0.1:102
# If there aren't any mail users yet, create one. # If there aren't any mail users yet, create one.
source setup/firstuser.sh source setup/firstuser.sh
# Grant admins access to Munin
source tools/munin_update.sh
# Done. # Done.
echo echo
echo "-----------------------------------------------" echo "-----------------------------------------------"

22
tools/munin_update.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Grant admins access to munin
source setup/functions.sh # load our functions
source /etc/mailinabox.conf # load global vars
db=$STORAGE_ROOT'/mail/users.sqlite'
users=`sqlite3 $db "SELECT email FROM users WHERE privileges = 'admin'"`;
passwords=`sqlite3 $db "SELECT password FROM users WHERE privileges = 'admin'"`;
# Define the arrays
users_array=(${users// / })
passwords_array=(${passwords// / })
# clear htpasswd
>/etc/nginx/htpasswd
# write user:password
for i in "${!users_array[@]}"; do
echo "${users_array[i]}:${passwords_array[i]:14}" >> /etc/nginx/htpasswd
done