Talk:Clamav:freshclam update
From SME Server
Jump to navigationJump to searchThe printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
as per forum
I have formmated for wiki
--Stephdl (talk) 04:05, 17 March 2013 (MDT) when your work will finish, you should create a new section (ie 2.other method) on the front page of clamav update
#!/bin/bash # clamcvdget # routine created on 03-14-2013 15:00 # this routine will update the clamav virus signature datafiles ######################################## VARIABLES FOR TESTING # SET skipdownload TO 1 WILL SKIP DOWNLOADING OF NEW CVD FILES # IF FILES NEED TO BE DOWNLOADED THEY WILL BE AUTOMATICALLY # FOR TESTING PURPOSES skipdownload="0" # SET dovirustest TO 1 WILL CAUSE A SHORT CLAMSACN VIRUS # TEST TO DISPLAY SHOWING SUMMARY AND KNOWN VIRUS COUNT doclamtest="1" #SET showversion TO 1 TO DISPLAY VERSION OF CLAMD AND CLAMSCAN showversion="1" ############################################################# ####################### THESE VARIABLES MUST BE SET CORRECTLY downloadurl="db.us.clamav.net" file1="main.cvd" file2="daily.cvd" file3="bytecode.cvd" clamdir="/var/clamav" downloaddirectory="" downloaddirectory1='/var/clamav/download/1' downloaddirectory2='/var/clamav/download/2' ############################################################# /usr/bin/renice 20 -p $$ > /dev/null ############################### begin of functions # FUNCTION TO COMPARE DOWNLOADED CVD FILES function comparecvdfiles { result="0" if ! diff \ "$downloaddirectory1/$file1" \ "$downloaddirectory2/$file1" > /dev/null then return 0 fi if ! diff \ "$downloaddirectory1/$file2" \ "$downloaddirectory2/$file2" > /dev/null then return 0 fi if ! diff \ "$downloaddirectory1/$file2" \ "$downloaddirectory2/$file2" > /dev/null then return 0 fi result="1" } # FUNCTION TO DOWNLOAD CVD FILES function downloadcvdfiles { result="0" cd /tmp currentdir=$PWD if [ $currentdir != "/tmp" ] then return 0 fi if [ $downloaddirectory == "" ] | [ $downloaddirectory == "/" ] then return 0 fi mkdir -p $downloaddirectory chmod 755 $downloaddirectory rm -f $downloaddirectory/* > /dev/null cd $downloaddirectory currentdir=$PWD if [ $currentdir == "/tmp" ] | [ $currentdir == "/" ] | [ $currentdir == "/root" ] then return 0 fi wget -q $downloadurl/$file3 wget -q $downloadurl/$file1 wget -q $downloadurl/$file2 echo "done with downloading" cd /tmp result="1" } #FUNCITON TO CHECK FOR EXISTENCE OF CVD FILES function dodownloadfilesexist { result="0" if [ ! -f "$downloaddirectory/$file1" ] | [ ! -f "$downloaddirectory/$file2" ] \ | [ ! -f "$downloaddirectory/$file3" ] then return 0 else result="1" fi } ################################## end of functions #TODAY=$(date +"%Y%m%d %T") #echo "$TODAY started" if [ $skipdownload == "0" ] then echo "downloding new clamav cvd files" downloaddirectory=$downloaddirectory1 downloadcvdfiles fi # DOWNLOAD FIRST SET OF CVD FILES IF NOT EXIST downloaddirectory=$downloaddirectory1 dodownloadfilesexist if [ $result == "0" ] then downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then sleep 90 downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then sleep 90 downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then echo "Update cvd files do not exist" echo "Cannot update Clamav" exit 0 fi # DOWNLOAD SECOND SET OF CVD FILES IF NOT EXIST downloaddirectory=$downloaddirectory2 dodownloadfilesexist if [ $result == "0" ] then downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then sleep 90 downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then sleep 90 downloadcvdfiles fi if [ $result == "0" ] then echo "Update cvd files do not exist" echo "Cannot update Clamav" exit 0 fi comparecvdfiles if [ $result == "0" ] then downloaddirectory=$downloaddirectory2 dodownloadfilesexist if [ $result == "0" ] then downloadcvdfiles fi if [ $result == "0" ] then sleep 90 downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then sleep 90 downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then echo "Update cvd files do not exist" echo "Cannot update Clamav" exit 0 fi fi comparecvdfiles if [ $result == "0" ] then downloaddirectory=$downloaddirectory1 dodownloadfilesexist if [ $result == "0" ] then downloadcvdfiles fi if [ $result == "0" ] then sleep 90 downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then sleep 90 downloadcvdfiles fi dodownloadfilesexist if [ $result == "0" ] then echo "Update cvd files do not exist" echo "Cannot update Clamav" exit 0 fi fi comparecvdfiles if [ $result == "0" ] then echo "Update files are not complete" echo "Cannot update ClamAV" exit 0 fi echo "updating Clamav" service clamd stop > /dev/null cd $clamdir rm -f $clamdir/*.cvd 1> /dev/null 2> /dev/null cp -p $downloaddirectory1/*.cvd $clamdir service clamd start > /dev/null # THE FOLLOWING LINE IS JUST A TEST TO SEE if [ $showversion == "1" ] then clamd -V clamscan -V fi if [ $doclamtest == "1" ] then echo "running clamscan test" mkdir -p $clamdir/temp clamscan $clamdir/temp rm -rf $clamdir/temp fi #TODAY=$(date +"%Y%m%d %T") #echo "$TODAY ended" exit 0