#!/bin/sh
#
# Configure Clam AV 
#
echo "Configuring Anti-Virus scanner..."

# Create clamav.log
CLAMAV_LOG="/var/log/clamav.log"
if [ ! -e $CLAMAV_LOG ]; then
	touch $CLAMAV_LOG
fi
chmod 640 $CLAMAV_LOG
chown _amavisd:admin $CLAMAV_LOG

# Creage freshclam.log
FRESHCLAM_LOG="/var/log/freshclam.log"
if [ ! -e $FRESHCLAM_LOG ]; then
	touch $FRESHCLAM_LOG
fi
chmod 640 $FRESHCLAM_LOG
chown _clamav:admin $FRESHCLAM_LOG

CLAMAV_LOG="/var/log/clamav.log"
if [ ! -e $CLAMAV_LOG ]; then
        touch $CLAMAV_LOG
fi
chmod 640 $CLAMAV_LOG
chown _amavisd:admin $CLAMAV_LOG

CLAMAV_DIR=/var/clamav
if [ ! -d $CLAMAV_DIR ]; then
	mkdir $CLAMAV_DIR
	chown _clamav:_clamav $CLAMAV_DIR
fi

# Set clamav home to /var/clamav
`/usr/bin/dscl . -create /Users/_clamav NFSHomeDirectory /var/clamav`
`/usr/bin/dscl . -append /Groups/_amavisd GroupMembership _clamav`

echo "done."
