2022-10-17 08:40:09 +00:00
|
|
|
#!/bin/bash
|
2021-02-23 19:03:01 +00:00
|
|
|
|
2023-02-27 19:21:45 +00:00
|
|
|
declare -a DAEMONS_START
|
|
|
|
|
2023-05-25 23:01:41 +00:00
|
|
|
function _register_start_daemon() {
|
2023-02-27 19:21:45 +00:00
|
|
|
DAEMONS_START+=("${1}")
|
|
|
|
_log 'trace' "${1}() registered"
|
|
|
|
}
|
|
|
|
|
2023-05-25 23:01:41 +00:00
|
|
|
function _start_daemons() {
|
2022-03-27 07:43:39 +00:00
|
|
|
_log 'info' 'Starting daemons'
|
|
|
|
|
2023-05-26 12:00:40 +00:00
|
|
|
for FUNCTION in "${DAEMONS_START[@]}"; do
|
2022-03-27 07:43:39 +00:00
|
|
|
${FUNCTION}
|
2021-02-23 19:03:01 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-05-25 23:01:41 +00:00
|
|
|
function _default_start_daemon() {
|
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
|
2023-05-24 07:06:59 +00:00
|
|
|
if [[ ${?} -ne 0 ]]; then
|
2023-02-28 09:25:23 +00:00
|
|
|
_log 'error' "${RESULT}"
|
2023-04-18 21:38:46 +00:00
|
|
|
_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_amavis { _default_start_daemon 'amavis' ; }
|
2023-02-28 09:25:23 +00:00
|
|
|
function _start_daemon_changedetector { _default_start_daemon 'changedetector' ; }
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_clamav { _default_start_daemon 'clamav' ; }
|
|
|
|
function _start_daemon_cron { _default_start_daemon 'cron' ; }
|
2023-02-28 09:25:23 +00:00
|
|
|
function _start_daemon_dovecot { _default_start_daemon 'dovecot' ; }
|
|
|
|
function _start_daemon_fail2ban { _default_start_daemon 'fail2ban' ; }
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_opendkim { _default_start_daemon 'opendkim' ; }
|
|
|
|
function _start_daemon_opendmarc { _default_start_daemon 'opendmarc' ; }
|
2023-02-28 09:25:23 +00:00
|
|
|
function _start_daemon_postgrey { _default_start_daemon 'postgrey' ; }
|
2022-03-27 07:43:39 +00:00
|
|
|
function _start_daemon_postsrsd { _default_start_daemon 'postsrsd' ; }
|
2024-01-13 08:37:20 +00:00
|
|
|
function _start_daemon_mta_sts_daemon { _default_start_daemon 'mta-sts-daemon' ; }
|
2023-02-28 09:25:23 +00:00
|
|
|
function _start_daemon_rspamd { _default_start_daemon 'rspamd' ; }
|
2023-03-04 09:45:43 +00:00
|
|
|
function _start_daemon_rspamd_redis { _default_start_daemon 'rspamd-redis' ; }
|
2022-03-27 07:43:39 +00:00
|
|
|
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
|
|
|
|
2023-05-25 23:01:41 +00:00
|
|
|
function _start_daemon_saslauthd() {
|
2022-03-27 07:43:39 +00:00
|
|
|
_default_start_daemon "saslauthd_${SASLAUTHD_MECHANISMS}"
|
2021-02-23 19:03:01 +00:00
|
|
|
}
|
|
|
|
|
2023-05-25 23:01:41 +00:00
|
|
|
function _start_daemon_postfix() {
|
2023-01-12 21:10:58 +00:00
|
|
|
_adjust_mtime_for_postfix_maincf
|
|
|
|
_default_start_daemon 'postfix'
|
|
|
|
}
|
|
|
|
|
2023-05-25 23:01:41 +00:00
|
|
|
function _start_daemon_fetchmail() {
|
2023-05-24 07:06:59 +00:00
|
|
|
if [[ ${FETCHMAIL_PARALLEL} -eq 1 ]]; then
|
2021-02-23 19:03:01 +00:00
|
|
|
local COUNTER=0
|
2023-05-26 12:00:40 +00:00
|
|
|
for _ in /etc/fetchmailrc.d/fetchmail-*.rc; do
|
2021-02-23 19:03:01 +00:00
|
|
|
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
|
|
|
|
}
|