<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>榆树网 &#187; 升级服务</title>
	<atom:link href="http://www.wenzk.com/archives/tag/%e5%8d%87%e7%ba%a7%e6%9c%8d%e5%8a%a1/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wenzk.com</link>
	<description>http://www.wenzk.com</description>
	<lastBuildDate>Thu, 09 Feb 2012 07:57:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Linux下镜像NOD32病毒库的脚本</title>
		<link>http://www.wenzk.com/archives/425</link>
		<comments>http://www.wenzk.com/archives/425#comments</comments>
		<pubDate>Thu, 22 Oct 2009 01:35:31 +0000</pubDate>
		<dc:creator>ELM</dc:creator>
				<category><![CDATA[榆树网-网络]]></category>
		<category><![CDATA[Nod32]]></category>
		<category><![CDATA[升级服务]]></category>
		<category><![CDATA[病毒库]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[镜像]]></category>

		<guid isPermaLink="false">http://www.wenzk.com/?p=425</guid>
		<description><![CDATA[以前在网上找到的一个升级NOD32病毒库的脚本，在使用过程中不断的对其进行修正，最终生成了这个版本，我个人认为比较满意，暂时符合我的要求。 注意：这个脚本不是我原创的，脚本的作者是soff，目前可以在http://www.52crack.com/blog/?action=show&#38;id=226找到，我做了一点点修改而已： #!/usr/bin/php -q &#60;? // author: soff // Modified by: ELM $LOCALDIR = '/home/nod32'; $WGET = '/usr/bin/wget'; $UNRAR = '/usr/bin/unrar'; $GREP = '/bin/grep'; $STRINGS = '/usr/bin/strings'; $UPDATE_SERVER = 'http://u20.eset.com'; $USER = 'AV-7009043'; $PASS = 'vu34kgnc4a'; $UA = "ESS Update (Windows; U; 32bit; VDB 5843; BPC 3.0.684.0; OS: 5.1.2600 SP 3.0 NT; CH 1.1; LNG [...]]]></description>
			<content:encoded><![CDATA[<p>以前在网上找到的一个升级NOD32病毒库的脚本，在使用过程中不断的对其进行修正，最终生成了这个版本，我个人认为比较满意，暂时符合我的要求。</p>
<p><span id="more-425"></span>注意：这个脚本不是我原创的，脚本的作者是soff，目前可以在<a href="http://www.52crack.com/blog/?action=show&amp;id=226" target="_self">http://www.52crack.com/blog/?action=show&amp;id=226</a>找到，我做了一点点修改而已：</p>
<p><code>#!/usr/bin/php -q<br />
&lt;?<br />
// author: soff<br />
// Modified by: ELM<br />
$LOCALDIR = '/home/nod32';<br />
$WGET = '/usr/bin/wget';<br />
$UNRAR = '/usr/bin/unrar';<br />
$GREP = '/bin/grep';<br />
$STRINGS = '/usr/bin/strings';<br />
$UPDATE_SERVER = 'http://u20.eset.com';<br />
$USER = 'AV-7009043';<br />
$PASS = 'vu34kgnc4a';<br />
$UA = "</code>ESS Update (Windows; U; 32bit; VDB 5843; BPC 3.0.684.0; OS: 5.1.2600 SP 3.0 NT; CH 1.1; LNG 2052; x32c; UPD http://<code>u20.eset.com</code>/eset_upd; APP eav; BEO 1)<code>";</code></p>
<p>$product = array (&#8216;nod_upd&#8217;, &#8216;eset_upd&#8217;, &#8216;eset_upd/sky&#8217;, &#8216;eset_upd/pre&#8217;);</p>
<p>chdir($LOCALDIR);</p>
<p>//不下载的文件<br />
$ignore = array(&#8216;data0001&#8242;);</p>
<p>//需要额外下载的文件<br />
#$list[] = “{$UPDATE_SERVER}/nod_upd/expire.rar”;<br />
$list = array();</p>
<p>//下载update.ver &amp; 并处理，生成需要下载的文件列表<br />
foreach ( $product as $subdir ) {<br />
exec(“$WGET -U &#8216;$UA&#8217; -t 9 -T 9 -N -nH -nd -P {$LOCALDIR}/{$subdir} {$UPDATE_SERVER}/{$subdir}/update.ver”, $output, $ret);</p>
<p>if ($ret &gt; 0) {<br />
echo &#8216;Failed while downloading {$UPDATE_SERVER}/{$subdir}/update.ver.&#8217;;<br />
}</p>
<p>exec(“$UNRAR x -o+ {$LOCALDIR}/{$subdir}/update.ver”, $output, $ret);</p>
<p>if ($ret &gt; 0) {<br />
echo &#8216;Failed while extracting {$LOCALDIR}/{$subdir}/update.ver.&#8217;;<br />
}</p>
<p>$content = file_get_contents(&#8216;update.ver&#8217;);</p>
<p>preg_match_all(“/file=(.+?)\n/ie”, $content, $matches);</p>
<p>preg_match_all(“/build=(.+?)\n/ie”, $content, $buildes);</p>
<p>preg_match_all(“/size=(.+?)\n/ie”, $content, $size);</p>
<p>foreach($matches[1] as $id =&gt; $match) {<br />
$match = trim($match);<br />
$last = substr($match, 0);</p>
<p>if ( !in_array($last, $ignore)) {<br />
exec(“$STRINGS {$LOCALDIR}{$match} | $GREP \”^” . trim($buildes[0][$id]) . “\”\n” , $output, $ret);<br />
//echo “File size:” . (int)$size[1][$id] . ” Real Size:” . filesize($LOCALDIR . $match) . “\n”;<br />
if ( $ret != 0 || (int)$size[1][$id] &gt; filesize($LOCALDIR . $match) ) $list[] = “{$UPDATE_SERVER}$match”;<br />
}<br />
}<br />
} // for each product</p>
<p>//消重<br />
$list = array_unique($list);</p>
<p>if (count($list) &gt; 0 ) { //get list<br />
//生成list.txt文件<br />
foreach ($list as $url) {<br />
if ( strlen($url) &gt; 10 )<br />
$filelist .= $url . “\n”;<br />
}</p>
<p>//写入到文件中，我这个机器上的php不支持file_put_contents函数，所以用比较笨的办法<br />
#file_put_contents(&#8216;list.txt&#8217;, $list);<br />
$filename=”list.txt”;<br />
if (!$handle = fopen($filename, &#8216;w&#8217;)) {<br />
echo “不能打开文件 $filename”;<br />
exit;<br />
}</p>
<p>// 将$somecontent写入到我们打开的文件中。<br />
if (fwrite($handle, $filelist) === FALSE) {<br />
echo “不能写入到文件 $filename”;<br />
exit;<br />
}</p>
<p>fclose($handle);</p>
<p>//开始下载啦<br />
exec(“$WGET &#8211;http-user=$USER &#8211;http-passwd=$PASS -U &#8216;$UA&#8217; -t 9 -T 9 -m -nH -P $LOCALDIR -i list.txt”, $output, $ret);</p>
<p>if ($ret &gt; 0) {<br />
echo &#8216;Failed while downloading files.&#8217;;<br />
exit;<br />
}</p>
<p>} //get file</p>
<p>if ( file_exists(“update.ver”) )<br />
unlink(“update.ver”);<br />
if ( file_exists(“list.txt”) )<br />
unlink(“list.txt”);</p>
<p>echo &#8216;Updated successfully.&#8217;;<br />
?&gt;</p>
<p>修改主要为了提高镜像速度，原脚本通过wget来检查每个文件是否有更新，如果有更新下载更新，但是对于100多个文件来说，时间就比较长了。</p>
<p>修改后的脚本会根据版本号和文件大小来确定是否需要下载文件，当然update.ver每次都检查是否有更新。</p>
<h2  class="related_post_title">相关文章</h2><ul class="related_post"><li><a href="http://www.wenzk.com/archives/1464" title="如何为逻辑卷创建镜像">如何为逻辑卷创建镜像</a> (0)</li><li><a href="http://www.wenzk.com/archives/1053" title="MySQL镜像站点">MySQL镜像站点</a> (0)</li><li><a href="http://www.wenzk.com/archives/990" title="为CentOS网卡启动脚本增加PreUp、PostUp、PreDown和PostDown脚本">为CentOS网卡启动脚本增加PreUp、PostUp、PreDown和PostDown脚本</a> (2)</li><li><a href="http://www.wenzk.com/archives/672" title="修改Bat文件运行后窗口的标题">修改Bat文件运行后窗口的标题</a> (0)</li><li><a href="http://www.wenzk.com/archives/464" title="How to build *BSD CVSup mirror">How to build *BSD CVSup mirror</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.wenzk.com/archives/425/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

