[mc] Detect and display curl error during Spigot/Bukkit download

#74
This commit is contained in:
Geoff Bourne 2016-04-24 10:50:48 -05:00
parent 3052cd1155
commit b9f247728f

View file

@ -60,10 +60,20 @@ function downloadSpigot {
esac esac
curl -o /tmp/versions -sSL https://getspigot.org/api/getversions curl -o /tmp/versions -sSL https://getspigot.org/api/getversions
status=$?
if [ $status != 0 ]; then
echo "ERROR: failed to access Spigot versions (curl error code was $status)"
exit 3
fi
downloadUrl=$(cat /tmp/versions | jq -r ".[] | select(.version == \"$match\") | .downloadUrl") downloadUrl=$(cat /tmp/versions | jq -r ".[] | select(.version == \"$match\") | .downloadUrl")
if [[ -n $downloadUrl ]]; then if [[ -n $downloadUrl ]]; then
echo "Downloading $match" echo "Downloading $match"
curl -o $SERVER -sSL "$downloadUrl" curl -o $SERVER -sSL "x$downloadUrl"
status=$?
if [ $status != 0 ]; then
echo "ERROR: failed to download from $downloadUrl due to (curl error code was $status)"
exit 3
fi
else else
echo "ERROR: Version $VANILLA_VERSION is not supported for $TYPE" echo "ERROR: Version $VANILLA_VERSION is not supported for $TYPE"
echo " Refer to http://getspigot.org for supported versions" echo " Refer to http://getspigot.org for supported versions"