Clamav 流程圖和一鍵安裝腳本


clamav流程圖

image.png

一鍵安裝

搭建clamav雳灵,并監(jiān)聽clamd服務(wù),發(fā)布對(duì)外調(diào)用接口

#!/bin/bash
## Date:                2018-09-25
## Author               Browser
## Describtion          Install clamav
## Version:             1.0

ADDRESS=ip addr | grep "inet" | grep -v "inet6" | grep -v "127.0.0.1" | awk -F '[ /]+' '{print $3}'

###dependence
yum -y install wget unzip zip gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel llvm-devel libxml2 libxml2-devel libcurl-devel 

###download and compiling
wget  https://www.clamav.net/downloads/production/clamav-0.100.1.tar.gz
tar -zxvf clamav-0.100.1.tar.gz
cd clamav-0.100.1
./configure --prefix=/opt/clamav
make && make install

###configure
cp /opt/clamav/etc/clamd.conf.sample /opt/clamav/etc/clamd.conf
cp /opt/clamav/etc/freshclam.conf.sample /opt/clamav/etc/freshclam.conf

### Setting
groupadd clamav
useradd clamav -g clamav -s /sbin/nologin
mkdir -p /opt/clamav/logs
mkdir -p /opt/clamav/share/clamav
mkdir -p /opt/clamav/worktmp
touch /opt/clamav/logs/freshclam.log
touch /opt/clamav/logs/clamd.log
chown -R clamav:clamav /opt/clamav



###freshclam.conf
sed -i 's/^Example/\#Example/g' /opt/clamav/etc/freshclam.conf
sed -i 's/^#DatabaseDirectory\ \/var\/lib\/clamav/DatabaseDirectory\ \/opt\/clamav\/share\/clamav/g' /opt/clamav/etc/freshclam.conf
sed -i 's/^#UpdataLogFile\ \/var\/log\/freshclam\.log/UpdateLogFile\ \/opt\/clamav\/logs\/freshclam\.log/g' /opt/clamav/etc/freshclam.conf
sed -i 's/^#PidFile\ \/var\/run\/freshclam\.pid/PidFile\ \/opt\/clamav\/worktmp\/freshclam\.pid/g' /opt/clamav/etc/freshclam.conf

###clamd.conf
sed -i 's/^Example/\#Example/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#LogFile\ \/tmp\/clamd\.log/LogFile\ \/opt\/clamav\/logs\/clamd\.log/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#PidFile\ \/var\/run\/clamd.pid/PidFile\ \/opt\/clamav\/worktmp\/clamd.pid/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#DatabaseDirectory\ \/var\/lib\/clamav/DatabaseDirectory\ \/opt\/clamav\/share\/clamav/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#LocalSocket\ \/tmp\/clamd.socket/LocalSocket\ \/opt\/clamav\/worktmp\/clamd.socket/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#TCPSocket\ 3310/TCPSocket\ 3310/g' /opt/clamav/etc/clamd.conf
sed -i "s/^#TCPAddr\ 127\.0\.0\.1/TCPAddr\ $ADDRESS/g" /opt/clamav/etc/clamd.conf
sed -i 's/^#LogFileMaxSize\ 2M/LogFileMaxSize\ 100M/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#LogVerbose\ yes/LogVerbose\ yes/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#LogRotate\ yes/LogRotate\ yes/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#ExtendedDetectionInfo\ yes/ExtendedDetectionInfo\ yes/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#FixStaleSocket\ yes/FixStaleSocket\ yes/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#MaxConnectionQueueLength\ 30/MaxConnectionQueueLength\ 500/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#MaxThreads\ 20/MaxThreads\ 50/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#ReadTimeout\ 300/ReadTimeout\ 300/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#CommandReadTimeout\ 5/CommandReadTimeout\ 5/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#SendBufTimeout\ 200/SendBufTimeout\ 200/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#MaxQueue\ 200/MaxQueue\ 500/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#MaxScanSize\ 150M/MaxScanSize\ 150M/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#MaxFileSize\ 30M/MaxFileSize\ 150M/g' /opt/clamav/etc/clamd.conf
sed -i 's/^#StreamMaxLength\ 10M/StreamMaxLength\ 150M/g' /opt/clamav/etc/clamd.conf

