在网上找到的一个Nod32升级脚本
看看了3.x的免ID升级服务器,感觉都是用这个脚本download下来的,他们都修改了update.ver文件的内容。
详细内容:
#!/bin/bash
##############################################
# CONFIGURATION
##############################################
# system paths
WGET="/usr/bin/wget"
UNRAR="/usr/bin/unrar"
PS="/bin/ps"
MV="/bin/mv"
RM="/bin/rm"
MD5="/usr/bin/md5sum"
# temporary path, must exist and be writeable
TMP="/tmp"
# clean-up old unused files : 0 - disable, 1 - enable-saves disk space
clean_unused="0"
# ESET updates server
SERVERURL="u33.eset.com"
# Local shared folder
BASE="/var/shares/antivirus/nod32"
# Username and password sent to you by e-mail from ESET
USER="EAV-01234567"
PASS="gej24i34j2"
# What languages should be IGNORED (not downloaded)
EXCLUDE_LANGUAGES=( fr ch nl ge jp pl pt sk sp hr hu )
##############################################
# DO NOT EDIT BELOW THIS LINE
##############################################
# Functions, pre-checks
SERVERv3="http://$SERVERURL/eset_upd/"
function err_disp {
if [ $? = 0 ];then
:
else
echo $1
exit 0
fi
}
function FilterLanguages {
list=$(cat "$TMP/update.ver"|grep ".nup")
for s in ${EXCLUDE_LANGUAGES[@]}; do
list=$(echo "$list"|grep -v "$s.nup")
done
list=${list//"file="/""}
echo "$list"
}
if [ -f $TMP/nod32list ];then
$RM -f $TMP/nod32list
err_disp 'Failed while deleting old file'
fi
if [ -f $TMP/v3.ver ];then
$RM -f $TMP/v3.ver
err_disp 'Failed while deleting old file'
fi
${PS} aux|grep wget|grep "$SERVERURL" >/dev/null 2>&1
if [ $? = 0 ];then
kill `ps aux|grep wget|grep "$SERVERURL"|awk '{print $2}'`
err_disp 'Failed while killing process'
fi
if [ ! -d ${BASE} ];then
mkdir -p ${BASE}
err_disp 'Failed while creating nod32 base home directiory'
fi
# Downloading the informational update files
$WGET -t 9 -T 9 -nH -q -nd -O $TMP/v3.ver $SERVERv3/update.ver
err_disp 'Failed while downloading update.ver v3'
$UNRAR x -inul $TMP/v3.ver $TMP
echo "`FilterLanguages`" >> $TMP/nod32list
$RM $TMP/update.ver
# Downloading the data files, adding/updating differences
$WGET --http-user=$USER --http-passwd=$PASS -N -t 9 -T 9 -m -nH -P $BASE --input-file=$TMP/nod32list -B "http://$SERVERURL" --quiet
if [ $? = 0 ]; then
$UNRAR p -inul $TMP/v3.ver | sed 's/\/download/download/' > $BASE/update.ver
fi
# Cleaning old NUP datafiles
if [ "$clean_unused" = "1" ]; then
if [ ! -f $TMP/nod32list ]; then
exit 0
fi
ARY=(`cat "$TMP/nod32list" | tr '\r' ' ' | tr '\n' ' '`)
if [ "${#ARY[@]}" -lt "10" ]; then
exit 0
fi
EFS=( )
filelist=`ls -1R "$BASE"`
de=${#BASE}
for s in $filelist; do
if [ "${s:(-1)}" = ":" ]; then
cdir=${s:($de)}
cdir=${cdir:0:(${#cdir}-1)}
else
ext=${s:(-4)}
if [ "$ext" = ".nup" ]; then
EFS=( "${EFS[@]}" "$cdir/$s" )
fi
fi
done
# echo "Existing files: ${#EFS[@]}\nUplink files: ${#ARY[@]}\nCleaning..."
if [ "${#EFS[@]}" -lt "10" ]; then
exit 0
fi
function FindInArray {
FOUND=0
for s in ${ARY[@]}; do
if [ "$s" = "$1" ]; then
FOUND=1
break
fi
done
echo "$FOUND"
}
for s in ${EFS[@]}; do
FOUND=`FindInArray $s`
if [ "$FOUND" = "0" ]; then
rm "$BASE$s"
fi
done
fi
$RM -f $TMP/nod32list
附件下载:nodupdate
载自:http://ashus.ashus.net/viewtopic.php?f=16&t=68
我个人觉得这个脚本写的不怎么样,这个脚本没有对所有文件做完整性检查,每次运行这个脚本,完全依靠Wget来判断是否需要更新文件,所以在Nod32服务器上可以看到这些升级机器每次都搜刮一下所有文件。