Some changes.

This commit is contained in:
kamuri 2017-10-07 20:30:26 +02:00
parent d582d9cee9
commit 6ab23cc562
3 changed files with 41 additions and 8 deletions

View File

@ -1,13 +1,28 @@
#! /bin/bash #! /bin/bash
while true; do
while ! [ $ENABLE_LDAP = 1 ]; do
cd /tmp/docker-mailserver cd /tmp/docker-mailserver
chksum=$(sha512sum -c chksum) chksum=$(sha512sum -c chksum)
resu_acc=${chksum:21:2} resu_acc=${chksum:21:2}
resu_vir=${chksum:44:2} resu_vir=${chksum:44:2}
# Check postfix-virtual.cf exist else break
if [ ! -f postfix-virtual.cf ]; then
echo 'postfix-virtual.cf is missing! exit!'
break;
fi
# Check postfix-accounts.cf exist else break
if [ ! -f postfix-accounts.cf ]; then
echo 'postfix-accounts.cf is missing! exit!'
break;
fi
# Check chksum exist else create
if [ ! -f chksum ]; then
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
fi
if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
echo "CHANGE DETECT" echo "CHANGE DETECT"
echo -n > /etc/postfix/vmailbox echo -n > /etc/postfix/vmailbox
@ -50,16 +65,21 @@ if ! [ $resu_acc = "OK" ] || ! [ $resu_vir = "OK" ]; then
echo ${domain} >> /tmp/vhost.tmp echo ${domain} >> /tmp/vhost.tmp
done done
fi fi
# Set vhost
if [ -f /tmp/vhost.tmp ]; then if [ -f /tmp/vhost.tmp ]; then
cat /tmp/vhost.tmp | sort | uniq > /etc/postfix/vhost && rm /tmp/vhost.tmp cat /tmp/vhost.tmp | sort | uniq > /etc/postfix/vhost && rm /tmp/vhost.tmp
fi fi
# Set right new if needed
if [ `find /var/mail -maxdepth 3 -a \( \! -user 5000 -o \! -group 5000 \) | grep -c .` != 0 ]; then if [ `find /var/mail -maxdepth 3 -a \( \! -user 5000 -o \! -group 5000 \) | grep -c .` != 0 ]; then
chown -R 5000:5000 /var/mail chown -R 5000:5000 /var/mail
fi fi
postfix reload supervisorctl restart postfix
dovecot reload supervisorctl restart dovecot
sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum sha512sum --tag postfix-accounts.cf --tag postfix-virtual.cf > chksum
fi fi
sleep 1 sleep 1
done done

View File

@ -183,7 +183,10 @@ function register_functions() {
if [ "$ENABLE_CLAMAV" = 1 ]; then if [ "$ENABLE_CLAMAV" = 1 ]; then
_register_start_daemon "_start_daemons_clamav" _register_start_daemon "_start_daemons_clamav"
fi fi
# Change detector
if [ "$ENABLE_LDAP" = 0 ]; then
_register_start_daemon "_start_changedetector"
fi
_register_start_daemon "_start_daemons_amavis" _register_start_daemon "_start_daemons_amavis"
################### << daemon funcs ################### << daemon funcs
@ -1247,7 +1250,10 @@ function _start_daemons_amavis() {
# Start check for update postfix-accounts and postfix-virtual # Start check for update postfix-accounts and postfix-virtual
########################################################################## ##########################################################################
nohup /usr/local/bin/check_for_changes.sh >/dev/null 2>&1 & function _start_changedetector() {
notify 'task' 'Starting changedetector' 'n'
supervisorctl start changedetector
}
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@ -114,3 +114,10 @@ stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log stderr_logfile=/var/log/supervisor/%(program_name)s.log
command=/usr/local/bin/postfix-wrapper.sh command=/usr/local/bin/postfix-wrapper.sh
[program:changedetector]
startsecs=0
autostart=false
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
command=/usr/local/bin/check_for_changes.sh