-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.py
More file actions
158 lines (124 loc) · 4.09 KB
/
Test.py
File metadata and controls
158 lines (124 loc) · 4.09 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
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
import os
import sys
import time
import codecs
from source import *
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
PORT=25565
cores = ''
versions = ''
selectCoreCorrect = False
selectVersionCorrect = False
downloadSuccess = False
with open('Welcome','r',encoding = "UTF-8") as f:
lines=f.readlines()
for line in lines:
print(line,end='')
#login
print('')
print('Press "Enter" to continue... ')
input()
os.system('clear')
print('='*40)
print('Checking java version...')
os.system("java -version 2>&1 | awk -F[\\\"_] 'NR==1{print $2}'")
print('-'*40)
#core
print('Minecraft Server Core lists:')
while(not selectCoreCorrect):
for core in source.keys():
print('- '+core)
print('Please select a Minecraft Server Core:',end=' ')
cores = input().strip()
if cores in source.keys():
selectCoreCorrect = True
#version
os.system('clear')
print("Minecraft-"+cores+'-'+(versions if versions!='' else '?')+'.')
print('------------------------------')
print(cores + ' is selected!\n')
print('Minecraft version lists:')
while(not selectVersionCorrect):
for version in source[cores].keys():
print('- '+version)
print('Please select a Minecraft version:',end=' ')
versions = input().strip()
if versions in source[cores].keys():
selectVersionCorrect = True
#channel
os.system('clear')
print("Minecraft-"+cores+'-'+(versions if versions!='' else '?')+'.')
print('------------------------------')
print('We provide cpolar channel though you need to get token on https://www.cpolar.com/.')
print('Create a channel (y/n): ', end='')
createChannel = False if input() == 'n' else True
# channelCreated = False
def channel():
# global channelCreated
print('Enter your cpolar token (Empty if already setted): ',end='')
token = input()
print()
if token!='':
os.system('cpolar authtoken ' + token.strip())
# os.system('rm -rf ./cpolar')
cmd = 'cpolar tcp 25565 -log=stdout | grep --color=auto "1.tcp.cpolar.cn:" &'
# cmd = 'cpolar tcp '+str(PORT)+' -log="./cpolar/cpolar.log" &'
os.system(cmd)
# time.sleep(5)
print('Coppy the following sockets and Press "Enter" to continue.')
input()
# channelCreated = True
# print('Thread End.')
if createChannel:
channel()
# _thread.start_new_thread ( channel(), )
#download
os.system('clear')
print("Minecraft-"+cores+'-'+(versions if versions!='' else '?')+'.')
print('------------------------------')
print(versions + ' is selected!\n')
while(not downloadSuccess):
# os.system('rm -rf ./LocalServer')
# os.system('mkdir LocalServer')
os.system('wget '+source[cores][versions] + ' -O ./LocalServer/server.jar')
print(os.listdir(os.getcwd() + '/LocalServer'))
if 'server.jar' in os.listdir(os.getcwd() + '/LocalServer'):
downloadSuccess = True
print('Download Success!!')
# input()
break
else:
print('Download Failed ~')
print('You can:\n1.Retry\n2.Exit\n----')
choice = input().strip()
if choice == 'Exit' or choice == '2':
exit()
#install
os.system('clear')
os.chdir(os.getcwd()+'/LocalServer')
print("Minecraft-"+cores+'-'+(versions if versions!='' else '?')+'.')
print('------------------------------')
print('set RAM? (y/n) ',end='')
choice = input()
if choice == 'y':
maxRAM = -1
minRAM = -1
try:
print('Set Memory MB.')
print('Max RAM: ',end='')
maxRAM = int(input())
print('\nMin RAM: ',end='')
minRAM = int(input())
print()
if maxRAM >= minRAM:
os.system('java -Xmx'+maxRAM+'M -Xms'+minRAM+'M -jar server.jar nogui')
else:
print('parameter error using default')
os.system('java -jar server.jar nogui')
except:
print('parameter error using default')
os.system('java -jar server.jar nogui')
else:
os.system('java -jar server.jar nogui')
while True:
pass