Solve Fetchmail imap idle issue (#10)

* Migrate PR#1730 from tomav/docker-mailserver repo to new
docker-mailserver/docker-mailserver repo
* Resolved review comments
* Moved counter increment to have consistency between fetchmail process
and fetchmail config files
* Added tests for new fetchmail option

Co-authored-by: Georg Lauterbach <44545919+aendeavor@users.noreply.github.com>
This commit is contained in:
brainkiller 2021-01-17 10:39:09 +01:00 committed by GitHub
parent f1b6873d62
commit 061fe12aa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 206 additions and 3 deletions

View file

@ -18,6 +18,7 @@ ENABLE_SASLAUTHD="${ENABLE_SASLAUTHD:=0}"
ENABLE_SPAMASSASSIN="${ENABLE_SPAMASSASSIN:=0}"
ENABLE_SRS="${ENABLE_SRS:=0}"
FETCHMAIL_POLL="${FETCHMAIL_POLL:=300}"
FETCHMAIL_PARALLEL="${FETCHMAIL_PARALLEL:=0}"
LDAP_START_TLS="${LDAP_START_TLS:=no}"
LOGROTATE_INTERVAL="${LOGROTATE_INTERVAL:=${REPORT_INTERVAL:-daily}}"
LOGWATCH_INTERVAL="${LOGWATCH_INTERVAL:=none}"
@ -396,6 +397,7 @@ function _setup_default_vars
echo "ENABLE_SPAMASSASSIN=${ENABLE_SPAMASSASSIN}"
echo "ENABLE_SRS=${ENABLE_SRS}"
echo "FETCHMAIL_POLL=${FETCHMAIL_POLL}"
echo "FETCHMAIL_PARALLEL=${FETCHMAIL_PARALLEL}"
echo "LDAP_START_TLS=${LDAP_START_TLS}"
echo "LOGROTATE_INTERVAL=${LOGROTATE_INTERVAL}"
echo "LOGWATCH_INTERVAL=${LOGWATCH_INTERVAL}"
@ -2068,9 +2070,46 @@ function _start_daemons_dovecot
function _start_daemons_fetchmail
{
_notify 'task' 'Starting fetchmail' 'n'
_notify 'task' 'Preparing fetchmail config'
/usr/local/bin/setup-fetchmail
supervisorctl start fetchmail
if [[ ${FETCHMAIL_PARALLEL} -eq 1 ]]
then
mkdir /etc/fetchmailrc.d/
/usr/local/bin/fetchmailrc_split
COUNTER=0
for RC in /etc/fetchmailrc.d/fetchmail-*.rc
do
COUNTER=$((COUNTER+1))
cat <<EOF > "/etc/supervisor/conf.d/fetchmail-${COUNTER}.conf"
[program:fetchmail-${COUNTER}]
startsecs=0
autostart=false
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
user=fetchmail
command=/usr/bin/fetchmail -f ${RC} -v --nodetach --daemon %(ENV_FETCHMAIL_POLL)s -i /var/lib/fetchmail/.fetchmail-UIDL-cache --pidfile /var/run/fetchmail/%(program_name)s.pid
EOF
chmod 700 "${RC}"
chown fetchmail:root "${RC}"
done
supervisorctl reread
supervisorctl update
COUNTER=0
for _ in /etc/fetchmailrc.d/fetchmail-*.rc
do
COUNTER=$((COUNTER+1))
_notify 'task' "Starting fetchmail instance ${COUNTER}" 'n'
supervisorctl start "fetchmail-${COUNTER}"
done
else
_notify 'task' 'Starting fetchmail' 'n'
supervisorctl start fetchmail
fi
}
function _start_daemons_clamav