-
Notifications
You must be signed in to change notification settings - Fork 113
/
MyServer.py
151 lines (135 loc) · 5.04 KB
/
MyServer.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
#!/usr/bin/python3
# Tool Name :- MyServer
# Author :- Rajkumar Dusad
# Date :- 2021/26/7
import sys
import os
from time import sleep
from core.system import *
if os.getuid() == 0 or system=="termux":
pass
else:
print("\nerror: Please, Run This programm as Root!\n")
sys.exit()
if len(sys.argv)>1:
pass
else:
print ("error : invalid arguments !!")
print ("use : myserver --help for more information")
sys.exit()
if sys.argv[1]=="-s":
if len(sys.argv)==2:
if system=="ubuntu":
os.system("sudo python3 core/s.py "+sys.argv[1])
else:
os.system("python3 core/s.py "+sys.argv[1])
elif len(sys.argv)==3:
if sys.argv[2]=="apache":
if system=="ubuntu":
os.system("python3 core/server.py -apa")
else:
os.system("python3 core/server.py -apa")
else:
print ("error : invalid arguments !!")
print ("use : myserver --help for more information")
elif len(sys.argv)==6:
if sys.argv[2]=="-php":
if system=="ubuntu":
os.system("python3 core/server.py -php "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
else:
os.system("python3 core/server.py -php "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
elif sys.argv[2]=="-py":
if system=="ubuntu":
os.system("sudo python3 core/server.py -py "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
else:
os.system("python3 core/server.py -py "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
elif sys.argv[2]=="-ng":
if system=="ubuntu":
os.system("python3 core/server.py -ng "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
else:
os.system("python3 core/server.py -ng "+sys.argv[3]+" "+sys.argv[4]+" "+sys.argv[5])
else:
print ("error : invalid arguments !!")
print ("use : myserver --help for more information")
elif len(sys.argv)==5:
if system=="ubuntu":
os.system("python3 core/server.py -d "+sys.argv[2]+" "+sys.argv[3]+" "+sys.argv[4])
else:
os.system("python3 core/server.py -d "+sys.argv[2]+" "+sys.argv[3]+" "+sys.argv[4])
else:
print ("error : invalid arguments !!")
print ("use : myserver --help for more information")
elif sys.argv[1]=="-h":
if len(sys.argv)==2:
if system=="ubuntu":
os.system("python3 core/s.py "+sys.argv[1])
else:
os.system("python3 core/s.py "+sys.argv[1])
elif len(sys.argv)==5:
if system=="ubuntu":
os.system("python3 core/host.py "+sys.argv[2]+" "+sys.argv[3]+" "+sys.argv[4])
else:
os.system("python3 core/host.py "+sys.argv[2]+" "+sys.argv[3]+" "+sys.argv[4])
else:
print ("error : invalid arguments")
print ("use : myserver --help for more information")
elif sys.argv[1]=="-db":
if len(sys.argv)==3:
if sys.argv[2]=="start":
if system=="ubuntu":
os.system("python3 core/mysql.py "+sys.argv[2])
else:
os.system("python3 core/mysql.py "+sys.argv[2])
elif sys.argv[2]=="stop":
if system=="ubuntu":
os.system("python3 core/mysql.py "+sys.argv[2])
else:
os.system("python3 core/mysql.py "+sys.argv[2])
else:
print ("error : invalid arguments !!")
print ("use : myserver --help for more information")
else:
print ("error : invalid arguments !!")
print ("use : myserver --help for more information")
elif sys.argv[1]=="rm":
if len(sys.argv)==3:
if sys.argv[2]=="-T" or sys.argv[2]=="-t":
if system=="ubuntu":
os.system("sudo python3 core/un.py")
else:
os.system("python3 core/un.py")
else:
print ("error : invalid arguments")
print ("use : myserver --help for more information")
else:
print ("error : invalid arguments")
print ("use : myserver --help for more information")
elif sys.argv[1]=="update":
if system=="ubuntu":
os.system("python3 core/upd.py")
else:
os.system("python3 core/upd.py")
elif sys.argv[1]=="start":
if system=="ubuntu":
os.system("python3 .MyServer.py")
else:
os.system("python3 .MyServer.py")
elif sys.argv[1]=="--help" or sys.argv[1]=="-help" or sys.argv[1]=="help":
print ("")
print ("Usage: myserver [command]... [arguments]...")
print ("")
print (" Commands:")
print (" -s <hostname> <port> <path> to start default localhost server.")
print (" -s -ng <hostname> <port> <path> to start php localhost server.")
print (" -s -php <hostname> <port> <path> to start php localhost server.")
print (" -s -py <hostname> <port> <path> to start python localhost server.")
print (" -h <hostname> <localhost_port> <port> to access localhost server on internet.")
print (" -db [start/stop] to start/stop MySQL database server.")
print (" -s apache to start apache web server.")
print (" update update MyServer.")
print (" rm -t uninstall MyServer.")
print (" start start MyServer menu.")
print ("")
else:
print ("error : invalid arguments !!")
print ("use : myserver --help for more information")