-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
start-deployBukkitSpigot
executable file
·133 lines (112 loc) · 3.58 KB
/
start-deployBukkitSpigot
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
#!/bin/bash
# shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils"
isDebugging && set -x
set -e
function buildSpigotFromSource {
if [[ ${TYPE^^} = *BUKKIT ]] && ! versionLessThan "1.14"; then
log "ERR craftbukkit build is only supported for versions less than 1.14"
exit 1
fi
log "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
rm -rf /data/temp
mkdir /data/temp
cd /data/temp
jvmOpts="-Xms${INIT_MEMORY:-$MEMORY} -Xmx${MAX_MEMORY:-$MEMORY}"
logn ''
curl -sSL -o /data/temp/BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
java $jvmOpts -jar /data/temp/BuildTools.jar --rev "$VERSION" 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; log "done"
case ${TYPE^^} in
SPIGOT)
if ! mv spigot-*.jar /data/${SERVER}; then
log "ERR failed to build Spigot"
cat /data/spigot_build.log
exit 1
fi
;;
*BUKKIT)
if ! mv craftbukkit-*.jar /data/${SERVER}; then
log "ERR failed to build Spigot"
cat /data/spigot_build.log
exit 1
fi
;;
esac
log "Cleaning up"
rm -rf /data/temp
cd /data
}
function downloadSpigot {
local match
case "$TYPE" in
*BUKKIT|*bukkit)
match="CraftBukkit"
downloadUrl=${BUKKIT_DOWNLOAD_URL}
getbukkitFlavor=craftbukkit
;;
*)
match="Spigot"
downloadUrl=${SPIGOT_DOWNLOAD_URL}
getbukkitFlavor=spigot
;;
esac
if [[ ${VERSION^^} = LATEST ]]; then
VERSION=$(restify https://getbukkit.org/download/spigot --attribute='property=og:title' | jq -r '.[0] | .attributes | select(.property == "og:title") | .content | split(" ") | .[-1]')
fi
if [[ -z $downloadUrl ]]; then
if versionLessThan 1.16.5 || ([[ ${getbukkitFlavor} = "craftbukkit" ]] && [[ ${VERSION} = "1.16.5" ]]); then
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VERSION}.jar"
else
downloadUrl="https://download.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VERSION}.jar"
fi
fi
setServerVar
if [ -f "$SERVER" ] && ! isTrue "$FORCE_REDOWNLOAD"; then
# tell curl to only download when newer
curlArgs="-z $SERVER"
fi
if isDebugging; then
curlArgs="$curlArgs -v"
fi
log "Downloading $match from $downloadUrl ..."
curl -fsSL -o "$SERVER" $curlArgs "$downloadUrl"
if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then
cat <<EOF
ERROR: failed to download from $downloadUrl
Visit https://getbukkit.org/download/${getbukkitFlavor} to lookup the
exact version, such as 1.4.6-R0.4-SNAPSHOT or 1.8-R0.1-SNAPSHOT-latest.
Click into the version entry to find the **exact** version, because something
like "1.8" is not sufficient according to their download naming.
EOF
if isDebugging && [[ $(grep -c "DOCTYPE html" "$SERVER") != 0 ]]; then
cat "$SERVER"
fi
# remove invalid download
rm "$SERVER"
exit 3
fi
JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
export JVM_OPTS
}
function setServerVar {
case "$TYPE" in
*BUKKIT|*bukkit)
export SERVER=craftbukkit_server-${VERSION}.jar
;;
*)
export SERVER=spigot_server-${VERSION}.jar
;;
esac
}
if isTrue "$BUILD_SPIGOT_FROM_SOURCE" || isTrue "$BUILD_FROM_SOURCE"; then
resolveVersion
setServerVar
if [ ! -f "$SERVER" ] || isTrue "$FORCE_REDOWNLOAD"; then
buildSpigotFromSource
fi
else
downloadSpigot
fi
# Normalize on Spigot for operations below
export FAMILY=SPIGOT
exec ${SCRIPTS:-/}start-spiget "$@"