mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-07-25 13:14:56 +02:00
feature: adding getmail
as an alternative to fetchmail
(#2803)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> Co-authored-by: Casper <casperklein@users.noreply.github.com>
This commit is contained in:
parent
abd72b6f10
commit
7af7546d88
16 changed files with 320 additions and 3 deletions
|
@ -201,6 +201,21 @@ function _install_fail2ban
|
|||
sedfile -i -r 's/^_nft_add_set = .+/_nft_add_set = <nftables> add set <table_family> <table> <addr_set> \\{ type <addr_type>\\; flags interval\\; \\}/' /etc/fail2ban/action.d/nftables.conf
|
||||
}
|
||||
|
||||
# Presently the getmail6 package is v6.14, which is too old.
|
||||
# v6.18 contains fixes for Google and Microsoft OAuth support.
|
||||
# using pip to install getmail.
|
||||
# TODO This can be removed when the base image is updated to Debian 12 (Bookworm)
|
||||
function _install_getmail
|
||||
{
|
||||
_log 'debug' 'Installing getmail6'
|
||||
apt-get "${QUIET}" --no-install-recommends install python3-pip
|
||||
pip3 install --no-cache-dir 'getmail6~=6.18.12'
|
||||
ln -s /usr/local/bin/getmail /usr/bin/getmail
|
||||
ln -s /usr/local/bin/getmail-gmail-xoauth-tokens /usr/bin/getmail-gmail-xoauth-tokens
|
||||
apt-get "${QUIET}" purge python3-pip
|
||||
apt-get "${QUIET}" autoremove
|
||||
}
|
||||
|
||||
function _remove_data_after_package_installations
|
||||
{
|
||||
_log 'debug' 'Deleting sensitive files (secrets)'
|
||||
|
@ -225,5 +240,6 @@ _install_packages
|
|||
_install_dovecot
|
||||
_install_rspamd
|
||||
_install_fail2ban
|
||||
_install_getmail
|
||||
_remove_data_after_package_installations
|
||||
_post_installation_steps
|
||||
|
|
|
@ -97,6 +97,8 @@ function _register_functions
|
|||
# needs to come after _setup_postfix_early
|
||||
_register_setup_function '_setup_spoof_protection'
|
||||
|
||||
_register_setup_function '_setup_getmail'
|
||||
|
||||
if [[ ${ENABLE_SRS} -eq 1 ]]
|
||||
then
|
||||
_register_setup_function '_setup_SRS'
|
||||
|
|
42
target/scripts/startup/setup.d/getmail.sh
Normal file
42
target/scripts/startup/setup.d/getmail.sh
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
function _setup_getmail
|
||||
{
|
||||
if [[ ${ENABLE_GETMAIL} -eq 1 ]]
|
||||
then
|
||||
_log 'trace' 'Preparing Getmail configuration'
|
||||
|
||||
local GETMAILRC ID CONFIGS
|
||||
|
||||
GETMAILRC='/etc/getmailrc.d'
|
||||
CONFIGS=0
|
||||
|
||||
mkdir -p "${GETMAILRC}"
|
||||
|
||||
# Generate getmailrc configs, starting with the `/etc/getmailrc_general` base config,
|
||||
# Add a unique `message_log` config, then append users own config to the end.
|
||||
for FILE in /tmp/docker-mailserver/getmail-*.cf
|
||||
do
|
||||
if [[ -f ${FILE} ]]
|
||||
then
|
||||
CONFIGS=1
|
||||
ID=$(cut -d '-' -f 3 <<< "${FILE}" | cut -d '.' -f 1)
|
||||
local GETMAIL_CONFIG="${GETMAILRC}/getmailrc-${ID}"
|
||||
cat /etc/getmailrc_general >"${GETMAIL_CONFIG}.tmp"
|
||||
echo -e "message_log = /var/log/mail/getmail-${ID}.log\n" >>"${GETMAIL_CONFIG}.tmp"
|
||||
cat "${GETMAIL_CONFIG}.tmp" "${FILE}" >"${GETMAIL_CONFIG}"
|
||||
rm "${GETMAIL_CONFIG}.tmp"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${CONFIGS} -eq 1 ]]
|
||||
then
|
||||
cat >/etc/cron.d/getmail << EOF
|
||||
*/${GETMAIL_POLL} * * * * root /usr/local/bin/getmail-cron
|
||||
EOF
|
||||
chmod -R 600 "${GETMAILRC}"
|
||||
fi
|
||||
else
|
||||
_log 'debug' 'Getmail is disabled'
|
||||
fi
|
||||
}
|
|
@ -25,6 +25,7 @@ function _setup_save_states
|
|||
[[ ${ENABLE_CLAMAV} -eq 1 ]] && SERVICEDIRS+=('lib/clamav')
|
||||
[[ ${ENABLE_FAIL2BAN} -eq 1 ]] && SERVICEDIRS+=('lib/fail2ban')
|
||||
[[ ${ENABLE_FETCHMAIL} -eq 1 ]] && SERVICEDIRS+=('lib/fetchmail')
|
||||
[[ ${ENABLE_GETMAIL} -eq 1 ]] && SERVICEDIRS+=('lib/getmail')
|
||||
[[ ${ENABLE_POSTGREY} -eq 1 ]] && SERVICEDIRS+=('lib/postgrey')
|
||||
[[ ${ENABLE_RSPAMD} -eq 1 ]] && SERVICEDIRS+=('lib/rspamd')
|
||||
[[ ${ENABLE_RSPAMD_REDIS} -eq 1 ]] && SERVICEDIRS+=('lib/redis')
|
||||
|
|
|
@ -74,6 +74,7 @@ function __environment_variables_general_setup
|
|||
VARS[ENABLE_DNSBL]="${ENABLE_DNSBL:=0}"
|
||||
VARS[ENABLE_FAIL2BAN]="${ENABLE_FAIL2BAN:=0}"
|
||||
VARS[ENABLE_FETCHMAIL]="${ENABLE_FETCHMAIL:=0}"
|
||||
VARS[ENABLE_GETMAIL]="${ENABLE_GETMAIL:=0}"
|
||||
VARS[ENABLE_MANAGESIEVE]="${ENABLE_MANAGESIEVE:=0}"
|
||||
VARS[ENABLE_OPENDKIM]="${ENABLE_OPENDKIM:=1}"
|
||||
VARS[ENABLE_OPENDMARC]="${ENABLE_OPENDMARC:=1}"
|
||||
|
@ -125,6 +126,7 @@ function __environment_variables_general_setup
|
|||
VARS[ACCOUNT_PROVISIONER]="${ACCOUNT_PROVISIONER:=FILE}"
|
||||
VARS[FETCHMAIL_PARALLEL]="${FETCHMAIL_PARALLEL:=0}"
|
||||
VARS[FETCHMAIL_POLL]="${FETCHMAIL_POLL:=300}"
|
||||
VARS[GETMAIL_POLL]="${GETMAIL_POLL:=5}"
|
||||
VARS[LOG_LEVEL]="${LOG_LEVEL:=info}"
|
||||
VARS[LOGROTATE_INTERVAL]="${LOGROTATE_INTERVAL:=weekly}"
|
||||
VARS[LOGWATCH_INTERVAL]="${LOGWATCH_INTERVAL:=none}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue