[[ $DEBUG == 1 ]] && set -x

AntiVirus_Setup() {

SECFILE=/etc/slossec.conf
[ -f "$SECFILE" ] && source ${SECFILE} 

if [[ $antivirus -eq 1 ]] ; then
    log "SLOSSecurity: Antivirus Setup"
    $DIALOG --backtitle "$BT" --title "Antivirus Security" --infobox "Antivirus Setup, check Log /var/log/uvscan" $H1 $W1
    sleep $autoTO
else
    log "SLOSSecurity: AntiVirus Setup NOT performed"
    return
fi

    mkdir -p /root/install
    if ! rpm -q --quiet vscl && ! rpm -q --quiet cronie ; then 
        yum -y install vscl cronie
        if [ $? -ne 0 ] ; then
            log "SLOSSecurity: Failed to install antivirus - vscl, cron pkg's"
            return
        fi
    fi 
    # To run in background as it takes long time.
    #/usr/sbin/avvdat -a && UVNICE=15 UVTARGET=/ /usr/sbin/uvscan-job &

    CRONTAB=/etc/crontab
    CRONDIRS='/etc/cron.d /etc/cron.daily /etc/cron.weekly /etc/cron.monthly'

    if [ -f /var/spool/cron/root ]; then
        VARSPOOL=/var/spool/cron/root
    fi

    if ! egrep -qR 'uvscan|avvdat -a' $CRONTAB $VARSPOOL $CRONDIRS; then
        crontab -l > /tmp/mycron
        echo '0 6 * * * /usr/sbin/avvdat -a ; UVNICE=15 UVTARGET=/ /usr/sbin/uvscan-job ; cat $(ls -tr /var/log/uvscan/*.log |tail -1) | /bin/mail -s "$(hostname) - VSCL: Antivirus Scan Update " root@localhost < $(ls -tr /var/log/uvscan/*.log |tail -1)' >> /tmp/mycron

        crontab /tmp/mycron
    fi
    show "SLOSSecurity: Antivirus Setup: CronJob enabled for Antivirus update and Scan. Check logs at /var/log/uvscan/"

    sed -i "s/antivirus=1/antivirus=0/g" $SECFILE 2>/dev/null
    log "Antivirus Setup Completed"
}

AntiVirus_Setup
