mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-22 02:17:26 +00:00
Merge branch 'master' of https://github.com/nstanke/mailinabox into munin
This commit is contained in:
commit
a9892efe38
68
setup/munin.sh
Normal file
68
setup/munin.sh
Normal 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
|
@ -145,6 +145,7 @@ source setup/webmail.sh
|
||||
source setup/owncloud.sh
|
||||
source setup/zpush.sh
|
||||
source setup/management.sh
|
||||
source setup/munin.sh
|
||||
|
||||
# Ping the management daemon to write the DNS and nginx configuration files.
|
||||
while [ ! -f /var/lib/mailinabox/api.key ]; do
|
||||
@ -157,6 +158,9 @@ tools/web_update
|
||||
# If there aren't any mail users yet, create one.
|
||||
source setup/firstuser.sh
|
||||
|
||||
# Grant admins access to Munin
|
||||
source tools/munin_update.sh
|
||||
|
||||
# Done.
|
||||
echo
|
||||
echo "-----------------------------------------------"
|
||||
|
22
tools/munin_update.sh
Normal file
22
tools/munin_update.sh
Normal 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
|
Loading…
Reference in New Issue
Block a user