-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoServ.py
211 lines (199 loc) · 8.24 KB
/
AutoServ.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import os
import random
import platform
import subprocess
from time import sleep as s
import time
import colorama
colorama.init(autoreset=True)
bye_txt = ["GoodBye", "See You", "Bye Bye", "Have a Great Time"]
b = r'''
db mm .M"""bgd
;MM: MM ,MI "Y
,V^MM. `7MM `7MM mmMMmm ,pW"Wq. `MMb. .gP"Ya `7Mb,od8 `7M' `MF'
,M `MM MM MM MM 6W' `Wb `YMMNq. ,M' Yb MM' "' VA ,V'''
b2 = r''' AbmmmqMA MM MM MM 8M M8 . `MM 8M"""""" MM VA ,V
A' VML MM MM MM YA. ,A9 Mb dM YM. , MM VVV
.AMA. .AMMA`Mbod"YML. `Mbmo`Ybmd9' P"Ybmmd" `Mbmmd'.JMML. W'''
def banner():
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + b)
print(colorama.Fore.RED + colorama.Style.BRIGHT + b2)
print("")
os.system("clear")
banner()
if platform.system() == "Windows":
print("")
print(colorama.Fore.RED + "[-] The Script is Only for UNEX Systems")
print("")
print(colorama.Fore.GREEN + colorama.Style.BRIGHT + f"[UwU] {random.choice(bye_txt)}")
exit(0)
else:
pass
if os.getenv("SUDO_USER") == None:
print("")
print(colorama.Fore.RED + "[-] Please Run The Script As Root | Try 'sudo python3 AutoServ.py'")
print("")
print(colorama.Fore.GREEN + colorama.Style.BRIGHT + f"[UwU] {random.choice(bye_txt)}")
exit(0)
else:
pass
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + f"[+] Updating Linux..")
print("")
try:
while True:
try:
os.system("sudo apt-get update")
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[+] System Update Successful!")
print("")
break
except:
print(colorama.Fore.RED + "[-] Update Failed...")
print("")
inp = input(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[?] Do You Want To Retry (y/n): ")
if inp == "y" or inp == "yes":
continue
else:
break
time.sleep(3)
os.system("clear")
banner()
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[=] Starting Default Services")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "=============================>")
print("")
os.system("service apache2 start")
print(colorama.Fore.WHITE + colorama.Style.BRIGHT + f"[{colorama.Fore.GREEN + '●'}{colorama.Fore.WHITE + '] Service Apache2 Started'}")
s(0.5)
os.system("service postgresql start")
print(colorama.Fore.WHITE + colorama.Style.BRIGHT + f"[{colorama.Fore.GREEN + '●'}{colorama.Fore.WHITE + '] Service PostGreSql Started'}")
s(0.5)
os.system("service tor start")
print(colorama.Fore.WHITE + colorama.Style.BRIGHT + f"[{colorama.Fore.GREEN + '●'}{colorama.Fore.WHITE + '] Service Tor Started'}")
s(2)
while True:
os.system("clear")
banner()
print("")
inp2 = input(colorama.Fore.GREEN + colorama.Style.BRIGHT + "[?] Do You Want To Stop All The Services (y/n): ")
if inp2 == "y":
os.system("clear")
banner()
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[=] Stopping Default Services")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "=============================>")
print("")
os.system("service apache2 stop")
print(colorama.Fore.WHITE + colorama.Style.BRIGHT + f"[{colorama.Fore.RED + '●'}{ colorama.Fore.WHITE + '] Service Apache2 Stopped'}")
s(0.5)
os.system("service postgresql stop")
print(colorama.Fore.WHITE + colorama.Style.BRIGHT + f"[{colorama.Fore.RED + '●'}{colorama.Fore.WHITE + '] Service PostGreSql Stopped'}")
s(0.5)
os.system("service tor stop")
print(colorama.Fore.WHITE + colorama.Style.BRIGHT + f"[{colorama.Fore.RED + '●'}{colorama.Fore.WHITE + '] Service Tor Stopped'}")
print("")
s(2)
break
elif inp2 == "n" or inp2 == "":
break
else:
os.system("clear")
banner()
print()
print(colorama.Fore.RED + colorama.Style.BRIGHT + "[-] Please Select A Valid Option")
s(1.75)
continue
while True:
os.system("clear")
banner()
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[=] Checking For Updates..")
print("")
upgradables = subprocess.run("sudo apt list --upgradable", shell=True, capture_output=True).stdout.decode()
upgradables = upgradables.rstrip()
if upgradables == "Listing...":
print(colorama.Fore.GREEN + colorama.Style.BRIGHT + "[++] System Up-To Date!")
time.sleep(3)
break
else:
time.sleep(3)
os.system("clear")
banner()
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[+] These are The Packages that can be Upgraded...")
print("")
print(colorama.Fore.RED + colorama.Style.BRIGHT + upgradables)
print("")
inp3 = input(colorama.Fore.GREEN + colorama.Style.BRIGHT + "[?] Do You Want To Upgrade the System (y/n): ")
if inp3 == "y":
os.system("clear")
banner()
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[=] Preparing For Upgrade")
os.system("sudo dpkg --configure -a")
print("")
print(colorama.Fore.GREEN + colorama.Style.BRIGHT + "[++] Done")
print("")
while True:
inp4 = input(colorama.Fore.GREEN + colorama.Style.BRIGHT + "[?] 1) Full-Upgrade type | 2) Normal Upgrade type (n) | Or Enter To Exit: ")
if inp4 == "1":
os.system("clear")
banner()
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[+] Full-Upgrading Linux...")
print("")
os.system("sudo apt full-upgrade -y")
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[++] System Upgrade Successful!")
time.sleep(3)
break
elif inp4 == "2":
os.system("clear")
banner()
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[+] Upgrading Linux...")
print("")
os.system("sudo apt upgrade")
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[++] System Upgrade Successful!")
time.sleep(3)
break
elif inp4 == "":
break
elif inp4 != "1" or inp4 != "2" or inp4 != "":
os.system("clear")
banner()
print("")
print(colorama.Fore.RED + colorama.Style.BRIGHT + "[-] Please Select A Valid Option")
s(1.75)
os.system("clear")
continue
break
elif inp3 == "n":
break
elif inp3 != "y" or inp3 != "n":
os.system("clear")
print(colorama.Fore.RED + colorama.Style.BRIGHT + "[-] Please Select A Valid Option")
s(1.75)
continue
os.system("clear")
banner()
print("")
print(colorama.Fore.GREEN + colorama.Style.BRIGHT + "[=] Auto-Removing Unwanted Update Files")
print("")
os.system("sudo apt autoremove")
print("")
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + "[++] Auto-Remove Successful!")
time.sleep(3)
os.system("clear")
banner()
print("")
print(colorama.Fore.GREEN + colorama.Style.BRIGHT + f"[UwU] {random.choice(bye_txt)}")
exit(0)
except KeyboardInterrupt:
print("")
print("")
print(colorama.Fore.RED + colorama.Style.BRIGHT + "[-] Exiting AutoServ")
print("")
print(colorama.Fore.GREEN + colorama.Style.BRIGHT + f"[UwU] {random.choice(bye_txt)}")
exit(0)