###update virus_data
/opt/clamav/bin/freshclam
#如果首次更新失敗缨称,可以直接從官網(wǎng)下載病毒庫
#cd /opt/clamav/share/clamav
#wget http://database.clamav.net/main.cvd
#wget http://database.clamav.net/daily.cvd
#wget http://database.clamav.net/bytecode.cvd

###start the service
systemctl enable clamav-daemon.service
systemctl start clamav-daemon.service
systemctl enable clamav-freshclam.service
systemctl start clamav-freshclam.service

###soft connection
ln -s /opt/clamav/bin/clamscan  /usr/local/bin/clamscan
ln -s /opt/clamav/bin/freshclam /usr/local/bin/freshclam
ln -s /opt/clamav/bin/clamdscan  /usr/local/bin/clamdscan

### 添加定時(shí)掃描任務(wù)
mkdir -p /tmp/virus
echo '0 1 * * * /opt/clamav/bin/clamscan -r -i --move=/tmp/virus  / >/dev/null 2>&1' >>/etc/crontab

接口調(diào)用亚茬,參數(shù)配置

cat /opt/clamav/etc/clamd.conf | grep -v "^[#|$]" | grep -v "^$"
LogFile /opt/clamav/logs/clamd.log
LogFileMaxSize 100M
LogVerbose yes
LogRotate yes
ExtendedDetectionInfo yes
PidFile /opt/clamav/worktmp/clamd.pid
DatabaseDirectory /opt/clamav/share/clamav
LocalSocket /opt/clamav/worktmp/clamd.socket
FixStaleSocket yes
TCPSocket 3310
TCPAddr 192.168.204.11
MaxConnectionQueueLength 500
StreamMaxLength 150M
MaxThreads 50
ReadTimeout 300
MaxQueue 100
MaxScanSize 150M
MaxFileSize 150M
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市铡恕,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌丢间,老刑警劉巖探熔,帶你破解...
    沈念sama閱讀 210,914評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異烘挫,居然都是意外死亡诀艰,警方通過查閱死者的電腦和手機(jī)柬甥,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,935評(píng)論 2 383
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來其垄,“玉大人苛蒲,你說我怎么就攤上這事÷搪” “怎么了臂外?”我有些...
    開封第一講書人閱讀 156,531評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)喇颁。 經(jīng)常有香客問我漏健,道長(zhǎng),這世上最難降的妖魔是什么橘霎? 我笑而不...
    開封第一講書人閱讀 56,309評(píng)論 1 282
  • 正文 為了忘掉前任蔫浆,我火速辦了婚禮,結(jié)果婚禮上茎毁,老公的妹妹穿的比我還像新娘克懊。我一直安慰自己,他們只是感情好七蜘,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,381評(píng)論 5 384
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著墙懂,像睡著了一般橡卤。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上损搬,一...
    開封第一講書人閱讀 49,730評(píng)論 1 289
  • 那天碧库,我揣著相機(jī)與錄音,去河邊找鬼巧勤。 笑死嵌灰,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的颅悉。 我是一名探鬼主播沽瞭,決...
    沈念sama閱讀 38,882評(píng)論 3 404
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼剩瓶!你這毒婦竟也來了驹溃?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,643評(píng)論 0 266
  • 序言:老撾萬榮一對(duì)情侶失蹤延曙,失蹤者是張志新(化名)和其女友劉穎豌鹤,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體枝缔,經(jīng)...
    沈念sama閱讀 44,095評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡布疙,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,448評(píng)論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片灵临。...
    茶點(diǎn)故事閱讀 38,566評(píng)論 1 339
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡截型,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出俱诸,到底是詐尸還是另有隱情菠劝,我是刑警寧澤,帶...
    沈念sama閱讀 34,253評(píng)論 4 328
  • 正文 年R本政府宣布睁搭,位于F島的核電站赶诊,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏园骆。R本人自食惡果不足惜舔痪,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,829評(píng)論 3 312
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望锌唾。 院中可真熱鬧锄码,春花似錦、人聲如沸晌涕。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,715評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽余黎。三九已至重窟,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間惧财,已是汗流浹背巡扇。 一陣腳步聲響...
    開封第一講書人閱讀 31,945評(píng)論 1 264
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留垮衷,地道東北人厅翔。 一個(gè)月前我還...
    沈念sama閱讀 46,248評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像搀突,于是被迫代替她去往敵國和親刀闷。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,440評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容