2021-02-23 19:03:01 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemons
|
2021-02-23 19:03:01 +00:00
|
|
|
{
|
2022-03-27 07:43:39 +00:00
|
|
|
_log 'info' 'Starting daemons'
|
|
|
|
|
|
|
|
for FUNCTION in "${DAEMONS_START[@]}"
|
2021-02-23 19:03:01 +00:00
|
|
|
do
|
2022-03-27 07:43:39 +00:00
|
|
|
${FUNCTION}
|
2021-02-23 19:03:01 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
function _default_start_daemon
|
2021-02-23 19:03:01 +00:00
|
|
|
{
|
2022-03-27 07:43:39 +00:00
|
|
|
_log 'debug' "Starting ${1:?}"
|
2021-02-23 19:03:01 +00:00
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
local RESULT
|
2022-05-05 08:28:38 +00:00
|
|
|
RESULT=$(supervisorctl start "${1}" 2>&1)
|
2021-02-23 19:03:01 +00:00
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
# shellcheck disable=SC2181
|
|
|
|
if [[ ${?} -ne 0 ]]
|
2021-02-23 19:03:01 +00:00
|
|
|
then
|
2022-03-27 07:43:39 +00:00
|
|
|
echo "${RESULT}" >&2
|
|
|
|
dms_panic__fail_init "${1}"
|
2021-02-23 19:03:01 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_changedetector { _default_start_daemon 'changedetector' ; }
|
|
|
|
function _start_daemon_amavis { _default_start_daemon 'amavis' ; }
|
|
|
|
function _start_daemon_clamav { _default_start_daemon 'clamav' ; }
|
|
|
|
function _start_daemon_cron { _default_start_daemon 'cron' ; }
|
|
|
|
function _start_daemon_opendkim { _default_start_daemon 'opendkim' ; }
|
|
|
|
function _start_daemon_opendmarc { _default_start_daemon 'opendmarc' ; }
|
|
|
|
function _start_daemon_postsrsd { _default_start_daemon 'postsrsd' ; }
|
|
|
|
function _start_daemon_postfix { _default_start_daemon 'postfix' ; }
|
|
|
|
function _start_daemon_rsyslog { _default_start_daemon 'rsyslog' ; }
|
|
|
|
function _start_daemon_update_check { _default_start_daemon 'update-check' ; }
|
2021-02-23 19:03:01 +00:00
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_saslauthd
|
2021-02-23 19:03:01 +00:00
|
|
|
{
|
2022-03-27 07:43:39 +00:00
|
|
|
_default_start_daemon "saslauthd_${SASLAUTHD_MECHANISMS}"
|
2021-02-23 19:03:01 +00:00
|
|
|
}
|
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_postgrey
|
2021-02-23 19:03:01 +00:00
|
|
|
{
|
2022-03-27 07:43:39 +00:00
|
|
|
rm -f /var/run/postgrey/postgrey.pid
|
|
|
|
_default_start_daemon 'postgrey'
|
2021-02-23 19:03:01 +00:00
|
|
|
}
|
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_fail2ban
|
2021-02-23 19:03:01 +00:00
|
|
|
{
|
2022-03-27 07:43:39 +00:00
|
|
|
touch /var/log/auth.log
|
|
|
|
|
|
|
|
# delete fail2ban.sock that probably was left here after container restart
|
|
|
|
[[ -e /var/run/fail2ban/fail2ban.sock ]] && rm /var/run/fail2ban/fail2ban.sock
|
|
|
|
|
|
|
|
_default_start_daemon 'fail2ban'
|
2021-02-23 19:03:01 +00:00
|
|
|
}
|
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_dovecot
|
2021-02-23 19:03:01 +00:00
|
|
|
{
|
|
|
|
if [[ ${ENABLE_POP3} -eq 1 ]]
|
|
|
|
then
|
2022-03-27 07:43:39 +00:00
|
|
|
_log 'debug' 'Enabling POP3 services'
|
|
|
|
mv /etc/dovecot/protocols.d/pop3d.protocol.disab /etc/dovecot/protocols.d/pop3d.protocol
|
2021-02-23 19:03:01 +00:00
|
|
|
fi
|
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
[[ -f /tmp/docker-mailserver/dovecot.cf ]] && cp /tmp/docker-mailserver/dovecot.cf /etc/dovecot/local.conf
|
2021-02-23 19:03:01 +00:00
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
_default_start_daemon 'dovecot'
|
2021-02-23 19:03:01 +00:00
|
|
|
}
|
|
|
|
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_fetchmail
|
2021-02-23 19:03:01 +00:00
|
|
|
{
|
|
|
|
if [[ ${FETCHMAIL_PARALLEL} -eq 1 ]]
|
|
|
|
then
|
|
|
|
local COUNTER=0
|
|
|
|
for _ in /etc/fetchmailrc.d/fetchmail-*.rc
|
|
|
|
do
|
|
|
|
COUNTER=$(( COUNTER + 1 ))
|
2022-03-27 07:43:39 +00:00
|
|
|
_default_start_daemon "fetchmail-${COUNTER}"
|
2021-02-23 19:03:01 +00:00
|
|
|
done
|
|
|
|
else
|
2022-03-27 07:43:39 +00:00
|
|
|
_default_start_daemon 'fetchmail'
|
2021-02-23 19:03:01 +00:00
|
|
|
fi
|
|
|
|
}
|