mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
parent
f68e979229
commit
08a4bde6c1
@ -4,43 +4,54 @@
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
isDebugging && set -x
|
isDebugging && set -x
|
||||||
|
|
||||||
: ${PAPERBUILD:=latest}
|
# PaperMC API v2 docs : https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config
|
||||||
export SERVER=paper_server-${VANILLA_VERSION}-${PAPERBUILD}.jar
|
|
||||||
|
|
||||||
if [ ! -f "$SERVER" ] || isTrue "$FORCE_REDOWNLOAD"; then
|
build=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}" -H "accept: application/json" \
|
||||||
|
| jq '.builds[-1]')
|
||||||
|
case $? in
|
||||||
|
0)
|
||||||
|
;;
|
||||||
|
22)
|
||||||
|
versions=$(curl -fsSL "https://papermc.io/api/v2/projects/paper" -H "accept: application/json")
|
||||||
|
if [[ $VERSION = LATEST ]]; then
|
||||||
|
VANILLA_VERSION=$(echo "$versions" | jq -r '.versions[-1]')
|
||||||
|
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 published by PaperMC"
|
||||||
|
log " Set VERSION to one of the following: "
|
||||||
|
log " $(echo "$versions" | jq -r '.versions | join(", ")')"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: unknown error while looking up PaperMC version=${VANILLA_VERSION}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "ERROR: failed to lookup PaperMC build from version ${VANILLA_VERSION}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export SERVER=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}" -H "accept: application/json" \
|
||||||
|
| jq -r '.downloads.application.name')
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "ERROR: failed to lookup PaperMC download file from version=${VANILLA_VERSION} build=${build}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f "$SERVER" ]; then
|
if [ -f "$SERVER" ]; then
|
||||||
zarg=(-z "$SERVER")
|
zarg=(-z "$SERVER")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/${PAPERBUILD}/download}
|
log "Downloading PaperMC $VANILLA_VERSION (build $build) ..."
|
||||||
log "Downloading Paper $VANILLA_VERSION (build $PAPERBUILD) from $downloadUrl ..."
|
curl -fsSL -o "$SERVER" "${zarg[@]}" \
|
||||||
out=$(curl -fsSL -o "$SERVER" "${zarg[@]}" "$downloadUrl" 2>&1)
|
"https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}/downloads/${SERVER}" \
|
||||||
case $? in
|
-H "accept: application/java-archive"
|
||||||
0)
|
if [ $? != 0 ]; then
|
||||||
;;
|
echo "ERROR: failed to download PaperMC from version=${VANILLA_VERSION} build=${build} download=${SERVER}"
|
||||||
22) # = 404 HTTP status
|
exit 1
|
||||||
if versions=$(curl -fsSL https://papermc.io/api/v1/paper 2> /dev/null); then
|
|
||||||
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
|
|
||||||
exit 3
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
log "ERROR: failed to contact PaperMC at $downloadUrl"
|
|
||||||
log " $out"
|
|
||||||
exit 3
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Normalize on Spigot for downstream operations
|
# Normalize on Spigot for downstream operations
|
||||||
|
Loading…
Reference in New Issue
Block a user