#!/usr/bin/with-contenv sh

if [ ! -z "$DISABLE_CLAMAV" ]; then
   echo "* ClamAV disabled"
   exit 0;
fi

if [ ! -z "$DOWNLOAD_CLAMAV_BOOTSTRAP" ]; then
    if [ ! -d /data/var/clamav ] || [ ! -f /data/var/clamav/daily.cvd ]; then
        echo "* downloading ClamAV definition files"
        if [ ! -d /data/var/clamav ]; then
            mkdir -p /data/var/clamav 2> /dev/null
        fi
        cd /data/var/clamav
        curl -s -O https://poste.io/clamav/daily.cvd &
        curl -s -O https://poste.io/clamav/main.cvd &
    else
        echo "* ClamAV files already there"
    fi
fi