2018-10-01 23:44:37 +02:00
|
|
|
# SubCreator Spigot Build Script
|
|
|
|
#
|
|
|
|
#!/usr/bin/env bash
|
2019-06-17 05:13:48 +02:00
|
|
|
if [[ -z "$version" ]]
|
2018-10-01 23:44:37 +02:00
|
|
|
then
|
|
|
|
echo ERROR: No Build Version Supplied
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-12-18 20:15:02 +01:00
|
|
|
if [[ -z "$java" ]]
|
|
|
|
then
|
|
|
|
export java="java"
|
|
|
|
fi
|
2018-10-01 23:44:37 +02:00
|
|
|
function __DL() {
|
2019-06-17 05:13:48 +02:00
|
|
|
if [[ -x "$(command -v wget)" ]]; then
|
2018-10-01 23:44:37 +02:00
|
|
|
wget -O "$1" "$2"; return $?
|
|
|
|
else
|
|
|
|
curl -o "$1" "$2"; return $?
|
|
|
|
fi
|
|
|
|
}
|
2019-06-17 05:13:48 +02:00
|
|
|
if [[ -z "$cache" ]] || [[ ! -f "$cache/Spigot-$version.jar" ]] || [[ "$mode" == "UPDATE" && $(find "$cache/Spigot-$version.jar" -mtime +1 -print) ]]; then
|
2018-10-01 23:44:37 +02:00
|
|
|
echo Downloading Buildtools...
|
|
|
|
__DL Buildtools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar; __RETURN=$?
|
2019-06-17 05:13:48 +02:00
|
|
|
if [[ $__RETURN -eq 0 ]]; then
|
|
|
|
if [[ -d "Buildtools" ]]; then
|
2018-10-01 23:44:37 +02:00
|
|
|
rm -Rf Buildtools
|
|
|
|
fi
|
|
|
|
mkdir Buildtools
|
|
|
|
cd "Buildtools"
|
|
|
|
echo Launching Buildtools
|
2019-06-17 05:13:48 +02:00
|
|
|
if [[ ! -z "$cache" ]] && [[ -d "$cache" ]]; then
|
2018-10-01 23:44:37 +02:00
|
|
|
export __HOME="$HOME"
|
2019-01-14 01:52:44 +01:00
|
|
|
export HOME="$cache"
|
2018-10-01 23:44:37 +02:00
|
|
|
fi
|
|
|
|
export MAVEN_OPTS="-Xms2G"
|
2019-12-18 20:15:02 +01:00
|
|
|
"$java" -Xms2G -jar ../Buildtools.jar --rev "$version"; __RETURN=$?
|
2019-06-17 05:13:48 +02:00
|
|
|
if [[ ! -z "$cache" ]] && [[ ! -z "$__HOME" ]] && [[ "$cache" == "$HOME" ]]; then
|
2018-10-01 23:44:37 +02:00
|
|
|
export HOME="$__HOME"
|
|
|
|
fi
|
|
|
|
cd ../
|
2019-06-17 05:13:48 +02:00
|
|
|
if [[ $__RETURN -eq 0 ]]; then
|
2018-10-01 23:44:37 +02:00
|
|
|
echo Copying Finished Jar...
|
2019-06-17 05:13:48 +02:00
|
|
|
if [[ -f "Spigot.jar" ]]; then
|
|
|
|
if [[ -f "Spigot.old.jar.x" ]]; then
|
|
|
|
rm -Rf Spigot.old.jar.x
|
|
|
|
fi
|
|
|
|
mv Spigot.jar Spigot.old.jar.x
|
|
|
|
fi
|
|
|
|
if [[ ! -z "$cache" ]] && [[ -d "$cache" ]]; then
|
|
|
|
if [[ -f "$cache/Spigot-$version.jar" ]]; then
|
|
|
|
rm -Rf "$cache/Spigot-$version.jar"
|
|
|
|
fi
|
2019-01-14 01:52:44 +01:00
|
|
|
cp Buildtools/spigot-*.jar "$cache/Spigot-$version.jar"
|
2018-10-01 23:44:37 +02:00
|
|
|
fi
|
|
|
|
cp Buildtools/spigot-*.jar Spigot.jar
|
|
|
|
echo Cleaning Up...
|
|
|
|
rm -Rf Buildtools.jar
|
|
|
|
rm -Rf Buildtools
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo ERROR: Buildtools exited with an error. Please try again
|
|
|
|
rm -Rf Buildtools.jar
|
|
|
|
rm -Rf Buildtools
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 4
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo ERROR: Failed downloading Buildtools. Is SpigotMC.org down?
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo Copying Cached Jar...
|
2019-01-14 01:52:44 +01:00
|
|
|
cp "$cache/Spigot-$version.jar" Spigot.jar
|
2018-10-01 23:44:37 +02:00
|
|
|
echo Cleaning Up...
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
exit 2
|