Richard G
Verified User
I got this somehwere, maybe from the site of Zeiter or somewhere else, but after the clamav change it does not work anymore and throws a "clamd service not running"
I already changed some binary paths, but I think for clamd it still is not correct.
I'm no coder. What I do see is this:
Now there is a /sbin/clamd present, however, the service is now called clam@scan and the other service is called clamav-freshlam and now I don't know which service needs to be checked.
Also the first part, checking if the clamd service is running, might not be correct.
However, the clamd service is running.
So probably the check if it running is wrong now.
I think somewhere the "if" statement or something which checks if clamd is running needs to be changed.
Can anyone help me fixing this?
I already changed some binary paths, but I think for clamd it still is not correct.
Code:
#!/bin/sh
# path to an empty dummy test file
testfile="/usr/local/directadmin/scripts/custom/clamav.txt"
# path to the clamav database files without the ending "/"
dbfolder="/var/lib/clamav"
# path to the clamdscan executable
scan="/usr/bin/clamdscan"
# path to the freshclam executable
freshdb="/usr/bin/freshclam"
# number of times the script tries to kick start clamd
trial=10
# email of server administrator
email="[email protected]"
# server hostname (no modification needed)
myhost=$(hostname)
# email alert subject on failure
subject="Clamd on ${myhost} is down!"
# email alert body message on failure
message="Clamd on ${myhost} is down!"
output=$($scan $testfile | grep "SCAN SUMMARY")
if [ -z "$output" ]; then
echo "Clamd is not running!"
echo "Now trying to start clamd..."
for (( i=1; i<=$trial; i++ ))
do
echo "Trial $i..."
/sbin/service clamd restart
output=$($scan $testfile | grep "SCAN SUMMARY")
if [ -n "$output" ]; then
break
else
sleep 3
fi
done
if [ -z "$output" ]; then
echo "Clamd is still not running!"
echo "Now trying to refresh clamav database..."
rm -Rf $dbfolder/*
$freshdb
/sbin/service clamd restart
output=$($scan $testfile | grep "SCAN SUMMARY")
if [ -z "$output" ]; then
echo "Clamd is still not running!"
echo "$message" | mail -s "$subject" "$email"
echo "Giving up... email alert has been sent to administrator."
else
echo "Clamd is running now!"
fi
else
echo "Clamd is running now!"
fi
else
echo "Clamd is running!"
fi
I'm no coder. What I do see is this:
/sbin/service clamd restart
Now there is a /sbin/clamd present, however, the service is now called clam@scan and the other service is called clamav-freshlam and now I don't know which service needs to be checked.
Also the first part, checking if the clamd service is running, might not be correct.
However, the clamd service is running.
Code:
[root@server23: /sbin]# ps faux | grep clamd
clamscan 17003 0.1 2.1 1826380 1391496 ? Ssl 00:16 1:24 /usr/sbin/clamd -c /etc/clamd.d/scan.conf
So probably the check if it running is wrong now.
I think somewhere the "if" statement or something which checks if clamd is running needs to be changed.
Can anyone help me fixing this?