#!/bin/bash
CLAMD=/usr/local/sbin/clamd
if [[ -n "$1" ]]; then CLAMD=$1; fi
if [ ! -f $CLAMD ]; then  echo "$1 not found";  exit 3; fi
LOCALVERSION=`$CLAMD -V | awk '{print $2}' | cut -d \/ -f1`
CURRENTVERSION=`host -t txt current.cvd.clamav.net|cut -d \" -f 2|cut -d \: -f 1`

if [ $LOCALVERSION != $CURRENTVERSION ]; then
  echo "CLAMD ($LOCALVERSION) outdated - $CURRENTVERSION available"
  exit 2
else
  echo "CLAMD ($LOCALVERSION) is up to date"
  exit 0
fi
