#!/bin/bash #SYN-3 clamav updater and monitoring #(C)2010 DatuX OUTPUT=/tmp/syn3clam.$$ trap "rm '$OUTPUT'" 0 #update scanner freshclam &> $OUTPUT EXIT=$? #update when ok? if grep -v 'Clamd was NOT notified' $OUTPUT | grep "^WARNING: " >/dev/null; then MSG="`grep '^WARNING: ' $OUTPUT`" elif [ "$EXIT" != "0" ] && [ "$EXIT" != "1" ]; then MSG="Error while updating virus scanner." fi #create test virus cat /usr/share/clamav/eicar.com.1 /usr/share/clamav/eicar.com.2 > /tmp/clamavtest chmod 555 /tmp/clamavtest #use deamon or not? if netstat -na|grep /var/run/clamav/clamd >/dev/null; then CLAM=clamdscan else CLAM=clamscan fi #test scanner if $CLAM /bin/bash /tmp/clamavtest | grep -x 'Infected files: 1' >/dev/null; then syn3-state clamav OK "Virus scanner self-test was OK. $MSG" else syn3-state clamav CAUTION "Virus scanner self-test failed. $MSG" fi rm /tmp/clamavtest