log errors to syslog

This commit is contained in:
casperklein 2024-08-14 22:28:23 +02:00
parent f58c0e8b11
commit 3b7f104601
1 changed files with 7 additions and 3 deletions

View File

@ -11,14 +11,18 @@ GETMAIL_DIR=/var/lib/getmail
# Otherwise 'supervisorctl restart getmail' leads to zombie 'sleep' processes.
trap 'pkill --parent $$' EXIT
function _syslog_error() {
logger --id --priority mail.err -t getmail6 "$*"
}
function _stopService() {
_log 'warn' "Stopping getmail service"
_syslog_error "Stopping service"
exec supervisorctl stop getmail
}
# Verify the correct value for GETMAIL_POLL. Valid are any numbers greater than 0.
if ! [[ ${GETMAIL_POLL} =~ ^[0-9]+$ && ${GETMAIL_POLL} -gt 0 ]]; then
_log 'warn' "Invalid value for GETMAIL_POLL: ${GETMAIL_POLL}"
_syslog_error "Invalid value for GETMAIL_POLL: ${GETMAIL_POLL}"
_stopService
fi
@ -35,7 +39,7 @@ while :; do
# Stop service if no configuration is found.
if [[ -z ${RC_FILE} ]]; then
_log 'warn' 'No getmail configration found'
_syslog_error 'No configration found'
_stopService
fi