#!/bin/bash

   DOMO_IP="localhost"             # Domoticz IP Address
   DOMO_PORT="81"                    # Domoticz Port
   IDX=330

lockfile-create --lock-name "/tmp/clamscandomoticz.lockfile"
nice -n 12 clamscan -r -i --max-filesize=100M --exclude "\.(CR2|TIF|tif|img|IMG|mp4|mp3|mov|flv|mkv|avi|AVI|MKV|MP4|MP3|MOV|mpg|MPG|jpg|JPG|nfo|png|PNG|html|htm|HTM|HTML|idx|gif|txt|TXT)$" --cross-fs=no /opt/domoticz/ >/tmp/clamscanDomoticz.txt

virus=`cat /tmp/clamscanDomoticz.txt |grep FOUND|wc -l`

curl -y 1 -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$IDX&nvalue=0&svalue=$virus" &

lockfile-remove --lock-name "/tmp/clamscandomoticz.lockfile"
exit 0
