scripts: new log (#2493)

* added new `_log` function

With `_log`, the `_notify` method wa rendered obsolete. `_notify` was
not completely removed due to test failures in `check-for-changes.sh`.

The new `_log` function properly uses log levels such as `trace`,
`debug`, `info`, `warn` and `error`. It provides a cleaner solution
and renders `DMS_DEBUG` obsolete too (as only `_notify` depends on it).

* converted all helper script to new `_log` function

* converted all startup stacks to new `log` function

* `start-mailserver.sh` now uses new `_log` function

* final test and misc small script adjustments

* updated documentation
This commit is contained in:
Georg Lauterbach 2022-03-21 07:07:52 +01:00 committed by GitHub
parent d8d4b6a189
commit 24031ae365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 367 additions and 221 deletions

View file

@ -2,7 +2,7 @@
function start_daemons
{
_notify 'tasklog' 'Starting daemons & mail server'
_log 'info' 'Starting daemons & mail server'
for FUNC in "${DAEMONS_START[@]}"
do
${FUNC}
@ -11,25 +11,25 @@ function start_daemons
function _start_daemons_cron
{
_notify 'task' 'Starting cron'
_log 'debug' 'Starting cron'
supervisorctl start cron || dms_panic__fail_init 'cron'
}
function _start_daemons_rsyslog
{
_notify 'task' 'Starting rsyslog'
_log 'debug' 'Starting rsyslog'
supervisorctl start rsyslog || dms_panic__fail_init 'rsyslog'
}
function _start_daemons_saslauthd
{
_notify 'task' 'Starting saslauthd'
_log 'debug' 'Starting saslauthd'
supervisorctl start "saslauthd_${SASLAUTHD_MECHANISMS}" || dms_panic__fail_init 'saslauthd'
}
function _start_daemons_fail2ban
{
_notify 'task' 'Starting Fail2ban'
_log 'debug' 'Starting Fail2ban'
touch /var/log/auth.log
# delete fail2ban.sock that probably was left here after container restart
@ -43,35 +43,35 @@ function _start_daemons_fail2ban
function _start_daemons_opendkim
{
_notify 'task' 'Starting opendkim'
_log 'debug' 'Starting opendkim'
supervisorctl start opendkim || dms_panic__fail_init 'opendkim'
}
function _start_daemons_opendmarc
{
_notify 'task' 'Starting opendmarc'
_log 'debug' 'Starting opendmarc'
supervisorctl start opendmarc || dms_panic__fail_init 'opendmarc'
}
function _start_daemons_postsrsd
{
_notify 'task' 'Starting postsrsd'
_log 'debug' 'Starting postsrsd'
supervisorctl start postsrsd || dms_panic__fail_init 'postsrsd'
}
function _start_daemons_postfix
{
_notify 'task' 'Starting postfix'
_log 'debug' 'Starting postfix'
supervisorctl start postfix || dms_panic__fail_init 'postfix'
}
function _start_daemons_dovecot
{
_notify 'task' 'Starting dovecot services'
_log 'debug' 'Starting dovecot services'
if [[ ${ENABLE_POP3} -eq 1 ]]
then
_notify 'task' 'Starting pop3 services'
_log 'debug' 'Starting pop3 services'
mv /etc/dovecot/protocols.d/pop3d.protocol.disab \
/etc/dovecot/protocols.d/pop3d.protocol
fi
@ -86,7 +86,7 @@ function _start_daemons_dovecot
function _start_daemons_fetchmail
{
_notify 'task' 'Preparing fetchmail config'
_log 'debug' 'Preparing fetchmail config'
/usr/local/bin/setup-fetchmail
if [[ ${FETCHMAIL_PARALLEL} -eq 1 ]]
@ -119,42 +119,42 @@ EOF
for _ in /etc/fetchmailrc.d/fetchmail-*.rc
do
COUNTER=$(( COUNTER + 1 ))
_notify 'task' "Starting fetchmail instance ${COUNTER}"
_log 'debug' "Starting fetchmail instance ${COUNTER}"
supervisorctl start "fetchmail-${COUNTER}" || _panic__fail_init "fetchmail-${COUNTER}"
done
else
_notify 'task' 'Starting fetchmail'
_log 'debug' 'Starting fetchmail'
supervisorctl start fetchmail || dms_panic__fail_init 'fetchmail'
fi
}
function _start_daemons_clamav
{
_notify 'task' 'Starting ClamAV'
_log 'debug' 'Starting ClamAV'
supervisorctl start clamav || dms_panic__fail_init 'ClamAV'
}
function _start_daemons_postgrey
{
_notify 'task' 'Starting postgrey'
_log 'debug' 'Starting postgrey'
rm -f /var/run/postgrey/postgrey.pid
supervisorctl start postgrey || dms_panic__fail_init 'postgrey'
}
function _start_daemons_amavis
{
_notify 'task' 'Starting amavis'
_log 'debug' 'Starting amavis'
supervisorctl start amavis || dms_panic__fail_init 'amavis'
}
function _start_changedetector
{
_notify 'task' 'Starting changedetector'
_log 'debug' 'Starting changedetector'
supervisorctl start changedetector || dms_panic__fail_init 'changedetector'
}
function _start_daemons_update_check
{
_notify 'task' 'Starting update-check'
_log 'debug' 'Starting update-check'
supervisorctl start update-check || dms_panic__fail_init 'update-check'
}