(clamAV安装脚本)

clamAV安装脚本

#!/bin/bash
echo "install ClamAV"
yum -y update
yum -y install wget

# https://www.clamav.net/downloads 根据需求换新版本下载地址
#下载 clamAV
wget -U NoSuchBrowser/1.0 https://www.clamav.net/downloads/production/clamav-0.104.1.linux.x86_64.rpm
yum -y install clamav-0.104.1.linux.x86_64.rpm

#配置用户、权限
groupadd clamav
useradd -g clamav -s /bin/false -c "Clam Antivirus" clamav

sudo chown -R clamav /usr/local/share/clamav

#配置文件生成、初始化
clamconf -g clamd.conf > /usr/local/etc/clamd.conf
clamconf -g freshclam.conf > /usr/local/etc/freshclam.conf
clamconf -g clamav-milter.conf > /usr/local/etc/clamav-milter.conf

#修改配置文件
sed -i 's/^Example.*$/#Example/g' /usr/local/etc/clamd.conf
sed -i 's/^Example.*$/#Example/g' /usr/local/etc/freshclam.conf
sed -i 's/^Example.*$/#Example/g' /usr/local/etc/clamav-milter.conf

sed -i 's/^#DatabaseMirror.*$/DatabaseMirror db.cn.clamav.net/g' /usr/local/etc/freshclam.conf

freshclam

#配置自动更新
freshclam -d
echo '/usr/bin/freshclam -d' >> /etc/rc.local

#测试扫描
clamscan -rzi --quiet -l /tmp/clamscan_$(date +%s).log /boot

#清除缓存
rm -f clamav-0.104.1.linux.x86_64.rpm