-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.sh
67 lines (50 loc) · 2.56 KB
/
script.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
#!/bin/ash
# shellcheck shell=dash
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
printf "Version is valid. Using version %s\n" "${MINECRAFT_VERSION}"
else
printf "Using the latest purpur version\n"
MINECRAFT_VERSION=${LATEST_VERSION}
fi
BUILD_EXISTS=$(curl -s https://api.purpurmc.org/v2/purpur/"${MINECRAFT_VERSION}" | jq -r --arg BUILD "${BUILD_NUMBER}" '.builds.all | tostring | contains($BUILD)' | grep true)
LATEST_BUILD=$(curl -s https://api.purpurmc.org/v2/purpur/"${MINECRAFT_VERSION}" | jq -r '.builds.latest')
if [ "${BUILD_EXISTS}" = "true" ]; then
printf "Build is valid for version %s. Using build %s\n" "${MINECRAFT_VERSION}" "${BUILD_NUMBER}"
else
printf "Using the latest purpur build for version %s\n" "${MINECRAFT_VERSION}"
BUILD_NUMBER=${LATEST_BUILD}
fi
DOWNLOAD_URL=https://api.purpurmc.org/v2/purpur/${MINECRAFT_VERSION}/${BUILD_NUMBER}/download
cd /mnt/server || exit
printf "Downloading Purpur version %s build %s\n" "${MINECRAFT_VERSION}" "${BUILD_NUMBER}"
if [ -f "server.jar" ]; then
mv server.jar server.jar.old
fi
curl -o server.jar "${DOWNLOAD_URL}"
printf "Downloading optimized configuration files\n"
if [ ! -d "config" ]; then
mkdir config
fi
if [ ! -f "server.properties" ]; then
curl -o server.properties https://raw.githubusercontent.com/pyrohost/optimized-minecraft-egg/main/configs/server.properties
fi
if [ ! -f "bukkit.yml" ]; then
curl -o bukkit.yml https://raw.githubusercontent.com/pyrohost/optimized-minecraft-egg/main/configs/bukkit.yml
fi
if [ ! -f "spigot.yml" ]; then
curl -o spigot.yml https://raw.githubusercontent.com/pyrohost/optimized-minecraft-egg/main/configs/spigot.yml
fi
if [ ! -f "config/paper-global.yml" ]; then
curl -o config/paper-global.yml https://raw.githubusercontent.com/pyrohost/optimized-minecraft-egg/main/configs/paper-global.yml
fi
if [ ! -f "config/paper-world-defaults.yml" ]; then
curl -o config/paper-world-defaults.yml https://raw.githubusercontent.com/pyrohost/optimized-minecraft-egg/main/configs/paper-world-defaults.yml
fi
if [ ! -f "pufferfish.yml" ]; then
curl -o pufferfish.yml https://raw.githubusercontent.com/pyrohost/optimized-minecraft-egg/main/configs/pufferfish.yml
fi
if [ ! -f "config/purpur.yml" ]; then
curl -o purpur.yml https://raw.githubusercontent.com/pyrohost/optimized-minecraft-egg/main/configs/purpur.yml
fi