From e7efeda036c358462879c68d8002731df34aff6e Mon Sep 17 00:00:00 2001 From: Daniel Panteleit Date: Tue, 14 Mar 2017 15:22:19 +0100 Subject: [PATCH] Fixed virus-wiper script when using the default value for VIRUSMAILS_DELETE_DELAY (#540) Moved variable VIRUSMAILS_DELETE_DELAY to Dockerfile. This variable will be written to /etc/environment in the start script to make it visible to cron. Also removed echo in cron job to prevent sending mail for each run. --- Dockerfile | 4 ++++ target/bin/virus-wiper | 1 - target/start-mailserver.sh | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29e2da6c..878dab21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ FROM ubuntu:14.04 MAINTAINER Thomas VIAL +# Default values +ENV VIRUSMAILS_DELETE_DELAY=7 \ + ONE_DIR=0 + # Packages RUN DEBIAN_FRONTEND=noninteractive apt-get update -q --fix-missing && \ apt-get -y upgrade && \ diff --git a/target/bin/virus-wiper b/target/bin/virus-wiper index c9a5f336..279085ba 100644 --- a/target/bin/virus-wiper +++ b/target/bin/virus-wiper @@ -1,4 +1,3 @@ #!/bin/bash -echo "Wipping virus older than $VIRUSMAILS_DELETE_DELAY days" find /var/lib/amavis/virusmails/ -type f -mtime +$VIRUSMAILS_DELETE_DELAY -delete diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index cfe6efbf..9797a2b5 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -20,7 +20,6 @@ DEFAULT_VARS["POSTGREY_MAX_AGE"]="${POSTGREY_MAX_AGE:="35"}" DEFAULT_VARS["POSTGREY_TEXT"]="${POSTGREY_TEXT:="Delayed by postgrey"}" DEFAULT_VARS["ENABLE_SASLAUTHD"]="${ENABLE_SASLAUTHD:="0"}" DEFAULT_VARS["SMTP_ONLY"]="${SMTP_ONLY:="0"}" -DEFAULT_VARS["VIRUSMAILS_DELETE_DELAY"]="${VIRUSMAILS_DELETE_DELAY:="7"}" DEFAULT_VARS["DMS_DEBUG"]="${DMS_DEBUG:="0"}" DEFAULT_VARS["OVERRIDE_HOSTNAME"]="${OVERRIDE_HOSTNAME}" ########################################################################## @@ -122,6 +121,8 @@ function register_functions() { _register_setup_function "_setup_postfix_virtual_transport" fi + _register_setup_function "_setup_environment" + ################### << setup funcs ################### >> fix funcs @@ -909,6 +910,20 @@ function _setup_elk_forwarder() { | sed "s@\$ELK_PORT@$ELK_PORT@g" \ > /etc/filebeat/filebeat.yml } + +function _setup_environment() { + notify 'task' 'Setting up /etc/environment' + + local banner="# docker environment" + local var + if ! grep -q "$banner" /etc/environment; then + echo $banner >> /etc/environment + for var in "VIRUSMAILS_DELETE_DELAY"; do + echo "$var=${!var}" >> /etc/environment + done + fi +} + ########################################################################## # << Setup Stack ##########################################################################