2021-06-25 05:06:53 +02:00
|
|
|
# SubCreator Purpur Build Script
|
|
|
|
#
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
if [[ -z "$version" ]]
|
|
|
|
then
|
|
|
|
echo ERROR: No Build Version Supplied
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
function __DL() {
|
|
|
|
if [[ -x "$(command -v wget)" ]]; then
|
|
|
|
wget -O "$1" "$2"; return $?
|
|
|
|
else
|
2021-06-26 00:26:49 +02:00
|
|
|
curl -Lo "$1" "$2"; return $?
|
2021-06-25 05:06:53 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
function __Restore() {
|
|
|
|
if [[ -f "Purpur.old.jar.x" ]]; then
|
|
|
|
if [[ -f "Purpur.jar" ]]; then
|
|
|
|
rm -Rf Purpur.jar
|
|
|
|
fi
|
|
|
|
mv Purpur.old.jar.x Purpur.jar
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
echo Downloading Purpur...
|
|
|
|
if [[ -f "Purpur.jar" ]]; then
|
|
|
|
if [[ -f "Purpur.old.jar.x" ]]; then
|
|
|
|
rm -Rf Purpur.old.jar.x
|
|
|
|
fi
|
|
|
|
mv Purpur.jar Purpur.old.jar.x
|
|
|
|
fi
|
2021-12-06 09:41:26 +01:00
|
|
|
__DL Purpur.jar "https://api.purpurmc.org/v2/purpur/$version/latest/download"; __RETURN=$?
|
2021-06-25 05:06:53 +02:00
|
|
|
if [[ $__RETURN -eq 0 ]]; then
|
|
|
|
if [[ $(stat -c%s "Purpur.jar") -ge 1000000 ]]; then
|
|
|
|
echo Cleaning Up...
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo ERROR: Received invalid jarfile when requesting Purpur version $version:
|
|
|
|
cat Purpur.jar
|
|
|
|
printf "\n"
|
|
|
|
__Restore
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 4
|
|
|
|
fi
|
|
|
|
else
|
2021-12-06 09:41:26 +01:00
|
|
|
echo ERROR: Failed downloading Purpur. Is PurpurMC.org down?
|
2021-06-25 05:06:53 +02:00
|
|
|
__Restore
|
|
|
|
rm -Rf "$0"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
exit 2
|