-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
329 lines (257 loc) · 9.1 KB
/
install.sh
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/bash
display() {
echo -e "\033c"
echo "
==========================================================================
$(tput setaf 6) ⠀⠀⠀⠀⠀ ⠀ ⠻⣷⣄
$(tput setaf 6)⠀⠀⠀ ⠀ ⢀⣴⣿⣿⣿⡿⠋⠀ ⠹⣿⣦⡀
$(tput setaf 6)⠀⠀ ⢀⣴⣿⣿⣿⣿⣏⠀⠀⠀⠀⠀⠀⢹⣿⣧
$(tput setaf 6)⠀ ⠙⢿⣿⡿⠋⠻⣿⣿⣦⡀⠀⠀⠀⢸⣿⣿⡆
$(tput setaf 6)⠀ ⠀⠀⠉⠀⠀⠀⠈⠻⣿⣿⣦⡀⠀⢸⣿⣿⡇
$(tput setaf 6)⠀⠀⠀⠀ ⢀⣀⣄⡀⠀⠀⠈⠻⣿⣿⣶⣿⣿⣿⠁
$(tput setaf 6)⠀⠀⠀ ⣠⣿⣿⢿⣿⣶⣶⣶⣶⣾⣿⣿⣿⣿⡁
$(tput setaf 6) ⢠⣶⣿⣿⠋⠀⠀⠉⠛⠿⠿⠿⠿⠿⠛⠻⣿⣿⣦⡀
$(tput setaf 6) ⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⡿
$(tput setaf 6)
$(tput setaf 6)
$(tput setaf 6) ☭ Народная армия непобедима!
$(tput setaf 6)
$(tput setaf 6)
$(tput setaf 6)
$(tput setaf 6) COPYRIGHT 2024 ReyoServers Technology (https://reyo.run) & https://github.com/AvexXS
==========================================================================
"
}
forceStuffs() {
mkdir -p plugins && mkdir -p plugins/noMemberShutdown
cd plugins && curl -O https://raw.githubusercontent.com/AvexXS/sovietegg/main/Reya.jar && cd ../.
cd plugins && curl -O https://www.spigotmc.org/resources/spark.57242/download?version=489830 && cd ../.
echo "eula=true" > eula.txt
}
# Install functions
installJq() {
if [ ! -e "tmp/jq" ]; then
mkdir -p tmp
curl -s -o tmp/jq -L https://github.com/jqlang/jq/releases/download/jq-1.7rc1/jq-linux-amd64
chmod +x tmp/jq
fi
}
cleanup_files() {
rm -f jitdump*.dmp javacore*.txt core*.dmp Snap*.trc
}
cleanup_files
installPhp() {
installJq
REQUIRED_PHP_VERSION=$(curl -sSL https://update.pmmp.io/api?channel="$1" | jq -r '.php_version')
PMMP_VERSION="$2"
curl --location --progress-bar https://github.com/pmmp/PHP-Binaries/releases/download/php-"$REQUIRED_PHP_VERSION"-latest/PHP-Linux-x86_64-"$PMMP_VERSION".tar.gz | tar -xzv
EXTENSION_DIR=$(find "bin" -name '*debug-zts*')
grep -q '^extension_dir' bin/php7/bin/php.ini && sed -i'bak' "s{^extension_dir=.*{extension_dir=\"$EXTENSION_DIR\"{" bin/php7/bin/php.ini || echo "extension_dir=\"$EXTENSION_DIR\"" >>bin/php7/bin/php.ini
}
# Useful functions
jq() {
tmp/jq "$@"
}
# Validation functions
validateJavaVersion() {
if [ ! "$(command -v java)" ]; then
echo "Java is missing! Please ensure the 'Java' Docker image is selected in the startup options and then restart the server."
sleep 5
exit
fi
installJq
VER_EXISTS=$(curl -s https://api.papermc.io/v2/projects/paper | jq -r --arg VERSION $MINECRAFT_VERSION '.versions[] | contains($VERSION)' | grep -m1 true)
LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/paper | jq -r '.versions' | jq -r '.[-1]')
}
# Launch functions
launchJavaServer() {
# Remove 200 mb to prevent server freeze
number=200
memory=$((SERVER_MEMORY - number))
java -Xms128M -Xmx${memory}M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui
}
launchPMMPServer() {
if [ ! "$(command -v ./bin/php7/bin/php)" ]; then
echo "Php not found, installing Php..."
sleep 5
PMMP_VERSION="${PMMP_VERSION^^}"
if [[ "${PMMP_VERSION}" == "PM4" ]]; then
API_CHANNEL="4"
elif [[ "${PMMP_VERSION}" == "PM5" ]]; then
API_CHANNEL="stable"
else
printf "Unsupported version: %s" "${PMMP_VERSION}"
exit 1
fi
installPhp "$API_CHANNEL" "$PMMP_VERSION"
sleep 5
fi
./bin/php7/bin/php ./PocketMine-MP.phar --no-wizard --disable-ansi
}
launchNodeServer() {
if [ ! "$(command -v node)" ]; then
echo "Node.js is missing! Please ensure the 'NodeJS' Docker image is selected in the startup options and then restart the server."
sleep 5
exit
fi
if [ -n "$NODE_DEFAULT_ACTION" ]; then
action="$NODE_DEFAULT_ACTION"
else
echo "
$(tput setaf 3)What to run?
1) Run main file 2) Install packages from package.json
"
read -r action
fi
case $action in
1)
if [[ "${NODE_MAIN_FILE}" == "*.js" ]]; then
node "${NODE_MAIN_FILE}"
else
if [ ! "$(command -v ts-node)" ]; then
echo "ts-nods is missing! Your selected nodejs version doesn't support ts-node."
sleep 5
exit
fi
ts-node "${NODE_MAIN_FILE}"
fi
;;
2)
npm install
;;
*)
echo "Error 404"
exit
;;
esac
}
optimizeJavaServer() {
echo "view-distance=6" >> server.properties
}
if [ ! -e "server.jar" ] && [ ! -e "nodejs" ] && [ ! -e "PocketMine-MP.phar" ]; then
display
sleep 5
echo "
$(tput setaf 3)Which platform are you gonna use?
1) Paper 2) Purpur
3) BungeeCord 4) PocketmineMP
"
read -r n
case $n in
1)
sleep 1
echo "$(tput setaf 3)Starting the download for PaperMC ${MINECRAFT_VERSION} please wait"
sleep 4
forceStuffs
installJq
VER_EXISTS=$(curl -s https://api.papermc.io/v2/projects/paper | jq -r --arg VERSION $MINECRAFT_VERSION '.versions[] | contains($VERSION)' | grep -m1 true)
LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/paper | jq -r '.versions' | jq -r '.[-1]')
if [ "${VER_EXISTS}" == "true" ]; then
echo -e "Version is valid. Using version ${MINECRAFT_VERSION}"
else
echo -e "Specified version not found. Defaulting to the latest paper version"
MINECRAFT_VERSION=${LATEST_VERSION}
fi
BUILD_NUMBER=$(curl -s https://api.papermc.io/v2/projects/paper/versions/${MINECRAFT_VERSION} | jq -r '.builds' | jq -r '.[-1]')
JAR_NAME=paper-${MINECRAFT_VERSION}-${BUILD_NUMBER}.jar
DOWNLOAD_URL=https://api.papermc.io/v2/projects/paper/versions/${MINECRAFT_VERSION}/builds/${BUILD_NUMBER}/downloads/${JAR_NAME}
curl -o server.jar "${DOWNLOAD_URL}"
display
echo -e ""
optimizeJavaServer
launchJavaServer
forceStuffs
;;
2)
sleep 1
echo "$(tput setaf 3)Starting the download for PurpurMC ${MINECRAFT_VERSION} please wait"
sleep 4
forceStuffs
installJq
VER_EXISTS=$(curl -s https://api.purpurmc.org/v2/purpur | jq -r --arg VERSION $MINECRAFT_VERSION '.versions[] | contains($VERSION)' | grep true)
LATEST_VERSION=$(curl -s https://api.purpurmc.org/v2/purpur | jq -r '.versions' | jq -r '.[-1]')
if [ "${VER_EXISTS}" == "true" ]; then
echo -e "Version is valid. Using version ${MINECRAFT_VERSION}"
else
echo -e "Specified version not found. Defaulting to the latest purpur version"
MINECRAFT_VERSION=${LATEST_VERSION}
fi
BUILD_NUMBER=$(curl -s https://api.purpurmc.org/v2/purpur/${MINECRAFT_VERSION} | jq -r '.builds.latest')
JAR_NAME=purpur-${MINECRAFT_VERSION}-${BUILD_NUMBER}.jar
DOWNLOAD_URL=https://api.purpurmc.org/v2/purpur/${MINECRAFT_VERSION}/${BUILD_NUMBER}/download
curl -o server.jar "${DOWNLOAD_URL}"
display
echo -e ""
optimizeJavaServer
launchJavaServer
forceStuffs
;;
3)
sleep 1
echo "$(tput setaf 3)Starting the download for Bungeecord latest please wait"
sleep 4
curl -o server.jar https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar
touch proxy
display
sleep 10
echo -e ""
launchJavaServer proxy
;;
4)
sleep 1
echo "$(tput setaf 3)Starting the download for PocketMine-MP ${PMMP_VERSION} please wait"
sleep 4
PMMP_VERSION="${PMMP_VERSION^^}"
if [[ "${PMMP_VERSION}" == "PM4" ]]; then
API_CHANNEL="4"
elif [[ "${PMMP_VERSION}" == "PM5" ]]; then
API_CHANNEL="stable"
else
printf "Unsupported version: %s" "${PMMP_VERSION}"
exit 1
fi
if [ ! "$(command -v ./bin/php7/bin/php)" ]; then
installPhp "$API_CHANNEL" "$PMMP_VERSION"
sleep 5
fi
installJq
DOWNLOAD_LINK=$(curl -sSL https://update.pmmp.io/api?channel="$API_CHANNEL" | jq -r '.download_url')
curl --location --progress-bar "${DOWNLOAD_LINK}" --output PocketMine-MP.phar
display
echo -e ""
launchPMMPServer
;;
5)
echo "$(tput setaf 3)Starting Download please wait"
touch nodejs
display
sleep 10
echo -e ""
launchNodeServer
;;
*)
echo "Error 404"
exit
;;
esac
else
if [ -e "server.jar" ]; then
display
forceStuffs
if [ -e "proxy" ]; then
launchJavaServer proxy
else
launchJavaServer
fi
elif [ -e "PocketMine-MP.phar" ]; then
display
launchPMMPServer
elif [ -e "nodejs" ]; then
display
launchNodeServer
fi
fi
while true; do
sleep 30
cleanup_files
done