#!/bin/bash set -e function buildSpigotFromSource { echo "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee" mkdir /data/temp cd /data/temp jvmOpts="-Xms${INIT_MEMORY:-$MEMORY} -Xmx${MAX_MEMORY:-$MEMORY}" 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 $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; echo "done" if ! mv spigot-*.jar /data/spigot_server.jar; then echo "ERR failed to build Spigot" cat /data/spigot_build.log exit 1 fi mv craftbukkit-*.jar /data/craftbukkit_server.jar echo "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 local downloadVersion if [[ ${VERSION} == LATEST ]]; then downloadVersion=${VANILLA_VERSION} else downloadVersion=${VERSION} fi if [[ -z $downloadUrl ]]; then downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${downloadVersion}.jar" fi echo "Downloading $match from $downloadUrl ..." curl -fsSL -o $SERVER "$downloadUrl" if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then cat <