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.
This commit is contained in:
Daniel Panteleit 2017-03-14 15:22:19 +01:00 committed by Thomas VIAL
parent cb0714ff77
commit e7efeda036
3 changed files with 20 additions and 2 deletions

View file

@ -1,6 +1,10 @@
FROM ubuntu:14.04 FROM ubuntu:14.04
MAINTAINER Thomas VIAL MAINTAINER Thomas VIAL
# Default values
ENV VIRUSMAILS_DELETE_DELAY=7 \
ONE_DIR=0
# Packages # Packages
RUN DEBIAN_FRONTEND=noninteractive apt-get update -q --fix-missing && \ RUN DEBIAN_FRONTEND=noninteractive apt-get update -q --fix-missing && \
apt-get -y upgrade && \ apt-get -y upgrade && \

View file

@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
echo "Wipping virus older than $VIRUSMAILS_DELETE_DELAY days"
find /var/lib/amavis/virusmails/ -type f -mtime +$VIRUSMAILS_DELETE_DELAY -delete find /var/lib/amavis/virusmails/ -type f -mtime +$VIRUSMAILS_DELETE_DELAY -delete

View file

@ -20,7 +20,6 @@ DEFAULT_VARS["POSTGREY_MAX_AGE"]="${POSTGREY_MAX_AGE:="35"}"
DEFAULT_VARS["POSTGREY_TEXT"]="${POSTGREY_TEXT:="Delayed by postgrey"}" DEFAULT_VARS["POSTGREY_TEXT"]="${POSTGREY_TEXT:="Delayed by postgrey"}"
DEFAULT_VARS["ENABLE_SASLAUTHD"]="${ENABLE_SASLAUTHD:="0"}" DEFAULT_VARS["ENABLE_SASLAUTHD"]="${ENABLE_SASLAUTHD:="0"}"
DEFAULT_VARS["SMTP_ONLY"]="${SMTP_ONLY:="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["DMS_DEBUG"]="${DMS_DEBUG:="0"}"
DEFAULT_VARS["OVERRIDE_HOSTNAME"]="${OVERRIDE_HOSTNAME}" DEFAULT_VARS["OVERRIDE_HOSTNAME"]="${OVERRIDE_HOSTNAME}"
########################################################################## ##########################################################################
@ -122,6 +121,8 @@ function register_functions() {
_register_setup_function "_setup_postfix_virtual_transport" _register_setup_function "_setup_postfix_virtual_transport"
fi fi
_register_setup_function "_setup_environment"
################### << setup funcs ################### << setup funcs
################### >> fix funcs ################### >> fix funcs
@ -909,6 +910,20 @@ function _setup_elk_forwarder() {
| sed "s@\$ELK_PORT@$ELK_PORT@g" \ | sed "s@\$ELK_PORT@$ELK_PORT@g" \
> /etc/filebeat/filebeat.yml > /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 # << Setup Stack
########################################################################## ##########################################################################