2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-19 16:05:32 +00:00
|
|
|
. ${SCRIPTS:-/}start-utils
|
2020-10-30 22:03:13 +00:00
|
|
|
isDebugging && set -x
|
2020-03-06 15:52:17 +00:00
|
|
|
|
2019-02-27 04:19:43 +00:00
|
|
|
set -e
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
function buildSpigotFromSource {
|
2020-05-12 01:14:01 +00:00
|
|
|
if [[ ${TYPE^^} = *BUKKIT ]] && ! versionLessThan "1.14"; then
|
|
|
|
log "ERR craftbukkit build is only supported for versions less than 1.14"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
|
2019-07-23 02:33:54 +00:00
|
|
|
rm -rf /data/temp
|
2017-11-01 05:42:44 +00:00
|
|
|
mkdir /data/temp
|
|
|
|
cd /data/temp
|
2019-02-27 04:19:43 +00:00
|
|
|
|
|
|
|
jvmOpts="-Xms${INIT_MEMORY:-$MEMORY} -Xmx${MAX_MEMORY:-$MEMORY}"
|
|
|
|
|
2020-03-06 15:52:17 +00:00
|
|
|
logn ''
|
2018-06-26 00:13:47 +00:00
|
|
|
curl -sSL -o /data/temp/BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
|
2020-03-06 15:52:17 +00:00
|
|
|
java $jvmOpts -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; log "done"
|
2020-05-12 01:14:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Cleaning up"
|
2017-11-01 05:42:44 +00:00
|
|
|
rm -rf /data/temp
|
|
|
|
cd /data
|
|
|
|
}
|
|
|
|
|
|
|
|
function downloadSpigot {
|
|
|
|
local match
|
|
|
|
case "$TYPE" in
|
|
|
|
*BUKKIT|*bukkit)
|
2018-08-18 23:51:45 +00:00
|
|
|
match="CraftBukkit"
|
2017-11-01 05:42:44 +00:00
|
|
|
downloadUrl=${BUKKIT_DOWNLOAD_URL}
|
2018-03-16 22:03:21 +00:00
|
|
|
getbukkitFlavor=craftbukkit
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
match="Spigot"
|
|
|
|
downloadUrl=${SPIGOT_DOWNLOAD_URL}
|
2018-03-16 22:03:21 +00:00
|
|
|
getbukkitFlavor=spigot
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-09-27 15:21:33 +00:00
|
|
|
if [[ ${VERSION^^} = LATEST ]]; then
|
|
|
|
VANILLA_VERSION=$(restify https://getbukkit.org/download/spigot --attribute='property=og:title' | jq -r '.[0] | .attributes | select(.property == "og:title") | .content | split(" ") | .[-1]')
|
|
|
|
fi
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
if [[ -z $downloadUrl ]]; then
|
2020-02-02 14:09:54 +00:00
|
|
|
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar"
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
2020-07-11 18:17:28 +00:00
|
|
|
if [ -f $SERVER ]; then
|
|
|
|
# tell curl to only download when newer
|
|
|
|
zarg="-z $SERVER"
|
|
|
|
fi
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Downloading $match from $downloadUrl ..."
|
2020-11-03 22:47:46 +00:00
|
|
|
curl -fsSL -o $SERVER $zarg "$downloadUrl"
|
|
|
|
if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then
|
2018-03-16 22:03:21 +00:00
|
|
|
cat <<EOF
|
|
|
|
|
|
|
|
ERROR: failed to download from $downloadUrl
|
|
|
|
Visit https://getbukkit.org/download/${getbukkitFlavor} to lookup the
|
2018-08-18 23:51:45 +00:00
|
|
|
exact version, such as 1.4.6-R0.4-SNAPSHOT or 1.8-R0.1-SNAPSHOT-LATEST
|
2018-03-16 22:03:21 +00:00
|
|
|
|
|
|
|
EOF
|
2017-11-01 05:42:44 +00:00
|
|
|
exit 3
|
|
|
|
fi
|
2020-04-18 23:42:55 +00:00
|
|
|
|
|
|
|
JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
|
|
|
|
export JVM_OPTS
|
2017-11-01 05:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$TYPE" in
|
|
|
|
*BUKKIT|*bukkit)
|
2020-02-02 14:09:54 +00:00
|
|
|
export SERVER=craftbukkit_server-${VANILLA_VERSION}.jar
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
*)
|
2020-02-02 14:09:54 +00:00
|
|
|
export SERVER=spigot_server-${VANILLA_VERSION}.jar
|
2017-11-01 05:42:44 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-07-11 18:17:28 +00:00
|
|
|
if isTrue "$BUILD_SPIGOT_FROM_SOURCE" || isTrue "$BUILD_FROM_SOURCE"; then
|
|
|
|
if [ ! -f $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
|
|
|
buildSpigotFromSource
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
downloadSpigot
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Normalize on Spigot for operations below
|
|
|
|
export TYPE=SPIGOT
|
2020-04-21 23:30:48 +00:00
|
|
|
export SKIP_LOG4J_CONFIG=true
|
2017-11-01 05:42:44 +00:00
|
|
|
|
|
|
|
# Continue to Final Setup
|
2020-07-06 22:16:51 +00:00
|
|
|
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|