Make getmail a supervisord service; remove getmail cron job
This commit is contained in:
parent
701962415d
commit
f2c49f53d9
|
@ -212,7 +212,8 @@ EOF
|
||||||
RUN echo 'Reason_Message = Message {rejectdefer} due to: {spf}.' >>/etc/postfix-policyd-spf-python/policyd-spf.conf
|
RUN echo 'Reason_Message = Message {rejectdefer} due to: {spf}.' >>/etc/postfix-policyd-spf-python/policyd-spf.conf
|
||||||
|
|
||||||
COPY target/fetchmail/fetchmailrc /etc/fetchmailrc_general
|
COPY target/fetchmail/fetchmailrc /etc/fetchmailrc_general
|
||||||
COPY target/getmail/getmailrc /etc/getmailrc_general
|
COPY target/getmail/getmailrc_general /etc/getmailrc_general
|
||||||
|
COPY target/getmail/getmail-service.sh /usr/local/bin/
|
||||||
COPY target/postfix/main.cf target/postfix/master.cf /etc/postfix/
|
COPY target/postfix/main.cf target/postfix/master.cf /etc/postfix/
|
||||||
|
|
||||||
# DH parameters for DHE cipher suites, ffdhe4096 is the official standard 4096-bit DH params now part of TLS 1.3
|
# DH parameters for DHE cipher suites, ffdhe4096 is the official standard 4096-bit DH params now part of TLS 1.3
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
#! /bin/bash
|
|
||||||
|
|
||||||
GETMAILDIR=/tmp/docker-mailserver/getmail
|
|
||||||
for FILE in /etc/getmailrc.d/getmailrc*; do
|
|
||||||
if ! pgrep -f "${FILE}$" &>/dev/null; then
|
|
||||||
getmail --getmaildir "${GETMAILDIR}" --rcfile "${FILE}"
|
|
||||||
fi
|
|
||||||
done
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# shellcheck source=../scripts/helpers/log.sh
|
||||||
|
source /usr/local/bin/helpers/log.sh
|
||||||
|
|
||||||
|
# Directory, where "oldmail" files are stored.
|
||||||
|
# getmail stores its state - its "memory" of what it has seen in your POP/IMAP account - in the oldmail files.
|
||||||
|
GETMAIL_DIR=/var/lib/getmail
|
||||||
|
|
||||||
|
# Kill all child processes on EXIT.
|
||||||
|
# Otherwise 'supervisorctl restart getmail' leads to zombie 'sleep' processes.
|
||||||
|
trap 'pkill --parent $$' EXIT
|
||||||
|
|
||||||
|
function _stopService() {
|
||||||
|
_log 'warn' "Stopping getmail 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}"
|
||||||
|
_stopService
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If no matching filenames are found, and the shell option nullglob is disabled, the word is left unchanged.
|
||||||
|
# If the nullglob option is set, and no matches are found, the word is removed.
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
# Run each getmailrc periodically.
|
||||||
|
while :; do
|
||||||
|
for RC_FILE in /etc/getmailrc.d/*; do
|
||||||
|
_log 'debug' "Processing ${RC_FILE}"
|
||||||
|
getmail --getmaildir "${GETMAIL_DIR}" --rcfile "${RC_FILE}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Stop service if no configuration is found.
|
||||||
|
if [[ -z ${RC_FILE} ]]; then
|
||||||
|
_log 'warn' 'No getmail configration found'
|
||||||
|
_stopService
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep "${GETMAIL_POLL}m"
|
||||||
|
done
|
|
@ -1,3 +1,5 @@
|
||||||
|
# https://getmail6.org/configuration.html#conf-options
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
verbose = 0
|
verbose = 0
|
||||||
read_all = false
|
read_all = false
|
||||||
|
@ -5,3 +7,5 @@ delete = false
|
||||||
max_messages_per_session = 500
|
max_messages_per_session = 500
|
||||||
received = false
|
received = false
|
||||||
delivered_to = false
|
delivered_to = false
|
||||||
|
message_log_syslog = true
|
||||||
|
|
|
@ -161,6 +161,7 @@ function _register_functions() {
|
||||||
[[ ${ENABLE_CLAMAV} -eq 1 ]] && _register_start_daemon '_start_daemon_clamav'
|
[[ ${ENABLE_CLAMAV} -eq 1 ]] && _register_start_daemon '_start_daemon_clamav'
|
||||||
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _register_start_daemon '_start_daemon_amavis'
|
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _register_start_daemon '_start_daemon_amavis'
|
||||||
[[ ${ACCOUNT_PROVISIONER} == 'FILE' ]] && _register_start_daemon '_start_daemon_changedetector'
|
[[ ${ACCOUNT_PROVISIONER} == 'FILE' ]] && _register_start_daemon '_start_daemon_changedetector'
|
||||||
|
[[ ${ENABLE_GETMAIL} -eq 1 ]] && _register_start_daemon '_start_daemon_getmail'
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
|
@ -34,6 +34,7 @@ function _start_daemon_clamav { _default_start_daemon 'clamav' ;
|
||||||
function _start_daemon_cron { _default_start_daemon 'cron' ; }
|
function _start_daemon_cron { _default_start_daemon 'cron' ; }
|
||||||
function _start_daemon_dovecot { _default_start_daemon 'dovecot' ; }
|
function _start_daemon_dovecot { _default_start_daemon 'dovecot' ; }
|
||||||
function _start_daemon_fail2ban { _default_start_daemon 'fail2ban' ; }
|
function _start_daemon_fail2ban { _default_start_daemon 'fail2ban' ; }
|
||||||
|
function _start_daemon_getmail { _default_start_daemon 'getmail' ; }
|
||||||
function _start_daemon_opendkim { _default_start_daemon 'opendkim' ; }
|
function _start_daemon_opendkim { _default_start_daemon 'opendkim' ; }
|
||||||
function _start_daemon_opendmarc { _default_start_daemon 'opendmarc' ; }
|
function _start_daemon_opendmarc { _default_start_daemon 'opendmarc' ; }
|
||||||
function _start_daemon_postgrey { _default_start_daemon 'postgrey' ; }
|
function _start_daemon_postgrey { _default_start_daemon 'postgrey' ; }
|
||||||
|
|
|
@ -170,3 +170,12 @@ stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
command=/usr/bin/mta-sts-daemon --config /etc/mta-sts-daemon.yml
|
command=/usr/bin/mta-sts-daemon --config /etc/mta-sts-daemon.yml
|
||||||
user=_mta-sts
|
user=_mta-sts
|
||||||
environment=HOME=/var/lib/mta-sts
|
environment=HOME=/var/lib/mta-sts
|
||||||
|
|
||||||
|
[program:getmail]
|
||||||
|
startsecs=0
|
||||||
|
stopwaitsecs=55
|
||||||
|
autostart=false
|
||||||
|
autorestart=true
|
||||||
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
|
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||||
|
command=/bin/bash -l -c /usr/local/bin/getmail-service.sh
|
||||||
|
|
Loading…
Reference in New Issue