forked from nsdown/DNS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
67 lines (52 loc) · 1.9 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
63
64
65
66
67
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import platform
from bin.update import CalcMD5
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!"
sys.exit(1)
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 Downloadfile(URL):
if not os.path.isfile(GccFilepath):
os.system('wget -O bind.tar.gz ' + URL + ' --no-check-certificate')
os.system('mv bind.tar.gz /tmp')
print "File download success."
else:
print 'File already exists!'
if not checkfile(GccFilepath):
print 'File hash does not match, consider check your network!'
sys.exit(1)
print "File hash matches remote file."
def checkfile(ck_filepath):
MD5 = CalcMD5(ck_filepath)
# why not put a coresponding text file containing the hash
# of ck_filepath in the same dir as DowdloadURL, say,
# https://o5obpsd7a.qnssl.com/bind.hash'? Then you can just
# download and read hash value online, which would make it
# easier to maintain if the bind.tar.gz should change.
if MD5 != '173ce5e83e9ba31f8368367ee1ff7807':
print 'But Md5 mismatch found!'
print 'error MD5:', MD5
os.system('rm -rf /tmp/bind.tar.gz')
# Downloadfile(DowdloadURL)
return False
return True
if __name__ == '__main__':
Downloadfile(DowdloadURL)
select_platform(system_platform)
os.system('crontab /root/DNS/bin/dnscron.cron')
os.system('/sbin/service crond reload')
os.system('/sbin/service crond restart')