2020-10-21 16:16:32 +00:00
|
|
|
#! /bin/bash
|
2015-03-28 14:59:15 +00:00
|
|
|
|
2022-05-15 21:37:21 +00:00
|
|
|
# ------------------------------------------------------------
|
2022-03-21 12:42:12 +00:00
|
|
|
# ? >> Sourcing helpers & stacks
|
|
|
|
# 1. Helpers
|
|
|
|
# 2. Checks
|
|
|
|
# 3. Setup
|
|
|
|
# 4. Fixes
|
|
|
|
# 5. Miscellaneous
|
|
|
|
# 6. Daemons
|
|
|
|
# ------------------------------------------------------------
|
|
|
|
|
2022-02-21 10:56:57 +00:00
|
|
|
# shellcheck source=./helpers/index.sh
|
|
|
|
source /usr/local/bin/helpers/index.sh
|
2018-04-04 16:48:55 +00:00
|
|
|
|
2022-03-21 12:42:12 +00:00
|
|
|
# shellcheck source=./startup/check-stack.sh
|
|
|
|
source /usr/local/bin/check-stack.sh
|
|
|
|
|
|
|
|
# shellcheck source=./startup/setup-stack.sh
|
|
|
|
source /usr/local/bin/setup-stack.sh
|
|
|
|
|
|
|
|
# shellcheck source=./startup/fixes-stack.sh
|
|
|
|
source /usr/local/bin/fixes-stack.sh
|
|
|
|
|
|
|
|
# shellcheck source=./startup/misc-stack.sh
|
|
|
|
source /usr/local/bin/misc-stack.sh
|
|
|
|
|
|
|
|
# shellcheck source=./startup/daemons-stack.sh
|
|
|
|
source /usr/local/bin/daemons-stack.sh
|
|
|
|
|
2022-05-15 21:37:21 +00:00
|
|
|
# ------------------------------------------------------------
|
|
|
|
# ? << Sourcing helpers & stacks
|
|
|
|
# --
|
|
|
|
# ? >> Setup Supervisor & DNS names
|
2022-03-21 12:42:12 +00:00
|
|
|
# ------------------------------------------------------------
|
|
|
|
|
|
|
|
# Setup supervisord as early as possible
|
2021-02-23 19:03:01 +00:00
|
|
|
declare -A VARS
|
2022-03-21 12:42:12 +00:00
|
|
|
VARS[SUPERVISOR_LOGLEVEL]="${SUPERVISOR_LOGLEVEL:=warn}"
|
2021-02-23 19:03:01 +00:00
|
|
|
|
2022-05-15 21:37:21 +00:00
|
|
|
_setup_supervisor
|
2022-03-02 21:22:17 +00:00
|
|
|
_obtain_hostname_and_domainname
|
|
|
|
|
2021-06-08 01:20:20 +00:00
|
|
|
# ------------------------------------------------------------
|
2022-05-15 21:37:21 +00:00
|
|
|
# ? << Setup Supervisor & DNS names
|
2021-06-08 01:20:20 +00:00
|
|
|
# --
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? >> Setup of default and global values / variables
|
2021-06-08 01:20:20 +00:00
|
|
|
# ------------------------------------------------------------
|
2021-02-23 19:03:01 +00:00
|
|
|
|
2022-05-15 21:37:21 +00:00
|
|
|
# shellcheck disable=SC2034
|
|
|
|
declare -a FUNCS_SETUP FUNCS_FIX FUNCS_CHECK FUNCS_MISC DAEMONS_START
|
|
|
|
|
2022-03-02 21:22:17 +00:00
|
|
|
# These variables must be defined first; They are used as default values for other variables.
|
|
|
|
VARS[POSTMASTER_ADDRESS]="${POSTMASTER_ADDRESS:=postmaster@${DOMAINNAME}}"
|
|
|
|
VARS[REPORT_RECIPIENT]="${REPORT_RECIPIENT:=${POSTMASTER_ADDRESS}}"
|
2022-03-18 18:41:02 +00:00
|
|
|
VARS[REPORT_SENDER]="${REPORT_SENDER:=mailserver-report@${HOSTNAME}}"
|
2022-03-02 21:22:17 +00:00
|
|
|
|
2021-05-06 21:51:45 +00:00
|
|
|
VARS[AMAVIS_LOGLEVEL]="${AMAVIS_LOGLEVEL:=0}"
|
2022-03-03 15:17:01 +00:00
|
|
|
VARS[CLAMAV_MESSAGE_SIZE_LIMIT]="${CLAMAV_MESSAGE_SIZE_LIMIT:=25M}" # 25 MB
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[DEFAULT_RELAY_HOST]="${DEFAULT_RELAY_HOST:=}"
|
2022-01-05 23:53:18 +00:00
|
|
|
VARS[DOVECOT_INET_PROTOCOLS]="${DOVECOT_INET_PROTOCOLS:=all}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[DOVECOT_MAILBOX_FORMAT]="${DOVECOT_MAILBOX_FORMAT:=maildir}"
|
|
|
|
VARS[DOVECOT_TLS]="${DOVECOT_TLS:=no}"
|
2021-03-28 13:37:48 +00:00
|
|
|
VARS[ENABLE_AMAVIS]="${ENABLE_AMAVIS:=1}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[ENABLE_CLAMAV]="${ENABLE_CLAMAV:=0}"
|
2022-01-03 21:03:46 +00:00
|
|
|
VARS[ENABLE_DNSBL]="${ENABLE_DNSBL:=0}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[ENABLE_FAIL2BAN]="${ENABLE_FAIL2BAN:=0}"
|
|
|
|
VARS[ENABLE_FETCHMAIL]="${ENABLE_FETCHMAIL:=0}"
|
|
|
|
VARS[ENABLE_LDAP]="${ENABLE_LDAP:=0}"
|
|
|
|
VARS[ENABLE_MANAGESIEVE]="${ENABLE_MANAGESIEVE:=0}"
|
|
|
|
VARS[ENABLE_POP3]="${ENABLE_POP3:=0}"
|
|
|
|
VARS[ENABLE_POSTGREY]="${ENABLE_POSTGREY:=0}"
|
|
|
|
VARS[ENABLE_QUOTAS]="${ENABLE_QUOTAS:=1}"
|
|
|
|
VARS[ENABLE_SASLAUTHD]="${ENABLE_SASLAUTHD:=0}"
|
|
|
|
VARS[ENABLE_SPAMASSASSIN]="${ENABLE_SPAMASSASSIN:=0}"
|
2022-02-21 09:48:28 +00:00
|
|
|
VARS[ENABLE_SPAMASSASSIN_KAM]="${ENABLE_SPAMASSASSIN_KAM:=0}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[ENABLE_SRS]="${ENABLE_SRS:=0}"
|
2021-05-19 19:18:06 +00:00
|
|
|
VARS[ENABLE_UPDATE_CHECK]="${ENABLE_UPDATE_CHECK:=1}"
|
2021-04-18 10:55:43 +00:00
|
|
|
VARS[FAIL2BAN_BLOCKTYPE]="${FAIL2BAN_BLOCKTYPE:=drop}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[FETCHMAIL_PARALLEL]="${FETCHMAIL_PARALLEL:=0}"
|
2021-11-02 10:51:36 +00:00
|
|
|
VARS[FETCHMAIL_POLL]="${FETCHMAIL_POLL:=300}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[LDAP_START_TLS]="${LDAP_START_TLS:=no}"
|
2022-03-21 06:07:52 +00:00
|
|
|
VARS[LOG_LEVEL]="${LOG_LEVEL:=info}"
|
2022-03-02 21:22:17 +00:00
|
|
|
VARS[LOGROTATE_INTERVAL]="${LOGROTATE_INTERVAL:=weekly}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[LOGWATCH_INTERVAL]="${LOGWATCH_INTERVAL:=none}"
|
2022-03-02 21:22:17 +00:00
|
|
|
VARS[LOGWATCH_RECIPIENT]="${LOGWATCH_RECIPIENT:=${REPORT_RECIPIENT}}"
|
|
|
|
VARS[LOGWATCH_SENDER]="${LOGWATCH_SENDER:=${REPORT_SENDER}}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[MOVE_SPAM_TO_JUNK]="${MOVE_SPAM_TO_JUNK:=1}"
|
|
|
|
VARS[NETWORK_INTERFACE]="${NETWORK_INTERFACE:=eth0}"
|
2021-08-31 11:50:56 +00:00
|
|
|
VARS[ONE_DIR]="${ONE_DIR:=1}"
|
2022-03-02 21:22:17 +00:00
|
|
|
VARS[OVERRIDE_HOSTNAME]="${OVERRIDE_HOSTNAME:-}"
|
2022-03-03 15:17:01 +00:00
|
|
|
VARS[PERMIT_DOCKER]="${PERMIT_DOCKER:=none}"
|
2022-03-02 21:22:17 +00:00
|
|
|
VARS[PFLOGSUMM_RECIPIENT]="${PFLOGSUMM_RECIPIENT:=${REPORT_RECIPIENT}}"
|
|
|
|
VARS[PFLOGSUMM_SENDER]="${PFLOGSUMM_SENDER:=${REPORT_SENDER}}"
|
|
|
|
VARS[PFLOGSUMM_TRIGGER]="${PFLOGSUMM_TRIGGER:=none}"
|
2021-11-02 10:51:36 +00:00
|
|
|
VARS[POSTFIX_INET_PROTOCOLS]="${POSTFIX_INET_PROTOCOLS:=all}"
|
|
|
|
VARS[POSTFIX_MAILBOX_SIZE_LIMIT]="${POSTFIX_MAILBOX_SIZE_LIMIT:=0}"
|
2022-03-03 15:17:01 +00:00
|
|
|
VARS[POSTFIX_MESSAGE_SIZE_LIMIT]="${POSTFIX_MESSAGE_SIZE_LIMIT:=10240000}" # ~10 MB
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[POSTGREY_AUTO_WHITELIST_CLIENTS]="${POSTGREY_AUTO_WHITELIST_CLIENTS:=5}"
|
|
|
|
VARS[POSTGREY_DELAY]="${POSTGREY_DELAY:=300}"
|
|
|
|
VARS[POSTGREY_MAX_AGE]="${POSTGREY_MAX_AGE:=35}"
|
|
|
|
VARS[POSTGREY_TEXT]="${POSTGREY_TEXT:=Delayed by Postgrey}"
|
|
|
|
VARS[POSTSCREEN_ACTION]="${POSTSCREEN_ACTION:=enforce}"
|
|
|
|
VARS[RELAY_HOST]="${RELAY_HOST:=}"
|
2021-11-02 10:51:36 +00:00
|
|
|
VARS[SA_KILL]=${SA_KILL:="6.31"}
|
|
|
|
VARS[SA_SPAM_SUBJECT]=${SA_SPAM_SUBJECT:="***SPAM*** "}
|
|
|
|
VARS[SA_TAG]=${SA_TAG:="2.0"}
|
|
|
|
VARS[SA_TAG2]=${SA_TAG2:="6.31"}
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[SMTP_ONLY]="${SMTP_ONLY:=0}"
|
2022-02-17 08:31:45 +00:00
|
|
|
VARS[SPAMASSASSIN_SPAM_TO_INBOX]="${SPAMASSASSIN_SPAM_TO_INBOX:=1}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[SPOOF_PROTECTION]="${SPOOF_PROTECTION:=0}"
|
|
|
|
VARS[SRS_SENDER_CLASSES]="${SRS_SENDER_CLASSES:=envelope_sender}"
|
|
|
|
VARS[SSL_TYPE]="${SSL_TYPE:=}"
|
|
|
|
VARS[TLS_LEVEL]="${TLS_LEVEL:=modern}"
|
2022-04-06 14:48:41 +00:00
|
|
|
VARS[TZ]="${TZ:=}"
|
2021-05-19 19:18:06 +00:00
|
|
|
VARS[UPDATE_CHECK_INTERVAL]="${UPDATE_CHECK_INTERVAL:=1d}"
|
2021-02-23 19:03:01 +00:00
|
|
|
VARS[VIRUSMAILS_DELETE_DELAY]="${VIRUSMAILS_DELETE_DELAY:=7}"
|
|
|
|
|
2022-06-04 19:28:13 +00:00
|
|
|
# SASL specific variables
|
2022-06-05 19:33:21 +00:00
|
|
|
VARS[LDAP_BIND_DN]="${LDAP_BIND_DN:=}"
|
|
|
|
VARS[LDAP_BIND_PW]="${LDAP_BIND_PW:=}"
|
|
|
|
VARS[LDAP_SEARCH_BASE]="${LDAP_SEARCH_BASE:=}"
|
|
|
|
VARS[LDAP_SERVER_HOST]="${LDAP_SERVER_HOST:=}"
|
|
|
|
|
|
|
|
VARS[SASLAUTHD_LDAP_AUTH_METHOD]="${SASLAUTHD_LDAP_AUTH_METHOD:=bind}"
|
2022-06-04 19:28:13 +00:00
|
|
|
VARS[SASLAUTHD_LDAP_BIND_DN]="${SASLAUTHD_LDAP_BIND_DN:=${LDAP_BIND_DN}}"
|
2022-06-05 19:33:21 +00:00
|
|
|
VARS[SASLAUTHD_LDAP_FILTER]="${SASLAUTHD_LDAP_FILTER:=(&(uniqueIdentifier=%u)(mailEnabled=TRUE))}"
|
2022-06-04 19:28:13 +00:00
|
|
|
VARS[SASLAUTHD_LDAP_PASSWORD]="${SASLAUTHD_LDAP_PASSWORD:=${LDAP_BIND_PW}}"
|
|
|
|
VARS[SASLAUTHD_LDAP_SEARCH_BASE]="${SASLAUTHD_LDAP_SEARCH_BASE:=${LDAP_SEARCH_BASE}}"
|
2022-06-05 19:33:21 +00:00
|
|
|
VARS[SASLAUTHD_LDAP_SERVER]="${SASLAUTHD_LDAP_SERVER:=${LDAP_SERVER_HOST}}"
|
2022-06-04 19:28:13 +00:00
|
|
|
[[ ${SASLAUTHD_LDAP_SERVER} != *'://'* ]] && SASLAUTHD_LDAP_SERVER="ldap://${SASLAUTHD_LDAP_SERVER}"
|
|
|
|
VARS[SASLAUTHD_LDAP_START_TLS]="${SASLAUTHD_LDAP_START_TLS:=no}"
|
|
|
|
VARS[SASLAUTHD_LDAP_TLS_CHECK_PEER]="${SASLAUTHD_LDAP_TLS_CHECK_PEER:=no}"
|
2022-06-05 19:33:21 +00:00
|
|
|
VARS[SASLAUTHD_MECHANISMS]="${SASLAUTHD_MECHANISMS:=pam}"
|
2022-06-04 19:28:13 +00:00
|
|
|
|
|
|
|
if [[ -z ${SASLAUTHD_LDAP_TLS_CACERT_FILE} ]]
|
|
|
|
then
|
|
|
|
SASLAUTHD_LDAP_TLS_CACERT_FILE=''
|
|
|
|
else
|
|
|
|
SASLAUTHD_LDAP_TLS_CACERT_FILE="ldap_tls_cacert_file: ${SASLAUTHD_LDAP_TLS_CACERT_FILE}"
|
|
|
|
fi
|
|
|
|
VARS[SASLAUTHD_LDAP_TLS_CACERT_FILE]="${SASLAUTHD_LDAP_TLS_CACERT_FILE}"
|
|
|
|
|
|
|
|
if [[ -z ${SASLAUTHD_LDAP_TLS_CACERT_DIR} ]]
|
|
|
|
then
|
|
|
|
SASLAUTHD_LDAP_TLS_CACERT_DIR=''
|
|
|
|
else
|
|
|
|
SASLAUTHD_LDAP_TLS_CACERT_DIR="ldap_tls_cacert_dir: ${SASLAUTHD_LDAP_TLS_CACERT_DIR}"
|
|
|
|
fi
|
|
|
|
VARS[SASLAUTHD_LDAP_TLS_CACERT_DIR]="${SASLAUTHD_LDAP_TLS_CACERT_DIR}"
|
|
|
|
|
|
|
|
if [[ -z ${SASLAUTHD_LDAP_PASSWORD_ATTR} ]]
|
|
|
|
then
|
|
|
|
SASLAUTHD_LDAP_PASSWORD_ATTR=''
|
|
|
|
else
|
|
|
|
SASLAUTHD_LDAP_PASSWORD_ATTR="ldap_password_attr: ${SASLAUTHD_LDAP_PASSWORD_ATTR}"
|
|
|
|
fi
|
|
|
|
VARS[SASLAUTHD_LDAP_PASSWORD_ATTR]="${SASLAUTHD_LDAP_PASSWORD_ATTR}"
|
|
|
|
|
|
|
|
if [[ -z ${SASLAUTHD_LDAP_MECH} ]]
|
|
|
|
then
|
|
|
|
SASLAUTHD_LDAP_MECH=''
|
|
|
|
else
|
|
|
|
SASLAUTHD_LDAP_MECH="ldap_mech: ${SASLAUTHD_LDAP_MECH}"
|
|
|
|
fi
|
|
|
|
VARS[SASLAUTHD_LDAP_MECH]="${SASLAUTHD_LDAP_MECH}"
|
|
|
|
|
2021-06-08 01:20:20 +00:00
|
|
|
# ------------------------------------------------------------
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? << Setup of default and global values / variables
|
2021-06-08 01:20:20 +00:00
|
|
|
# --
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? >> Registering functions
|
2021-06-08 01:20:20 +00:00
|
|
|
# ------------------------------------------------------------
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2022-05-15 21:37:21 +00:00
|
|
|
function _register_functions
|
2020-09-23 08:21:37 +00:00
|
|
|
{
|
2022-03-21 06:07:52 +00:00
|
|
|
_log 'info' 'Initializing setup'
|
|
|
|
_log 'debug' 'Registering functions'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? >> Checks
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
_register_check_function '_check_hostname'
|
2022-03-21 06:07:52 +00:00
|
|
|
_register_check_function '_check_log_level'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? >> Setup
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
_register_setup_function '_setup_default_vars'
|
|
|
|
_register_setup_function '_setup_file_permissions'
|
2020-09-23 08:21:37 +00:00
|
|
|
|
2022-04-06 14:48:41 +00:00
|
|
|
[[ -n ${TZ} ]] && _register_setup_function '_setup_timezone'
|
|
|
|
|
2020-09-23 08:21:37 +00:00
|
|
|
if [[ ${SMTP_ONLY} -ne 1 ]]
|
|
|
|
then
|
2021-02-23 19:03:01 +00:00
|
|
|
_register_setup_function '_setup_dovecot'
|
|
|
|
_register_setup_function '_setup_dovecot_dhparam'
|
|
|
|
_register_setup_function '_setup_dovecot_quota'
|
|
|
|
_register_setup_function '_setup_dovecot_local_user'
|
|
|
|
fi
|
|
|
|
|
|
|
|
[[ ${ENABLE_LDAP} -eq 1 ]] && _register_setup_function '_setup_ldap'
|
|
|
|
[[ ${ENABLE_POSTGREY} -eq 1 ]] && _register_setup_function '_setup_postgrey'
|
|
|
|
[[ ${ENABLE_SASLAUTHD} -eq 1 ]] && _register_setup_function '_setup_saslauthd'
|
2022-01-05 23:53:18 +00:00
|
|
|
[[ ${POSTFIX_INET_PROTOCOLS} != 'all' ]] && _register_setup_function '_setup_postfix_inet_protocols'
|
|
|
|
[[ ${DOVECOT_INET_PROTOCOLS} != 'all' ]] && _register_setup_function '_setup_dovecot_inet_protocols'
|
2021-04-18 10:55:43 +00:00
|
|
|
[[ ${ENABLE_FAIL2BAN} -eq 1 ]] && _register_setup_function '_setup_fail2ban'
|
2022-01-03 21:03:46 +00:00
|
|
|
[[ ${ENABLE_DNSBL} -eq 0 ]] && _register_setup_function '_setup_dnsbl_disable'
|
2022-03-03 15:17:01 +00:00
|
|
|
[[ ${CLAMAV_MESSAGE_SIZE_LIMIT} != '25M' ]] && _register_setup_function '_setup_clamav_sizelimit'
|
2021-02-23 19:03:01 +00:00
|
|
|
|
|
|
|
_register_setup_function '_setup_dkim'
|
|
|
|
_register_setup_function '_setup_ssl'
|
|
|
|
_register_setup_function '_setup_docker_permit'
|
|
|
|
_register_setup_function '_setup_mailname'
|
|
|
|
_register_setup_function '_setup_amavis'
|
|
|
|
_register_setup_function '_setup_dmarc_hostname'
|
|
|
|
_register_setup_function '_setup_postfix_hostname'
|
|
|
|
_register_setup_function '_setup_dovecot_hostname'
|
|
|
|
_register_setup_function '_setup_postfix_smtputf8'
|
|
|
|
_register_setup_function '_setup_postfix_sasl'
|
|
|
|
_register_setup_function '_setup_security_stack'
|
|
|
|
_register_setup_function '_setup_postfix_aliases'
|
|
|
|
_register_setup_function '_setup_postfix_vhost'
|
|
|
|
_register_setup_function '_setup_postfix_dhparam'
|
|
|
|
_register_setup_function '_setup_postfix_postscreen'
|
|
|
|
_register_setup_function '_setup_postfix_sizelimits'
|
2019-09-15 16:29:46 +00:00
|
|
|
|
2021-01-19 11:31:45 +00:00
|
|
|
# needs to come after _setup_postfix_aliases
|
2021-02-23 19:03:01 +00:00
|
|
|
[[ ${SPOOF_PROTECTION} -eq 1 ]] && _register_setup_function '_setup_spoof_protection'
|
2018-03-18 18:52:28 +00:00
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
if [[ ${ENABLE_FETCHMAIL} -eq 1 ]]
|
|
|
|
then
|
|
|
|
_register_setup_function '_setup_fetchmail'
|
|
|
|
[[ ${FETCHMAIL_PARALLEL} -eq 1 ]] && _register_setup_function '_setup_fetchmail_parallel'
|
|
|
|
fi
|
|
|
|
|
2020-09-23 08:21:37 +00:00
|
|
|
if [[ ${ENABLE_SRS} -eq 1 ]]
|
|
|
|
then
|
2021-02-23 19:03:01 +00:00
|
|
|
_register_setup_function '_setup_SRS'
|
2022-03-27 07:43:39 +00:00
|
|
|
_register_start_daemon '_start_daemon_postsrsd'
|
2020-09-23 08:21:37 +00:00
|
|
|
fi
|
2019-09-15 13:40:05 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
_register_setup_function '_setup_postfix_access_control'
|
2021-11-20 20:33:49 +00:00
|
|
|
_register_setup_function '_setup_postfix_relay_hosts'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
[[ ${ENABLE_POSTFIX_VIRTUAL_TRANSPORT:-0} -eq 1 ]] && _register_setup_function '_setup_postfix_virtual_transport'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
_register_setup_function '_setup_postfix_override_configuration'
|
|
|
|
_register_setup_function '_setup_logrotate'
|
|
|
|
_register_setup_function '_setup_mail_summary'
|
|
|
|
_register_setup_function '_setup_logwatch'
|
|
|
|
_register_setup_function '_setup_user_patches'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? >> Fixes
|
2017-02-07 19:53:34 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
_register_fix_function '_fix_var_mail_permissions'
|
2021-03-28 13:37:48 +00:00
|
|
|
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _register_fix_function '_fix_var_amavis_permissions'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
[[ ${ENABLE_CLAMAV} -eq 0 ]] && _register_fix_function '_fix_cleanup_clamav'
|
|
|
|
[[ ${ENABLE_SPAMASSASSIN} -eq 0 ]] && _register_fix_function '_fix_cleanup_spamassassin'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? >> Miscellaneous
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
_register_misc_function '_misc_save_states'
|
2017-02-06 09:21:18 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? >> Daemons
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
_register_start_daemon '_start_daemon_cron'
|
|
|
|
_register_start_daemon '_start_daemon_rsyslog'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
[[ ${SMTP_ONLY} -ne 1 ]] && _register_start_daemon '_start_daemon_dovecot'
|
|
|
|
[[ ${ENABLE_UPDATE_CHECK} -eq 1 ]] && _register_start_daemon '_start_daemon_update_check'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
# needs to be started before SASLauthd
|
2022-03-27 07:43:39 +00:00
|
|
|
_register_start_daemon '_start_daemon_opendkim'
|
|
|
|
_register_start_daemon '_start_daemon_opendmarc'
|
2016-12-01 14:45:40 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
# needs to be started before postfix
|
2022-03-27 07:43:39 +00:00
|
|
|
[[ ${ENABLE_POSTGREY} -eq 1 ]] && _register_start_daemon '_start_daemon_postgrey'
|
2020-09-23 08:21:37 +00:00
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
_register_start_daemon '_start_daemon_postfix'
|
2020-09-23 08:21:37 +00:00
|
|
|
|
2021-02-23 19:03:01 +00:00
|
|
|
# needs to be started after postfix
|
2022-03-27 07:43:39 +00:00
|
|
|
[[ ${ENABLE_SASLAUTHD} -eq 1 ]] && _register_start_daemon '_start_daemon_saslauthd'
|
|
|
|
[[ ${ENABLE_FAIL2BAN} -eq 1 ]] && _register_start_daemon '_start_daemon_fail2ban'
|
|
|
|
[[ ${ENABLE_FETCHMAIL} -eq 1 ]] && _register_start_daemon '_start_daemon_fetchmail'
|
|
|
|
[[ ${ENABLE_CLAMAV} -eq 1 ]] && _register_start_daemon '_start_daemon_clamav'
|
|
|
|
[[ ${ENABLE_LDAP} -eq 0 ]] && _register_start_daemon '_start_daemon_changedetector'
|
|
|
|
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _register_start_daemon '_start_daemon_amavis'
|
2016-12-01 14:45:40 +00:00
|
|
|
}
|
2020-09-23 08:21:37 +00:00
|
|
|
|
2020-10-02 13:45:57 +00:00
|
|
|
function _register_start_daemon
|
2020-09-23 08:21:37 +00:00
|
|
|
{
|
|
|
|
DAEMONS_START+=("${1}")
|
2022-03-21 06:07:52 +00:00
|
|
|
_log 'trace' "${1}() registered"
|
2016-12-01 14:45:40 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 13:45:57 +00:00
|
|
|
function _register_setup_function
|
2020-09-23 08:21:37 +00:00
|
|
|
{
|
|
|
|
FUNCS_SETUP+=("${1}")
|
2022-03-21 06:07:52 +00:00
|
|
|
_log 'trace' "${1}() registered"
|
2016-12-01 14:45:40 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 13:45:57 +00:00
|
|
|
function _register_fix_function
|
2020-09-23 08:21:37 +00:00
|
|
|
{
|
|
|
|
FUNCS_FIX+=("${1}")
|
2022-03-21 06:07:52 +00:00
|
|
|
_log 'trace' "${1}() registered"
|
2016-12-01 14:45:40 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 13:45:57 +00:00
|
|
|
function _register_check_function
|
2020-09-23 08:21:37 +00:00
|
|
|
{
|
|
|
|
FUNCS_CHECK+=("${1}")
|
2022-03-21 06:07:52 +00:00
|
|
|
_log 'trace' "${1}() registered"
|
2016-12-01 14:45:40 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 13:45:57 +00:00
|
|
|
function _register_misc_function
|
2020-09-23 08:21:37 +00:00
|
|
|
{
|
|
|
|
FUNCS_MISC+=("${1}")
|
2022-03-21 06:07:52 +00:00
|
|
|
_log 'trace' "${1}() registered"
|
2016-12-01 14:45:40 +00:00
|
|
|
}
|
2020-09-23 08:21:37 +00:00
|
|
|
|
2021-06-08 01:20:20 +00:00
|
|
|
# ------------------------------------------------------------
|
2021-02-23 19:03:01 +00:00
|
|
|
# ? << Registering functions
|
2021-06-08 01:20:20 +00:00
|
|
|
# --
|
2022-05-15 21:37:21 +00:00
|
|
|
# ? >> Executing all stacks / actual start of DMS
|
2021-06-08 01:20:20 +00:00
|
|
|
# ------------------------------------------------------------
|
2020-12-08 14:07:01 +00:00
|
|
|
|
2022-03-21 06:07:52 +00:00
|
|
|
_log 'info' "Welcome to docker-mailserver $(</VERSION)"
|
2020-12-08 14:07:01 +00:00
|
|
|
|
2022-05-15 21:37:21 +00:00
|
|
|
_register_functions
|
|
|
|
_check
|
|
|
|
_setup
|
2022-03-21 06:07:52 +00:00
|
|
|
[[ ${LOG_LEVEL} =~ (debug|trace) ]] && print-environment
|
2022-05-15 21:37:21 +00:00
|
|
|
_apply_fixes
|
|
|
|
_start_misc
|
2022-03-27 07:43:39 +00:00
|
|
|
_start_daemons
|
2020-12-08 14:29:49 +00:00
|
|
|
|
2022-05-15 21:37:21 +00:00
|
|
|
# marker to check if container was restarted
|
2022-03-17 10:24:30 +00:00
|
|
|
date >/CONTAINER_START
|
2022-01-07 23:25:09 +00:00
|
|
|
|
2022-03-21 06:07:52 +00:00
|
|
|
_log 'info' "${HOSTNAME} is up and running"
|
2016-12-23 22:56:39 +00:00
|
|
|
|
2017-08-07 15:39:40 +00:00
|
|
|
touch /var/log/mail/mail.log
|
2021-05-17 12:54:43 +00:00
|
|
|
tail -Fn 0 /var/log/mail/mail.log
|
2016-12-01 14:45:40 +00:00
|
|
|
|
|
|
|
exit 0
|