From 785f4c8d75c1d2f5e7cc27e0bf1e182ca3f16d5f Mon Sep 17 00:00:00 2001 From: Frederick Ding Date: Fri, 31 Jul 2015 01:01:41 -0400 Subject: [PATCH] Fixes to wrapper entrypoint --- Dockerfile | 14 +++++++------- docker-entrypoint.sh | 8 +++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index b785acc..4fb477d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,9 @@ MAINTAINER Ding Corporation VOLUME /var/mail /config /output +ADD save-attachments.crontab /etc/cron.d/save-attachments +ADD save-attachments.sh /opt/save-attachments.sh + # install packages RUN apt-get update \ && apt-get install -y fetchmail maildrop mpack \ @@ -12,13 +15,10 @@ RUN apt-get update \ RUN maildirmake /var/mail/working \ && mkdir /var/mail/working/landing \ && mkdir /var/mail/working/extracted \ - && echo "to /var/mail/working" > /root/.mailfilter -RUN touch /var/mail/save-attachments.log - -ADD save-attachments.crontab /etc/cron.d/save-attachments -ADD save-attachments.sh /opt/save-attachments.sh -RUN chmod 0644 /etc/cron.d/save-attachments + && echo "to /var/mail/working" > /root/.mailfilter \ + && touch /var/mail/save-attachments.log \ + && chmod 0644 /etc/cron.d/save-attachments ADD docker-entrypoint.sh /opt/docker-entrypoint.sh ENTRYPOINT ["/opt/docker-entrypoint.sh"] -CMD cron && tail -f /var/mail/save-attachments.log +CMD ["cron"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 45f1d71..94e5b65 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -9,6 +9,7 @@ else mkdir /var/mail/working/landing mkdir /var/mail/working/extracted echo "to /var/mail/working" > /root/.mailfilter + touch /var/mail/save-attachments.log fi # check for user config fetchmailrc @@ -35,6 +36,7 @@ then update-ca-certificates fi +echo "$1" if [ "$1" = 'cron' ] || [ "$1" = '/opt/save-attachments.sh' ]; then if [ ! -f /root/.fetchmailrc ]; then echo "Cannot start container without .fetchmailrc" @@ -42,4 +44,8 @@ if [ "$1" = 'cron' ] || [ "$1" = '/opt/save-attachments.sh' ]; then fi fi -exec "$@" +if [ "$1" = 'cron' ]; then + exec /usr/sbin/cron && tail -f /var/mail/save-attachments.log +else + exec "$@" +fi