From 6c9901e2603a7ec5c0ff203f1abfa21880f20c69 Mon Sep 17 00:00:00 2001 From: Josef Friedrich Date: Mon, 29 Aug 2016 19:03:45 +0200 Subject: [PATCH] Improve fetchmail support (#289) Fetchmail is now configured by a script called 'setup-fetchmail'. The script 'debug-fetchmail' is used inside the 'setup.sh' script. --- Dockerfile | 2 +- setup.sh | 4 ++-- target/bin/debug-fetchmail | 10 ++++++++++ target/bin/setup-fetchmail | 18 ++++++++++++++++++ target/start-mailserver.sh | 4 +--- 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100755 target/bin/debug-fetchmail create mode 100755 target/bin/setup-fetchmail diff --git a/Dockerfile b/Dockerfile index 0e2c1648..412fde23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,7 @@ RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > /et curl -s https://letsencrypt.org/certs/lets-encrypt-x2-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x2-cross-signed.pem # Start-mailserver script -ADD target/bin/generate-ssl-certificate target/bin/generate-dkim-config target/bin/addmailuser target/bin/delmailuser target/bin/listmailuser target/start-mailserver.sh /usr/local/bin/ +ADD target/bin/generate-ssl-certificate target/bin/generate-dkim-config target/bin/addmailuser target/bin/delmailuser target/bin/listmailuser target/bin/setup-fetchmail target/bin/debug-fetchmail target/start-mailserver.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/* EXPOSE 25 587 143 993 110 995 4190 diff --git a/setup.sh b/setup.sh index 430b6e8a..b47711c6 100755 --- a/setup.sh +++ b/setup.sh @@ -26,7 +26,7 @@ SUBCOMMANDS: debug: - $0 debug fetchmail (not yet implemented) + $0 debug fetchmail " exit 1 } @@ -84,7 +84,7 @@ case $1 in shift case $1 in fetchmail) - _docker sh -c "cat /etc/fetchmailrc_general /tmp/docker-mailserver/fetchmail.cf > /etc/fetchmailrc; /etc/init.d/fetchmail debug-run" + _docker debug-fetchmail ;; esac ;; diff --git a/target/bin/debug-fetchmail b/target/bin/debug-fetchmail new file mode 100755 index 00000000..6fe5b870 --- /dev/null +++ b/target/bin/debug-fetchmail @@ -0,0 +1,10 @@ +#! /bin/sh + +/usr/local/bin/setup-fetchmail + +su -s /bin/sh -c "/usr/bin/fetchmail \ + --verbose \ + --daemon 0 \ + --nosyslog \ + --nodetach \ + -f /etc/fetchmailrc" fetchmail <&- 2>&1 diff --git a/target/bin/setup-fetchmail b/target/bin/setup-fetchmail new file mode 100755 index 00000000..45eb92a4 --- /dev/null +++ b/target/bin/setup-fetchmail @@ -0,0 +1,18 @@ +#! /bin/sh + +CONF=/tmp/docker-mailserver/fetchmail.cf +RC=/etc/fetchmailrc + +if [ -f "$RC" ]; then + echo "The Fetchmail configuration is file '$RC' is already generated." + exit 0 +fi + +if [ -f "$CONF" ]; then + cat /etc/fetchmailrc_general $CONF > $RC +else + cat /etc/fetchmailrc_general > $RC +fi + +chmod 700 $RC +chown fetchmail:root $RC diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index f70ab9e8..e96422b8 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -361,9 +361,7 @@ fi # Enable fetchmail daemon if [ "$ENABLE_FETCHMAIL" = 1 ]; then - if [ -f /tmp/docker-mailserver/fetchmail.cf ]; then - cat /etc/fetchmailrc_general /tmp/docker-mailserver/fetchmail.cf > /etc/fetchmailrc - fi + /usr/local/bin/setup-fetchmail echo "Fetchmail enabled" /etc/init.d/fetchmail start fi