2022-01-06 12:49:46 +00:00
#!/bin/bash
2022-03-05 01:52:55 +00:00
# shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils"
2022-01-06 12:49:46 +00:00
set -euo pipefail
isDebugging && set -x
IFS=$'\n\t'
2022-03-06 20:57:00 +00:00
if [[ "${MAJOR_VANILLA_VERSION}" != "1.18" ]] && [[ "${MAJOR_VANILLA_VERSION}" != "1.17" ]]; then
2022-03-05 01:52:55 +00:00
log "ERROR: Pufferfish server type only supports versions 1.18 or 1.17, use PUFFERFISH_BUILD to select the the correct build 47 => 1.18.1, 50 => 1.18.2 etc"
2022-01-06 12:49:46 +00:00
exit 1
fi
2022-03-05 01:52:55 +00:00
: "${PUFFERFISH_BUILD:=lastSuccessfulBuild}"
2022-01-06 12:49:46 +00:00
2022-03-06 20:57:00 +00:00
PUFFERFISH_BUILD_JSON=$(curl -X GET -s "https://ci.pufferfish.host/job/Pufferfish-${MAJOR_VANILLA_VERSION}/${PUFFERFISH_BUILD}/api/json")
2022-03-05 01:52:55 +00:00
# Example: "url": "https://ci.pufferfish.host/job/Pufferfish-1.18/50/",
PUFFERFISH_BUILD_URL=$(jq -n "$PUFFERFISH_BUILD_JSON" | jq -jc '.url // empty' )
# Example: "fileName": "pufferfish-paperclip-1.18.2-R0.1-SNAPSHOT-reobf.jar",
PUFFERFISH_BUILD_FILENAME=$(jq -n "$PUFFERFISH_BUILD_JSON" | jq -jc '.artifacts[].fileName // empty' )
PUFFERFISH_BUILD_DOWNLOAD_URL="${PUFFERFISH_BUILD_URL}artifact/build/libs/${PUFFERFISH_BUILD_FILENAME}"
2022-01-06 12:49:46 +00:00
2022-03-05 01:52:55 +00:00
# Setting server to the Jar filename for export.
export SERVER=$PUFFERFISH_BUILD_FILENAME
2022-01-06 12:49:46 +00:00
log "Removing old Pufferfish versions ..."
shopt -s nullglob
for f in pufferfish-*.jar; do
2022-03-05 01:52:55 +00:00
[[ $f != "$SERVER" ]] && rm "$f"
2022-01-06 12:49:46 +00:00
done
2022-03-05 21:49:36 +00:00
if [[ ! -f "$SERVER" ]] || isTrue "${FORCE_REDOWNLOAD:-false}"; then
2022-03-05 01:52:55 +00:00
log "Downloading Pufferfish from $PUFFERFISH_BUILD_DOWNLOAD_URL ..."
if ! get -o "$SERVER" "$PUFFERFISH_BUILD_DOWNLOAD_URL"; then
log "ERROR: failed to download from $PUFFERFISH_BUILD_DOWNLOAD_URL (status=$?)"
2022-01-06 12:49:46 +00:00
exit 3
fi
fi
# Normalize on Spigot for later operations
export FAMILY=SPIGOT
2022-03-05 01:52:55 +00:00
exec "${SCRIPTS:-/}start-spiget" "$@"