From ace2493f66a6cc39ea406180ab7d7f8aa21ade88 Mon Sep 17 00:00:00 2001 From: Jon Lockwood Date: Mon, 14 Feb 2022 09:53:57 +0930 Subject: [PATCH] feat(fetchmail): added fetchmail cron job to run fetchmail script to get fetchmail config from roundcube mysql database. MR !1 --- dockerfile | 22 ++++++++++++++++++ include/docker-entrypoint.sh | 2 ++ include/etc/cron.d/fetchmail | 7 ++++++ include/etc/mail/postfixadmin/fetchmail.conf | 24 ++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 include/etc/cron.d/fetchmail create mode 100644 include/etc/mail/postfixadmin/fetchmail.conf diff --git a/dockerfile b/dockerfile index fe8bb1f..09edde1 100644 --- a/dockerfile +++ b/dockerfile @@ -43,6 +43,21 @@ RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y --no-install-recommends libmailtools-perl=2.21-1 \ fam=2.7.0-17.3 \ libnet-dns-perl=1.29-1 \ + # Fetchmail + fetchmail=6.4.16-4+deb11u1 \ + # Perl Modules for fetchmail.pl + # DBI + libdbix-easy-perl \ + # LockFile::Simple + liblockfile-simple-perl \ + # DBD::mysql + libclass-dbi-mysql-perl \ + # Sys::Syslog + liblogger-syslog-perl \ + # LockFile::Simple + libio-lockedfile-perl + + # Cleanup, remove cron jobs not required RUN rm -f /etc/cron.d/e2scrub_all \ && rm -f /etc/cron.daily/apt-compat \ @@ -88,6 +103,13 @@ RUN chmod +x /docker-entrypoint.sh \ # Spammassassin related Commands && mkdir -p /var/spool/spamassassin \ && chmod 777 /var/spool/spamassassin \ + # Ensure spamassassin related scripts are executable + && chmod +x /bin/spam-learn.sh \ + # fetchmail.pl setup + && curl -o /bin/fetchmail.pl https://raw.githubusercontent.com/postfixadmin/postfixadmin/8f20c96278a694a7e0bb570f1d56c208105e5a14/ADDITIONS/fetchmail.pl \ + && chmod +x /bin/fetchmail.pl \ + && mkdir -p /var/run/fetchmail \ + && mkdir -p /var/lock/fetchmail # Setup data volumes diff --git a/include/docker-entrypoint.sh b/include/docker-entrypoint.sh index 72a7914..0bb9ea0 100644 --- a/include/docker-entrypoint.sh +++ b/include/docker-entrypoint.sh @@ -31,6 +31,8 @@ do done +mkdir -p /var/lock/fetchmail + if [ "$1" == "setup" ]; then diff --git a/include/etc/cron.d/fetchmail b/include/etc/cron.d/fetchmail new file mode 100644 index 0000000..010990f --- /dev/null +++ b/include/etc/cron.d/fetchmail @@ -0,0 +1,7 @@ +# +# SpamAssassin Bayes learning from mailboxes +# +# m h dom mon dow user command +#1,31 * * * * root if [ "0$USE_FETCHMAIL_PL" != "0" ]; then /bin/fetchmail.pl 2>&1; fi +1,31 * * * * root if [ "0$USE_FETCHMAIL_PL" != "0" ]; then echo /bin/fetchmail.pl 2>&1; fi + diff --git a/include/etc/mail/postfixadmin/fetchmail.conf b/include/etc/mail/postfixadmin/fetchmail.conf new file mode 100644 index 0000000..19fc794 --- /dev/null +++ b/include/etc/mail/postfixadmin/fetchmail.conf @@ -0,0 +1,24 @@ +# database settings + +# database backend - uncomment one of these +our $db_type = 'mysql'; +#my $db_type = 'mysql'; + +# host name +our $db_host="mysql"; +# database name +our $db_name="roundcube"; +# database username +our $db_username="roundcube"; +# database password +our $db_password="roundcube"; + +# Where to create a lockfile; please ensure path exists. +our $run_dir="/var/lock/fetchmail"; + +# in case you want to use dovecot deliver to put the mail directly into the users mailbox, +# set "mda" in the fetchmail table to the keyword "dovecot". + +# Where the delivery binary is located +$dovecot_deliver = "/usr/lib/dovecot/dovecot-lda"; +