#!/bin/bash set -e NAME="CLAMAV" function stop { echo "Stopping ${NAME}" kill $(cat /var/run/clamd.pid) kill $(cat /var/run/clamav-milter.pid) } trap 'stop' SIGTERM if [ "$1" == "start" ]; then [ -x /usr/sbin/clamd -a -x /usr/bin/freshclam ] && /usr/bin/freshclam --config-file=/etc/clamav/freshclam.conf && /usr/sbin/clamd -c /etc/clamav/clamd.conf [ -x /usr/sbin/clamav-milter ] && /usr/sbin/clamav-milter -c /etc/clamav/clamav-milter.conf & wait else exec $@ fi