Changed Paper update process to check FORCE_REDOWNLOAD first

For #634
This commit is contained in:
Geoff Bourne 2020-09-16 17:09:16 -05:00
parent 0ddabf3089
commit 7c3139226c

View File

@ -2,42 +2,46 @@
. ${SCRIPTS:-/}start-utils . ${SCRIPTS:-/}start-utils
set -o pipefail set -o pipefail
isDebugging && set -x
: ${PAPERBUILD:=latest} : ${PAPERBUILD:=latest}
export SERVER=paper_server-${VANILLA_VERSION}-${PAPERBUILD}.jar export SERVER=paper_server-${VANILLA_VERSION}-${PAPERBUILD}.jar
if [ -f "$SERVER" ] && ! isTrue "$FORCE_REDOWNLOAD"; then if [ ! -f "$SERVER" ] || isTrue "$FORCE_REDOWNLOAD"; then
zarg="-z '$SERVER'"
fi
downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/${PAPERBUILD}/download} if [ -f "$SERVER" ]; then
log "Downloading Paper $VANILLA_VERSION (build $PAPERBUILD) from $downloadUrl ..." zarg=(-z "$SERVER")
out=$(curl -fsSL -o "$SERVER" $zarg "$downloadUrl" 2>&1) fi
case $? in
0) downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/${PAPERBUILD}/download}
;; log "Downloading Paper $VANILLA_VERSION (build $PAPERBUILD) from $downloadUrl ..."
22) # = 404 HTTP status out=$(curl -fsSL -o "$SERVER" "${zarg[@]}" "$downloadUrl" 2>&1)
if versions=$(curl -fsSL https://papermc.io/api/v1/paper 2> /dev/null); then case $? in
if [[ $VERSION = LATEST ]]; then 0)
VANILLA_VERSION=$(echo $versions | jq -r '.versions[0]') ;;
log "WARN: using ${VANILLA_VERSION} since that's the latest provided by PaperMC" 22) # = 404 HTTP status
# re-execute the current script with the newly computed version if versions=$(curl -fsSL https://papermc.io/api/v1/paper 2> /dev/null); then
exec $0 "$@" if [[ $VERSION = LATEST ]]; then
VANILLA_VERSION=$(echo $versions | jq -r '.versions[0]')
log "WARN: using ${VANILLA_VERSION} since that's the latest provided by PaperMC"
# re-execute the current script with the newly computed version
exec $0 "$@"
fi
log "ERROR: ${VANILLA_VERSION} is not (yet) published by PaperMC"
log " Set VERSION to one of the following: "
log " $(echo $versions | jq -r '.versions | join(", ")')"
else
log "ERROR: failed to retrieve versions from https://papermc.io/api/v1/paper"
fi fi
log "ERROR: ${VANILLA_VERSION} is not (yet) published by PaperMC" exit 3
log " Set VERSION to one of the following: " ;;
log " $(echo $versions | jq -r '.versions | join(", ")')" *)
else log "ERROR: failed to contact PaperMC at $downloadUrl"
log "ERROR: failed to retrieve versions from https://papermc.io/api/v1/paper" log " $out"
fi exit 3
exit 3 ;;
;; esac
*) fi
log "ERROR: failed to contact PaperMC at $downloadUrl"
log " $out"
exit 3
;;
esac
# Normalize on Spigot for downstream operations # Normalize on Spigot for downstream operations
export TYPE=SPIGOT export TYPE=SPIGOT