杀毒软件更新相关

简介:

用了一个杀毒软件的更新工具,不过它不会自动删除过时的。然后用刚学的python折腾了一个。。。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
 
import  os
import  shutil
 
xxx_dir  =  "/var/www/xxx/rel"
tmp_dir  =  {}
 
#run update
os.system( 'sh /etc/xxx/start.sh' )
 
for  in  os.listdir(xxx_dir):
   tmp  =  i.split( '_' )
   tmp_key  =  "_" .join(tmp[: - 1 ])
   if  tmp_dir.has_key(tmp_key):  #exist key value
     if  int (tmp_dir[tmp_key]) <  int (tmp[ - 1 ]):
       #shutil.rmtree 可以直接删除目录
       shutil.rmtree(xxx_dir  +  "/"  +  tmp_key  +  "_"  +  tmp_dir[tmp_key])
       tmp_dir[tmp_key]  =  tmp[ - 1 ]
     else :
       shutil.rmtree(xxx_dir  +  "/"  +  tmp_key  +  "_"  +  tmp[ - 1 ])
   else :
     tmp_dir[tmp_key]  =  tmp[ - 1 ]
 
print  "Update OK"


上面那个是用另一个工具更新时用的, 那个现在不好用了,又换了一个服务器. 然后再折腾一个脚本.

本来不想折腾,不过杀毒软件用相关许可去更新时会进程卡死,奇怪. 于是这样折腾了...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
 
import  urllib
import  hashlib
import  os
import  sys
import  time
 
www  =  "C:\\Python27\\nod32\\"
ser  =  "http://user:pass@update.com/"
num  =  0
 
def  reporthook(count, block_size, total_size):  #下载进度
     global  start_time
     if  count  = =  0 :
         start_time  =  time.time()
         return
     duration  =  time.time()  -  start_time
     progress_size  =  int (count  *  block_size)
     speed  =  int (progress_size  /  ( 1024  *  duration))
     percent  =  int (count  *  block_size  *  100  /  total_size)
     if  percent >  100 : percent  =  100
     sys.stdout.write( "\r...%d%%, %d KB, %d KB/s, %d seconds passed, Filesize %d KB"  %
                     (percent, progress_size / 1024 , speed, duration, total_size / 1024 ))
     sys.stdout.flush()
     
def  download(u, f, n):
     try :
         print  "\n" ,n,os.sep.join(f.split(os.sep)[ - 2 :])
         urllib.urlretrieve(u, f, reporthook)
     except :
         print  "Download %s Failed"  %  os.sep.join(f.split(os.sep)[ - 2 :])
         sys.exit( 1 )
 
# cb54b290a1a825b29403f7ad285837b4  /var/www/html/v4-rel-sta/mod_008_epfw/em008_64_n3.nup
if  __name__  = =  "__main__" :
     download(ser  +  "nod32.md5" , www  +  "nod32.md5" 0 )
     if  os.path.isfile(www  +  "nod32.md5" ):
         with  open (www  +  "nod32.md5" ) as f:
             for  in  f:
                 num  + =  1
                 if  "/var/www/html"  not  in  i:  continue
                 md5, url, filename, dirname  =  i.split()[ 0 ], ser  +  "/" .join(i.split()[ 1 ].split( "/" )[ 4 :]), www  +  os.sep.join(i.split()[ 1 ].split( "/" )[ 4 :]), www  +  os.sep.join(i.split()[ 1 ].split( "/" )[ 4 : - 1 ])
                 if  not  os.path.isdir(dirname):
                     os.makedirs(dirname)
                 if  os.path.isfile(filename):
                     # 查文件md5时,读文件要用 rb 模式
                     with  open (filename, "rb" ) as n:
                         if  hashlib.md5(n.read()).hexdigest() ! =  md5:
                             download(url, filename, num)
                 else :
                     download(url, filename, num)


另外:rsync 时 ssh端口不是22

1
rsync  -az --progress  '-e ssh -p 1234'  /var/www/html/ * 1.2.3.4: /home/nod32/


本文转自 nonono11 51CTO博客,原文链接:http://blog.51cto.com/abian/1582886,如需转载请自行联系原作者
相关文章
Win系统 - 怎么样卸载 Win10 更新补丁,如何删除系统安全补丁(下)
Win系统 - 怎么样卸载 Win10 更新补丁,如何删除系统安全补丁(下)
118 0
Win系统 - 怎么样卸载 Win10 更新补丁,如何删除系统安全补丁(下)
|
安全
Win系统 - 怎么样卸载 Win10 更新补丁,如何删除系统安全补丁(上)
Win系统 - 怎么样卸载 Win10 更新补丁,如何删除系统安全补丁(上)
393 0
Win系统 - 怎么样卸载 Win10 更新补丁,如何删除系统安全补丁(上)
|
Windows
McAfee杀软补丁出错 可导致系统无法重启
  北京时间6月10日消息,据国外媒体报道,据McAfee用户支持论坛上的信息显示,McAfee最近为其企业版杀软推出的一个补丁可导致系统无法重启。   据悉,这个针对McAfee VSE 8.7的补丁是为了解决一些小的安全漏洞,但却误将Windows系统文件看作恶意软件。
895 0
|
Web App开发 存储 安全
赶快更新!Chrome再现高危漏洞已遭利用
Chrome update 72.0.3626.121 的 Windows、Mac 和 Linux 操作系统版本中已修复该漏洞,用户可能已经收到或者将在数天
222 0
|
安全 网络安全 Windows
勒索病毒预防实战:有的PC打不上补丁怎办?
家里有三台Windows 7 PC,其中两台居然打不上补丁…
2196 0

热门文章

最新文章