2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-02-27 04:19:43 +00:00
|
|
|
set -e
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
function buildSpigotFromSource {
|
|
|
|
echo "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}"
|
|
|
|
|
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 && \
|
2019-02-27 04:19:43 +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; 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
|
2020-02-02 14:09:54 +00:00
|
|
|
mv craftbukkit-*.jar /data/${SERVER}
|
2017-11-01 05:42:44 +00:00
|
|
|
echo "Cleaning up"
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-07-29 18:41:00 +00:00
|
|
|
echo "Downloading $match from $downloadUrl ..."
|
2018-08-18 23:51:45 +00:00
|
|
|
curl -fsSL -o $SERVER "$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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-06-12 18:33:10 +00:00
|
|
|
if [ ! -f $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
2017-11-01 05:42:44 +00:00
|
|
|
if [[ "$BUILD_SPIGOT_FROM_SOURCE" = TRUE || "$BUILD_SPIGOT_FROM_SOURCE" = true || "$BUILD_FROM_SOURCE" = TRUE || "$BUILD_FROM_SOURCE" = true ]]; then
|
|
|
|
buildSpigotFromSource
|
|
|
|
else
|
|
|
|
downloadSpigot
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Normalize on Spigot for operations below
|
|
|
|
export TYPE=SPIGOT
|
|
|
|
|
|
|
|
# Continue to Final Setup
|
|
|
|
exec /start-finalSetup01World $@
|