Last active
December 9, 2015 21:59
-
-
Save matchy256/4334403 to your computer and use it in GitHub Desktop.
ClamAV でシステム全体をスキャンして、問題があったらメールするスクリプト。
除外ディレクトリは /etc/clamscan.exclude ファイルに1行ずつ書いとく。/proc は入れといた方がいい。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MAILTO="root" | |
PATH=/usr/bin:/bin | |
# excludeopt setup | |
excludelist=/etc/clamscan.exclude | |
if [ -s $excludelist ]; then | |
for i in `cat $excludelist` | |
do | |
if [ $(echo "$i"|grep \/$) ]; then | |
i=`echo $i|sed -e 's/^\([^ ]*\)\/$/\1/p' -e d` | |
excludeopt="${excludeopt} --exclude-dir=^$i" | |
else | |
excludeopt="${excludeopt} --exclude=^$i" | |
fi | |
done | |
fi | |
# signature update | |
freshclam 2>&1 > /dev/null | |
# virus scan | |
CLAMSCANTMP=`mktemp` | |
#clamscan --recursive --remove ${excludeopt} / > $CLAMSCANTMP 2>&1 | |
clamscan --recursive ${excludeopt} / > $CLAMSCANTMP 2>&1 | |
[ ! -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \ | |
# report mail send | |
grep FOUND$ $CLAMSCANTMP | mail -s "Virus Found in `hostname`" $MAILTO | |
rm -f $CLAMSCANTMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment