More mysql implementation

This commit is contained in:
Julian Hille 2017-08-17 00:01:28 +02:00
parent b8095c24c1
commit f1d5209b35
2 changed files with 56 additions and 0 deletions

View File

@ -57,6 +57,7 @@ RUN apt-get update -q --fix-missing && \
pax \
p7zip-full \
postfix-ldap \
postifx-mysql \
postfix-policyd-spf-python \
pyzor \
rar \

View File

@ -89,6 +89,10 @@ function register_functions() {
_register_setup_function "_setup_ldap"
fi
if [ "$ENABLE_MYSQL" = 1 ];then
_register_setup_function "_setup_mysql"
fi
if [ "$ENABLE_SASLAUTHD" = 1 ];then
_register_setup_function "_setup_saslauthd"
fi
@ -360,6 +364,10 @@ function _check_hostname() {
function _check_environment_variables() {
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
}
##########################################################################
@ -565,8 +573,11 @@ function _setup_ldap() {
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-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
notify 'inf' "Configuring LDAP"
[ -f /etc/postfix/ldap-users.cf ] && \
postconf -e "virtual_mailbox_maps = ldap:/etc/postfix/ldap-users.cf" || \
@ -579,6 +590,50 @@ function _setup_ldap() {
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() {
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