linux版的查毒工具 ClamAv 安装脚本
#/bin/bash
##安装linux版的查毒工具 clamav
#用root执行
#保证服务器能访问外网
#yum源最好是最新的
#创建用户和组
groupadd clamav
useradd -g clamav clamav
#安装一些依赖库
yum -y install bzip2 bzip2-devel libbz2 libbz2-devel gcc* openssl openssl-devel
#下载clamav安装包,如果网速慢可以先下载再上传,上传文件必须跟脚本同一目录
wget http://www.clamav.net/downloads/production/clamav-0.99.2.tar.gz
tar zxf clamav-0.99.2.tar.gz
cd clamav-0.99.2
./configure --prefix=/home/clamav/clamav --disable-zlib-vcheck
#判断上一步是否执行成功
if [ $? -ne 0 ];
then
echo "configure失败!!"
exit 1
fi
make
if [ $? -ne 0 ];
then
echo "make 失败!!"
exit 1
fi
make install
if [ $? -ne 0 ];
then
echo "make install 失败!!"
exit 1
fi
#删除安装包
cd ../
rm -rf clamav-0.99.2*
#创建日志和病毒库目录
mkdir /home/clamav/clamav/logs
touch /home/clamav/clamav/logs/clamd.log
touch /home/clamav/clamav/logs/freshclam.log
mkdir /home/clamav/clamav/updata
#授权
chown -R root.clamav /home/clamav/clamav
chown -R clamav.clamav /home/clamav/clamav/updata
chown clamav.clamav /home/clamav/clamav/logs/clamd.log
chown clamav.clamav /home/clamav/clamav/logs/freshclam.log
cp /home/clamav/clamav/etc/clamd.conf.sample /home/clamav/clamav/etc/clamd.conf
cp /home/clamav/clamav/etc/freshclam.conf.sample /home/clamav/clamav/etc/freshclam.conf
#修改配置文件
sed -i -e "s/^Example/#Example/" /home/clamav/clamav/etc/clamd.conf
sed -i '/#LogFile /aLogFile /home/clamav/clamav/logs/clamd.log' /home/clamav/clamav/etc/clamd.conf
sed -i '/#PidFile /aPidFile /home/clamav/clamav/updata/clamd.pid' /home/clamav/clamav/etc/clamd.conf
sed -i '/#DatabaseDirectory /aDatabaseDirectory /home/clamav/clamav/updata' /home/clamav/clamav/etc/clamd.conf
sed -i -e "s/^Example/#Example/" /home/clamav/clamav/etc/freshclam.conf
sed -i '/#DatabaseDirectory /aDatabaseDirectory /home/clamav/clamav/updata' /home/clamav/clamav/etc/freshclam.conf
sed -i '/#UpdateLogFile /aUpdateLogFile /home/clamav/clamav/logs/freshclam.log' /home/clamav/clamav/etc/freshclam.conf
sed -i '/#PidFile /aPidFile /home/clamav/clamav/updata/freshclam.pid' /home/clamav/clamav/etc/freshclam.conf
#升级病毒库,此过程有点慢
/home/clamav/clamav/bin/freshclam
if [ $? -ne 0 ];
then
echo "升级病毒库失败!!"
exit 1
else
echo "clamav已经安装完成,请查毒!"
fi
##################到此clamav安装完成########################
:<<eof
查看使用帮助:
/home/clamav/clamav/bin/clamscan -h
下面举两条例子:
扫描某个目录(如:/home):
clamscan -r /home
扫描服务器上的所有文件并且显示所有的文件的扫描结果
clamscan -r /
扫描服务器上的所有文件并且显示有问题的文件的扫描结果
clamscan -r --bell -i /
可以做个定时任务让他定时更新病毒库,定时扫描查毒。比如:
crontab -e
#每周日一点更新病毒库
0 1 * * 7 /home/clamav/clamav/bin/freshclam
#每周一到周六一点查毒
0 1 * * 1-6 /home/clamav/clamav/bin/clamscan -r --bell -i / -l /home/clamav/clamav/logs/clamd.log
eof
本文来自博客园,作者:愤怒的小白~,转载请注明原文链接:https://www.cnblogs.com/mgsudu/p/8252541.html