forked from zekro-archive/DiscordBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
119 lines (94 loc) · 3.75 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
###################################
# USE THIS TO FOR INSTALLATION #
# (c) zekro 2017 #
###################################
import os
import urllib
import platform
import sys
updateURL = "https://github.com/zekroTJA/DiscordBot/blob/master/out/artifacts/DiscordBot_jar/DiscordBot.jar?raw=true"
updateScriptURL = "https://raw.githubusercontent.com/zekroTJA/DiscordBot/master/update.py"
restartScriptURL = "https://raw.githubusercontent.com/zekroTJA/DiscordBot/master/restart.py"
settingsURL = "https://raw.githubusercontent.com/zekroTJA/DiscordBot/master/SETTINGS.txt"
startFileURL = "https://raw.githubusercontent.com/zekroTJA/DiscordBot/master/startfile.sh"
DEFintsallPath = "Programs/zekroBot/"
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
class messages:
DL_FAIL = bcolors.FAIL + "An error occured while downloading! Please check your network connection!" + bcolors.ENDC
DL_COMPLETED = bcolors.OKGREEN + "Download completed." + bcolors.ENDC
COMPLETED = bcolors.OKGREEN + "Completed." + bcolors.ENDC
print "##############################\n" \
"# " + bcolors.BOLD + bcolors.OKBLUE + "ZEKROS DISCORD BOT" + bcolors.ENDC + " #\n" \
"# INSTALLATION #\n" \
"# (C) 2017 by zekro #\n" \
"##############################\n\n"
print "Please enter a path to install. Enter nothing for default installation path (~/Programs/zekroBot/)..."
installPath = raw_input()
installPath += "/"
if installPath == "":
installPath = DEFintsallPath
print "Default path chosen."
else:
if not os.path.exists(installPath):
print "Entered path " + installPath + " does not exist. Create path now?"
if raw_input("(y/n):") == "y":
os.makedirs(installPath)
print "Path created."
else:
sys.exit(0);
else:
print "Path " + installPath + " chosen."
if platform.system() != "Linux":
print "\n[ERROR] Please only use that installation script on Linux based system!"
sys.exit(0)
print "\n" + bcolors.ENDC + "Downloading/Updating screen package..."
os.system("sudo apt-get install screen")
if not os.path.exists(installPath):
print "\n" + bcolors.ENDC + "Creating path..."
os.makedirs(installPath)
print "\n" + bcolors.ENDC + "Downloading 'DiscordBot.jar'..."
try:
urllib.urlretrieve(updateURL, installPath + "DiscordBot.jar")
print messages.DL_COMPLETED
except:
print messages.DL_FAIL
print "\n" + bcolors.ENDC + "Downloading 'update.py'..."
try:
urllib.urlretrieve(updateScriptURL, installPath + "update.py")
print messages.DL_COMPLETED
except:
print messages.DL_FAIL
print "\n" + bcolors.ENDC + "Downloading 'restart.py'..."
try:
urllib.urlretrieve(restartScriptURL, installPath + "restart.py")
print messages.DL_COMPLETED
except:
print messages.DL_FAIL
print "\n" + bcolors.ENDC + "Downloading 'SETTINGS.txt'..."
try:
urllib.urlretrieve(settingsURL, installPath + "SETTINGS.txt")
print messages.DL_COMPLETED
except:
print messages.DL_FAIL
print "\n" + bcolors.ENDC + "Creating 'zb' (Startfile)..."
f = open("zb", "w")
f.write("cd " + installPath + "\n")
f.write("sudo screen -L -S zekroBot sudo java -jar DiscordBot.jar")
f.close()
print messages.COMPLETED
print "\n" + bcolors.OKGREEN + "Installation finished!"
print "\n" + bcolors.ENDC + "Do you want to open SETTINS.txt now?"
if raw_input("(y/n):") == "y":
os.system("sudo nano " + installPath + "/SETTINGS.txt")
else:
print "\n" + bcolors.OKBLUE + "Please open the file '~/Programs/zekroBot/SETTINGS.txt' \n" \
"and enter your Discord API token!"
sys.exit(0)