Merge 74cbe1ffed
into 9e7959fafe
This commit is contained in:
commit
4710d9f138
|
@ -31,6 +31,7 @@ RUN apt-get update -q --fix-missing && \
|
||||||
dovecot-imapd \
|
dovecot-imapd \
|
||||||
dovecot-ldap \
|
dovecot-ldap \
|
||||||
dovecot-lmtpd \
|
dovecot-lmtpd \
|
||||||
|
dovecot-mysql \
|
||||||
dovecot-managesieved \
|
dovecot-managesieved \
|
||||||
dovecot-pop3d \
|
dovecot-pop3d \
|
||||||
dovecot-sieve \
|
dovecot-sieve \
|
||||||
|
@ -56,6 +57,7 @@ RUN apt-get update -q --fix-missing && \
|
||||||
pax \
|
pax \
|
||||||
p7zip-full \
|
p7zip-full \
|
||||||
postfix-ldap \
|
postfix-ldap \
|
||||||
|
postfix-mysql \
|
||||||
postfix-policyd-spf-python \
|
postfix-policyd-spf-python \
|
||||||
pyzor \
|
pyzor \
|
||||||
rar \
|
rar \
|
||||||
|
@ -113,7 +115,8 @@ RUN sed -i -e 's/include_try \/usr\/share\/dovecot\/protocols\.d/include_try \/e
|
||||||
|
|
||||||
# Configures LDAP
|
# Configures LDAP
|
||||||
COPY target/dovecot/dovecot-ldap.conf.ext /etc/dovecot
|
COPY target/dovecot/dovecot-ldap.conf.ext /etc/dovecot
|
||||||
COPY target/postfix/ldap-users.cf target/postfix/ldap-groups.cf target/postfix/ldap-aliases.cf /etc/postfix/
|
COPY target/dovecot/dovecot-mysql.conf.ext /etc/dovecot
|
||||||
|
COPY target/postfix/mysql.cf target/postfix/ldap-users.cf target/postfix/ldap-groups.cf target/postfix/ldap-aliases.cf /etc/postfix/
|
||||||
|
|
||||||
# Enables Spamassassin CRON updates
|
# Enables Spamassassin CRON updates
|
||||||
RUN sed -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin
|
RUN sed -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin
|
||||||
|
|
|
@ -237,6 +237,10 @@ Otherwise, `iptables` won't be able to ban IPs.
|
||||||
- **0** => `fetchmail` disabled
|
- **0** => `fetchmail` disabled
|
||||||
- 1 => `fetchmail` enabled
|
- 1 => `fetchmail` enabled
|
||||||
|
|
||||||
|
##### ENABLE_MYSQL
|
||||||
|
- **empty** => MYSQL authentification is disabled
|
||||||
|
- 1 => MYSQL authentification is enabled
|
||||||
|
|
||||||
##### ENABLE_LDAP
|
##### ENABLE_LDAP
|
||||||
|
|
||||||
- **empty** => LDAP authentification is disabled
|
- **empty** => LDAP authentification is disabled
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
driver = mysql
|
||||||
|
connect = "host=127.0.0.1 dbname=vmail user=vmail password=vmaildbpass"
|
||||||
|
default_pass_scheme = SHA512-CRYPT
|
||||||
|
|
||||||
|
password_query = SELECT username AS user, domain, password FROM accounts WHERE username = '%n' AND domain = '%d' and enabled = true;
|
||||||
|
|
||||||
|
user_query = SELECT concat('*:storage=', quota, 'M') AS quota_rule FROM accounts WHERE username = '%n' AND domain = '%d' AND sendonly = false;
|
||||||
|
iterate_query = SELECT username, domain FROM accounts where sendonly = false;
|
|
@ -0,0 +1,5 @@
|
||||||
|
hosts =
|
||||||
|
user =
|
||||||
|
password =
|
||||||
|
dbname =
|
||||||
|
query = SELECT 1 FROM transport WHERE domain= '%s
|
|
@ -14,6 +14,7 @@ DEFAULT_VARS["ENABLE_FAIL2BAN"]="${ENABLE_FAIL2BAN:="0"}"
|
||||||
DEFAULT_VARS["ENABLE_MANAGESIEVE"]="${ENABLE_MANAGESIEVE:="0"}"
|
DEFAULT_VARS["ENABLE_MANAGESIEVE"]="${ENABLE_MANAGESIEVE:="0"}"
|
||||||
DEFAULT_VARS["ENABLE_FETCHMAIL"]="${ENABLE_FETCHMAIL:="0"}"
|
DEFAULT_VARS["ENABLE_FETCHMAIL"]="${ENABLE_FETCHMAIL:="0"}"
|
||||||
DEFAULT_VARS["ENABLE_LDAP"]="${ENABLE_LDAP:="0"}"
|
DEFAULT_VARS["ENABLE_LDAP"]="${ENABLE_LDAP:="0"}"
|
||||||
|
DEFAULT_VARS["ENABLE_MYSQL"]="${ENABLE_MYSQL:="0"}"
|
||||||
DEFAULT_VARS["ENABLE_POSTGREY"]="${ENABLE_POSTGREY:="0"}"
|
DEFAULT_VARS["ENABLE_POSTGREY"]="${ENABLE_POSTGREY:="0"}"
|
||||||
DEFAULT_VARS["POSTGREY_DELAY"]="${POSTGREY_DELAY:="300"}"
|
DEFAULT_VARS["POSTGREY_DELAY"]="${POSTGREY_DELAY:="300"}"
|
||||||
DEFAULT_VARS["POSTGREY_MAX_AGE"]="${POSTGREY_MAX_AGE:="35"}"
|
DEFAULT_VARS["POSTGREY_MAX_AGE"]="${POSTGREY_MAX_AGE:="35"}"
|
||||||
|
@ -88,6 +89,10 @@ function register_functions() {
|
||||||
_register_setup_function "_setup_ldap"
|
_register_setup_function "_setup_ldap"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$ENABLE_MYSQL" = 1 ];then
|
||||||
|
_register_setup_function "_setup_mysql"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$ENABLE_SASLAUTHD" = 1 ];then
|
if [ "$ENABLE_SASLAUTHD" = 1 ];then
|
||||||
_register_setup_function "_setup_saslauthd"
|
_register_setup_function "_setup_saslauthd"
|
||||||
fi
|
fi
|
||||||
|
@ -359,6 +364,10 @@ function _check_hostname() {
|
||||||
|
|
||||||
function _check_environment_variables() {
|
function _check_environment_variables() {
|
||||||
notify "task" "Check that there are no conflicts with env variables [$FUNCNAME]"
|
notify "task" "Check that there are no conflicts with env variables [$FUNCNAME]"
|
||||||
|
if [[ ${ENABLE_LDAP} = 1 ]] && [[ ${ENABLE_MYSQL} = 1 ]]; then
|
||||||
|
notify 'fatal' "Mysql and LDAP must not be enabled at the same time."
|
||||||
|
defunc
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -463,7 +472,7 @@ function _setup_dovecot_local_user() {
|
||||||
notify 'task' 'Setting up Dovecot Local User'
|
notify 'task' 'Setting up Dovecot Local User'
|
||||||
echo -n > /etc/postfix/vmailbox
|
echo -n > /etc/postfix/vmailbox
|
||||||
echo -n > /etc/dovecot/userdb
|
echo -n > /etc/dovecot/userdb
|
||||||
if [ -f /tmp/docker-mailserver/postfix-accounts.cf -a "$ENABLE_LDAP" != 1 ]; then
|
if [[ -f /tmp/docker-mailserver/postfix-accounts.cf ]] && [[ ${ENABLE_LDAP} != 1 ]] && [[ ${ENABLE_MYSQL} != 1 ]]; then
|
||||||
notify 'inf' "Checking file line endings"
|
notify 'inf' "Checking file line endings"
|
||||||
sed -i 's/\r//g' /tmp/docker-mailserver/postfix-accounts.cf
|
sed -i 's/\r//g' /tmp/docker-mailserver/postfix-accounts.cf
|
||||||
notify 'inf' "Regenerating postfix user list"
|
notify 'inf' "Regenerating postfix user list"
|
||||||
|
@ -512,8 +521,8 @@ function _setup_dovecot_local_user() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! $(grep '@' /tmp/docker-mailserver/postfix-accounts.cf | grep '|') ]]; then
|
if [[ ! $(grep '@' /tmp/docker-mailserver/postfix-accounts.cf | grep '|') ]]; then
|
||||||
if [ $ENABLE_LDAP -eq 0 ]; then
|
if [ $ENABLE_LDAP -eq 0 -a $ENABLE_MYSQL -eq 0 ]; then
|
||||||
notify 'fatal' "Unless using LDAP, you need at least 1 email account to start the server."
|
notify 'fatal' "Unless using LDAP or MySQL, you need at least 1 email account to start the server."
|
||||||
defunc
|
defunc
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -564,8 +573,11 @@ function _setup_ldap() {
|
||||||
|
|
||||||
notify 'inf' "Enabling dovecot LDAP authentification"
|
notify 'inf' "Enabling dovecot LDAP authentification"
|
||||||
sed -i -e '/\!include auth-ldap\.conf\.ext/s/^#//' /etc/dovecot/conf.d/10-auth.conf
|
sed -i -e '/\!include auth-ldap\.conf\.ext/s/^#//' /etc/dovecot/conf.d/10-auth.conf
|
||||||
|
sed -i -e '/\!include auth-sql\.conf\.ext/s/^/#/' /etc/dovecot/conf.d/10-auth.conf
|
||||||
sed -i -e '/\!include auth-passwdfile\.inc/s/^/#/' /etc/dovecot/conf.d/10-auth.conf
|
sed -i -e '/\!include auth-passwdfile\.inc/s/^/#/' /etc/dovecot/conf.d/10-auth.conf
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
notify 'inf' "Configuring LDAP"
|
notify 'inf' "Configuring LDAP"
|
||||||
[ -f /etc/postfix/ldap-users.cf ] && \
|
[ -f /etc/postfix/ldap-users.cf ] && \
|
||||||
postconf -e "virtual_mailbox_maps = ldap:/etc/postfix/ldap-users.cf" || \
|
postconf -e "virtual_mailbox_maps = ldap:/etc/postfix/ldap-users.cf" || \
|
||||||
|
@ -578,6 +590,50 @@ function _setup_ldap() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _setup_mysql() {
|
||||||
|
notify 'task' 'Setting up MySQL'
|
||||||
|
|
||||||
|
notify 'inf' "Configuring postfix MySQL"
|
||||||
|
|
||||||
|
declare -A _postfix_mysql_mapping
|
||||||
|
|
||||||
|
_postfix_mysql_mapping["POSTFIX_MYSQL_HOSTS"]="${POSTFIX_MYSQL_HOSTS:="${MYSQL_HOST}"}"
|
||||||
|
_postfix_mysql_mapping["POSTFIX_MYSQL_DBNAME"]="${POSTFIX_MYSQL_DBNAME:="${MYSQL_DB}"}"
|
||||||
|
_postfix_mysql_mapping["POSTFIX_MYSQL_USER"]="${POSTFIX_MYSQL_USER:="${MYSQL_USER}"}"
|
||||||
|
_postfix_mysql_mapping["POSTFIX_MYSQL_PASSWORD"]="${POSTFIX_MYSQL_PASSWORD:="${MYSQL_PASSWORD}"}"
|
||||||
|
for var in ${!_dovecot_mysql_mapping[@]}; do
|
||||||
|
export $var=${_dovecot_mysql_mapping[$var]}
|
||||||
|
done
|
||||||
|
configomat.sh "POSTFIX_MYSQL_" "/etc/postfix/mysql.cf"
|
||||||
|
|
||||||
|
notify 'inf' "Configuring dovecot MySQL"
|
||||||
|
declare -A _dovecot_mysql_mapping
|
||||||
|
|
||||||
|
_dovecot_mysql_mapping["DOVECOT_MYSQL_CONNECT"]="${DOVECOT_MYSQL_CONNECT:="host=${MYSQL_HOST} dbname=${MYSQL_DB} user=${MYSQL_USER} password=${MYSQL_PASSWORD}"}"
|
||||||
|
_dovecot_mysql_mapping["DOVECOT_MYSQL_DEFAULT_PASS_SCHEME"]="${DOVECOT_MYSQL_DEFAULT_PASS_SCHEME:="${MYSQL_PASS_SCHEME}"}"
|
||||||
|
|
||||||
|
for var in ${!_dovecot_mysql_mapping[@]}; do
|
||||||
|
export $var=${_dovecot_mysql_mapping[$var]}
|
||||||
|
done
|
||||||
|
|
||||||
|
configomat.sh "DOVECOT_MYSQL_" "/etc/dovecot/dovecot-mysql.conf.ext"
|
||||||
|
|
||||||
|
# Add domainname to vhost.
|
||||||
|
echo $DOMAINNAME >> /tmp/vhost.tmp
|
||||||
|
|
||||||
|
notify 'inf' "Enabling dovecot mysql authentification"
|
||||||
|
sed -i -e '/\!include auth-sql\.conf\.ext/s/^#//' /etc/dovecot/conf.d/10-auth.conf
|
||||||
|
sed -i -e '/\!include auth-passwdfile\.inc/s/^/#/' /etc/dovecot/conf.d/10-auth.conf
|
||||||
|
sed -i -e '/\!include auth-ldap\.inc/s/^/#/' /etc/dovecot/conf.d/10-auth.conf
|
||||||
|
|
||||||
|
notify 'inf' "Configuring MySQL"
|
||||||
|
[ -f /etc/postfix/mysql.cf ] && \
|
||||||
|
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql.cf" || \
|
||||||
|
notify 'inf' "==> Warning: /etc/postfix/ldap-user.cf not found"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
function _setup_postgrey() {
|
function _setup_postgrey() {
|
||||||
notify 'inf' "Configuring postgrey"
|
notify 'inf' "Configuring postgrey"
|
||||||
sed -i -e 's/bl.spamcop.net$/bl.spamcop.net, check_policy_service inet:127.0.0.1:10023/' /etc/postfix/main.cf
|
sed -i -e 's/bl.spamcop.net$/bl.spamcop.net, check_policy_service inet:127.0.0.1:10023/' /etc/postfix/main.cf
|
||||||
|
|
Loading…
Reference in New Issue