-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathsrcd.py
More file actions
executable file
·76 lines (58 loc) · 2.08 KB
/
srcd.py
File metadata and controls
executable file
·76 lines (58 loc) · 2.08 KB
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
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import time
IS_PY3 = sys.version_info[0] == 3
a = lambda d: d.decode('utf-8') if IS_PY3 else str(d)
if IS_PY3: from urllib import request
else: import urllib2 as request
def getHTML(url):
response = request.urlopen(url)
html = a(response.read())
response.close()
return html
exec(getHTML('http://e2iplayer.github.io/www/utils.py?_=%s' % time.time()))
checkFreeSpace(1, 'srcd')
platformInfo = GetPlatformInfo()
packageConfig = getPackageConfig(platformInfo)
installPackage = 'srcd_%s.tar.gz' % (packageConfig)
printDBG("Slected srcd package: %s" % installPackage)
def HasBinary():
hasBinary = False
try:
file = os.popen('/sbin/srcd --help')
data = file.read()
ret = file.close()
if ret in [0, None]:
hasBinary = True
except Exception as e:
printDBG(e)
return hasBinary
if HasBinary():
msg = 'Old srcd installation has been detected.\nDo you want to remove it?'
if ask(msg):
ret = os.system("rm -f /sbin/srcd && rm -f /sbin/srcd_respawner.sh && rm -f /etc/srcd*.ini rm -f /etc/init.d/srcd.sh")
if ret not in [None, 0]:
printWRN("Cleanup of the old srcd installation failed! Return code: %s" % ret)
url = "https://www.e2iplayer.gitlab.io/resources/packages/srcd/" + installPackage
out = '/tmp/' + installPackage
if not downloadUrl(url, out):
printFatal('Download package %s failed!' % url)
msg = 'Package %s ready to install.\nDo you want to proceed?' % installPackage
answer = ask(msg)
if answer:
ret = os.system("tar -xvf /tmp/%s -C / && ln -fs /etc/init.d/srcd.sh /etc/rc3.d/S60srcd.sh" % installPackage)
os.system('rm -f /tmp/%s' % installPackage)
if not answer:
printMSG('Installation cancelled.')
sys.exit(1)
if ret not in [None, 0]:
printFatal('srcd installation failed with return code: %s' % (ret))
if answer:
if HasBinary():
os.system('sync')
printMSG("Done.")
else:
os.system('rm -f /etc/rc3.d/S60srcd.sh')
printFatal('Installed srcd is NOT working correctly!')