docker-minecraft-server/start-deployBukkitSpigot

117 lines
3 KiB
Text
Raw Normal View History

2017-11-01 05:42:44 +00:00
#!/bin/bash
. ${SCRIPTS:-/}start-utils
isDebugging && set -x
2020-03-06 15:52:17 +00:00
set -e
2017-11-01 05:42:44 +00:00
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
2020-03-06 15:52:17 +00:00
log "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
rm -rf /data/temp
2017-11-01 05:42:44 +00:00
mkdir /data/temp
cd /data/temp
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"
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)
match="CraftBukkit"
2017-11-01 05:42:44 +00:00
downloadUrl=${BUKKIT_DOWNLOAD_URL}
getbukkitFlavor=craftbukkit
2017-11-01 05:42:44 +00:00
;;
*)
match="Spigot"
downloadUrl=${SPIGOT_DOWNLOAD_URL}
getbukkitFlavor=spigot
2017-11-01 05:42:44 +00:00
;;
esac
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
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar"
2017-11-01 05:42:44 +00:00
fi
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 ..."
tmpJar=/tmp/${getbukkitFlavor}.jar
curl -fsSL -o "$tmpJar" $zarg "$downloadUrl"
if [[ $? != 0 || $(grep -c "DOCTYPE html" $tmpJar) != 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
EOF
2017-11-01 05:42:44 +00:00
exit 3
fi
mv "$tmpJar" "$SERVER"
JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
export JVM_OPTS
2017-11-01 05:42:44 +00:00
}
case "$TYPE" in
*BUKKIT|*bukkit)
export SERVER=craftbukkit_server-${VANILLA_VERSION}.jar
2017-11-01 05:42:44 +00:00
;;
*)
export SERVER=spigot_server-${VANILLA_VERSION}.jar
2017-11-01 05:42:44 +00:00
;;
esac
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
export SKIP_LOG4J_CONFIG=true
2017-11-01 05:42:44 +00:00
# Continue to Final Setup
exec ${SCRIPTS:-/}start-finalSetupWorld $@