流程图
下载
ClamAVNet
离线安装脚本
#扫描文件路径,程序安装路径,当然也可以全盘扫描,全盘扫描的时候路径设置为"/"即可
scanfile="/home"
#分钟 小时 日 月 年, 例:0 0 * * * 表示每天0时0秒
scantime="0 0 * * *"
#添加用户组和组成员
groupadd clamav
useradd -g clamav -s /bin/false -c "Clam AntiVirus" clamav
#执行安装命令
rpm -ivh clamav*.rpm
#创建日志和病毒库目录
mkdir /usr/local/clamav
mkdir /usr/local/clamav/logs
mkdir /usr/local/clamav/update
#创建日志文件
touch /usr/local/clamav/logs/clamd.log
touch /usr/local/clamav/logs/freshclam.log
#文件授权
chown clamav:clamav /usr/local/clamav/logs/clamd.log
chown clamav:clamav /usr/local/clamav/logs/freshclam.log
chown -R clamav:clamav /usr/local/clamav/update
#修改配置文件clamd.conf
cp -rf /usr/local/etc/clamd.conf.sample /usr/local/etc/clamd.conf
sed -i '8s|Example|#Example|' /usr/local/etc/clamd.conf
cat << EOF >> /usr/local/etc/clamd.conf
DatabaseDirectory /var/lib/clamav
EOF
#修改配置文件freshclam.conf
cp -rf /usr/local/etc/freshclam.conf.sample /usr/local/etc/freshclam.conf
sed -i '8s|Example|#Example|' /usr/local/etc/freshclam.conf
cat << EOF >> /usr/local/etc/freshclam.conf
DatabaseOwner clamav
DatabaseDirectory /var/lib/clamav
ScriptedUpdates yes
Checks 24
#PrivateMirror 127.0.0.1
EOF
mkdir /var/lib/clamav
chown -R clamav:clamav /var/lib/clamav
#上传病毒库文件到/var/lib/clamav
cp -rf *.cvd /var/lib/clamav
#启动服务并开启自启动
#systemctl start clamd@scan
#systemctl enable clamd@scan
#递归扫描home目录,并且记录日志
#clamscan -r -i /home -l /usr/local/clamav/logs/clamd.log
#创建定时运行脚本
rm -rf /usr/local/bin/timescan.sh
touch /usr/local/bin/timescan.sh
cat << EOF >> /usr/local/bin/timescan.sh
#扫描/home目录,扫描日志存入/usr/local/clamav/logs/clamd.log
clamscan -r -i /home -l /usr/local/clamav/logs/clamd.log
EOF
#按需求修改扫描路径
sed -i '2s|/home|'$scanfile'|' /usr/local/bin/timescan.sh
#添加定时任务
sed -i '/timescan.sh/d' /etc/crontab
cat << EOF >> /etc/crontab
0 0 * * * /usr/local/bin/timescan.sh
EOF
#按需求修改定时任务执行时间
#sed -i 's|0 0 * * * /usr/local/bin/timescan.sh|'$scantime' /usr/local/bin/timescan.sh|' /etc/crontab
sed -i 's|0 0 * * * /usr/local/bin/timescan.sh|'"$scantime"' /usr/local/bin/timescan.sh|' /etc/crontab
通过git下载程序和脚本一键安装
git下载地址和文件说明
https://gitcode.net/zengliguang/clamav_offline_install.git
cvd后缀的文件是病毒库
sh后缀文件是脚本
rpm后缀的是杀毒软件离线安装包
下载
git clone https://gitcode.net/zengliguang/clamav_offline_install.git
安装
进入路径
cd clamav_offline_install
执行sh脚本文件,等待完成安装
source clamav_offline_install.sh
安装完成
手动扫描
clamscan
出现下图说明安装并手动扫描成功
‘
’