2021-02-07 17:22:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
2022-01-02 16:17:32 +00:00
|
|
|
# shellcheck source=start-utils
|
|
|
|
. "${SCRIPTS:-/}start-utils"
|
2021-02-07 17:22:08 +00:00
|
|
|
isDebugging && set -x
|
|
|
|
|
2022-06-15 11:51:41 +00:00
|
|
|
if [[ $PURPUR_DOWNLOAD_URL ]]; then
|
|
|
|
export SERVER=$(getFilenameFromUrl "${PURPUR_DOWNLOAD_URL}")
|
|
|
|
|
|
|
|
if [ -f "$SERVER" ]; then
|
|
|
|
zarg=(-z "$SERVER")
|
2021-02-07 17:22:08 +00:00
|
|
|
fi
|
|
|
|
|
2022-06-15 11:51:41 +00:00
|
|
|
echo "Preparing custom Purpur jar from $PURPUR_DOWNLOAD_URL"
|
2021-02-07 17:22:08 +00:00
|
|
|
|
2022-06-15 11:51:41 +00:00
|
|
|
curl -fsSL -o "$SERVER" "${zarg[@]}" "${PURPUR_DOWNLOAD_URL}"
|
|
|
|
else
|
|
|
|
: "${VANILLA_VERSION:?}"
|
|
|
|
: "${PURPUR_BUILD:=LATEST}"
|
|
|
|
: "${FORCE_REDOWNLOAD:=false}"
|
2022-05-24 12:21:30 +00:00
|
|
|
|
2022-06-15 11:51:41 +00:00
|
|
|
if [[ ${PURPUR_BUILD} == LATEST ]]; then
|
|
|
|
if ! PURPUR_BUILD=$(get --json-path=".builds.latest" "https://api.purpurmc.org/v2/purpur/${VANILLA_VERSION}"); then
|
|
|
|
log "ERROR: Failed to locate a Purpur build for ${VANILLA_VERSION}."
|
|
|
|
log " Please check if a download is available at https://purpur.pl3x.net/downloads/"
|
|
|
|
exit 1
|
2021-02-07 17:22:08 +00:00
|
|
|
fi
|
2022-06-15 11:51:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
export SERVER="purpur-${VANILLA_VERSION}-${PURPUR_BUILD}.jar"
|
|
|
|
|
|
|
|
log "Removing old Purpur versions ..."
|
|
|
|
shopt -s nullglob
|
|
|
|
for f in purpur-*.jar; do
|
|
|
|
[[ $f != "$SERVER" ]] && rm "$f"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -f "$SERVER" ] || isTrue "$FORCE_REDOWNLOAD"; then
|
|
|
|
downloadUrl="https://api.purpurmc.org/v2/purpur/${VANILLA_VERSION}/${PURPUR_BUILD}/download"
|
|
|
|
log "Downloading Purpur from $downloadUrl ..."
|
|
|
|
if ! get -o "$SERVER" "$downloadUrl"; then
|
|
|
|
log "ERROR: failed to download from $downloadUrl (status=$?)"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
fi
|
2021-02-07 17:22:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Normalize on Spigot for later operations
|
2021-12-11 02:50:40 +00:00
|
|
|
export FAMILY=SPIGOT
|
2021-02-07 17:22:08 +00:00
|
|
|
|
2022-01-02 16:17:32 +00:00
|
|
|
exec "${SCRIPTS:-/}start-spiget" "$@"
|