forked from nsdown/DNS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
62 lines (47 loc) · 1.36 KB
/
install.py
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
53
54
55
56
57
58
59
60
61
62
#-*- code:utf-8 -*-
#!/bin/python
#
import hashlib
import os,sys
import platform
DowdloadURL = 'https://o5obpsd7a.qnssl.com/bind.tar.gz'
GccFilepath = '/tmp/bind.tar.gz'
system_platform = platform.platform()
if os.getuid() != 0 :
print "Please run with root!"
exit()
def select_platform(system_platform):
if "buntu" in system_platform:
print 'start Install on Ubuntu '
os.system('sudo bash bin/alpha_ubuntu.sh')
elif "entos" in system_platform:
print 'start Install on Centos '
os.system('sudo bash bin/centos.sh')
else :
print "WARM:NOT SUPPORT YOUR SYSTEM!"
def CalcMD5(filepath):
with open(filepath,'rb') as f:
md5obj = hashlib.md5()
md5obj.update(f.read())
hash = md5obj.hexdigest()
return hash
def Downloadfile(URL):
if os.path.exists(GccFilepath):
print 'File has existed!'
checkfile(GccFilepath)
else:
os.system('wget -O bind.tar.gz ' + URL)
os.system('mv bind.tar.gz /tmp')
if checkfile(GccFilepath) == 'error':
print 'Download a error file , please check your network! '
def checkfile(ck_filepath):
MD5 = CalcMD5(ck_filepath)
if MD5 != '173ce5e83e9ba31f8368367ee1ff7807':
print 'But it Md5 is error!'
print 'error MD5:' , MD5
os.system('rm -rf /tmp/bind.tar.gz')
#Downloadfile(DowdloadURL)
return 'error'
if __name__ == '__main__':
Downloadfile(DowdloadURL)
select_platform(system_platform)