2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-19 16:05:32 +00:00
|
|
|
. ${SCRIPTS:-/}start-utils
|
2020-08-15 15:02:45 +00:00
|
|
|
set -o pipefail
|
2020-09-16 22:09:16 +00:00
|
|
|
isDebugging && set -x
|
2020-03-06 15:52:17 +00:00
|
|
|
|
2020-12-16 02:39:49 +00:00
|
|
|
if [[ $PAPER_DOWNLOAD_URL ]]; then
|
|
|
|
export SERVER=$(getFilenameFromUrl "${PAPER_DOWNLOAD_URL}")
|
|
|
|
|
|
|
|
if [ -f "$SERVER" ]; then
|
|
|
|
zarg=(-z "$SERVER")
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Preparing custom PaperMC jar from $PAPER_DOWNLOAD_URL"
|
|
|
|
|
|
|
|
curl -fsSL -o "$SERVER" "${zarg[@]}" "${PAPER_DOWNLOAD_URL}"
|
|
|
|
else
|
|
|
|
# PaperMC API v2 docs : https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config
|
|
|
|
|
2021-01-08 02:03:42 +00:00
|
|
|
build=${PAPERBUILD:=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}" -H "accept: application/json" \
|
|
|
|
| jq '.builds[-1]')}
|
2020-12-16 02:39:49 +00:00
|
|
|
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
|
2021-01-09 17:03:21 +00:00
|
|
|
exec "$0" "$@"
|
2020-12-16 02:39:49 +00:00
|
|
|
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}"
|
2020-11-25 21:42:27 +00:00
|
|
|
exit 1
|
2020-12-16 02:39:49 +00:00
|
|
|
fi
|
2020-11-25 21:42:27 +00:00
|
|
|
|
2020-12-16 02:39:49 +00:00
|
|
|
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
|
2020-11-25 21:42:27 +00:00
|
|
|
|
2020-12-16 02:39:49 +00:00
|
|
|
if [ -f "$SERVER" ]; then
|
|
|
|
zarg=(-z "$SERVER")
|
|
|
|
fi
|
2020-11-25 21:42:27 +00:00
|
|
|
|
2021-01-09 17:03:21 +00:00
|
|
|
log "Removing old PaperMC versions ..."
|
2021-03-10 04:05:21 +00:00
|
|
|
shopt -s nullglob
|
2021-02-24 02:04:34 +00:00
|
|
|
for f in paper-*.jar; do
|
|
|
|
[[ $f != $SERVER ]] && rm $f
|
|
|
|
done
|
2021-01-09 17:03:21 +00:00
|
|
|
|
2020-12-16 02:39:49 +00:00
|
|
|
log "Downloading PaperMC $VANILLA_VERSION (build $build) ..."
|
|
|
|
curl -fsSL -o "$SERVER" "${zarg[@]}" \
|
|
|
|
"https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}/downloads/${SERVER}" \
|
|
|
|
-H "accept: application/java-archive"
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "ERROR: failed to download PaperMC from version=${VANILLA_VERSION} build=${build} download=${SERVER}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-09-16 22:09:16 +00:00
|
|
|
fi
|
2020-07-11 18:30:39 +00:00
|
|
|
|
|
|
|
# Normalize on Spigot for downstream operations
|
2021-12-11 02:50:40 +00:00
|
|
|
export FAMILY=SPIGOT
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2021-03-21 16:43:21 +00:00
|
|
|
exec ${SCRIPTS:-/}start-spiget "$@"
|