mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-12-14 06:12:27 +00:00
41 lines
1.2 KiB
Bash
Executable file
41 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
|
|
# shellcheck source=start-utils
|
|
. "${SCRIPTS:-/}start-utils"
|
|
isDebugging && set -x
|
|
|
|
: "${VANILLA_VERSION:?}"
|
|
: "${PURPUR_BUILD:=LATEST}"
|
|
: "${FORCE_REDOWNLOAD:=false}"
|
|
|
|
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
|
|
fi
|
|
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
|
|
|
|
# Normalize on Spigot for later operations
|
|
export FAMILY=SPIGOT
|
|
|
|
exec "${SCRIPTS:-/}start-spiget" "$@"
|