#!/usr/bin/env bash

# Author: Zhang Huangbin <zhb _at_ iredmail.org>

#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail.  If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------

# Variables for Postfix and related.

#
# You do *NOT* need to modify them.
#
# ---- Postfix ----
export POSTFIX_DAEMON_USER='postfix'
export POSTFIX_DAEMON_GROUP='postfix'

export POSTFIX_ROOTDIR='/etc/postfix'
export POSTFIX_RC_SCRIPT_NAME='postfix'

# Log file
export MAILLOG='/var/log/maillog'

# Mail log files.
if [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
    export MAILLOG='/var/log/mail.log'
    export MAILLOG_INFO='/var/log/mail.info'
    export MAILLOG_ERROR='/var/log/mail.err'
    export MAILLOG_WARN='/var/log/mail.warn'

elif [ X"${DISTRO}" == X'FREEBSD' ]; then
    export POSTFIX_ROOTDIR='/usr/local/etc/postfix'

elif [ X"${DISTRO}" == X'OPENBSD' ]; then
    export POSTFIX_DAEMON_USER='_postfix'
    export POSTFIX_DAEMON_GROUP='_postfix'
fi

# You do *NOT* need to modify them.
export POSTFIX_CHROOT_DIR='/var/spool/postfix'

export POSTFIX_FILE_MAIN_CF="${POSTFIX_ROOTDIR}/main.cf"
export POSTFIX_FILE_MASTER_CF="${POSTFIX_ROOTDIR}/master.cf"
export POSTFIX_FILE_ALIASES="${POSTFIX_ROOTDIR}/aliases"
export POSTFIX_FILE_HELO_ACCESS="${POSTFIX_ROOTDIR}/helo_access.pcre"

export POSTFIX_FILE_HEADER_CHECKS="${POSTFIX_ROOTDIR}/header_checks"
export POSTFIX_FILE_BODY_CHECKS="${POSTFIX_ROOTDIR}/body_checks.pcre"
# used for sender white/blacklist with pcre support
export POSTFIX_FILE_SENDER_ACCESS="${POSTFIX_ROOTDIR}/sender_access.pcre"

# Default transport or LDA (local deliver agent).
# We use dovecot deliver program as default transport.
export TRANSPORT='dovecot'

# Set 'message_size_limit', in 'byte'. Default is 10M.
export MESSAGE_SIZE_LIMIT='15728640'

# LDAP/MYSQL/PGSQL lookup configuration files.
if [ X"${BACKEND}" == X"OPENLDAP" ]; then
    export POSTFIX_LOOKUP_DB='ldap'
elif [ X"${BACKEND}" == X"MYSQL" ]; then
    export POSTFIX_LOOKUP_DB='mysql'
elif [ X"${BACKEND}" == X"PGSQL" ]; then
    export POSTFIX_LOOKUP_DB='pgsql'
else
    export POSTFIX_LOOKUP_DIR="${POSTFIX_ROOTDIR}/lookups"
fi

export POSTFIX_LOOKUP_DIR="${POSTFIX_ROOTDIR}/${POSTFIX_LOOKUP_DB}"
