2021-05-20 01:16:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
2021-11-23 02:51:30 +00:00
|
|
|
# shellcheck source=start-utils
|
|
|
|
. "${SCRIPTS:-/}start-utils"
|
2021-05-20 01:16:57 +00:00
|
|
|
isDebugging && set -x
|
|
|
|
|
2023-04-30 15:50:31 +00:00
|
|
|
: "${CANYON_BUILD:=lastSuccessfulBuild}"
|
2021-05-20 01:16:57 +00:00
|
|
|
|
|
|
|
if [ "${VERSION}" != "b1.7.3" ]; then
|
|
|
|
log "ERROR: Canyon server type only supports VERSION=b1.7.3"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-04-30 15:50:31 +00:00
|
|
|
canyonJob="https://jenkins.glass-launcher.net/job/Canyon"
|
|
|
|
githubUrl="https://github.com/KoboDev/SupplyAndDemand/releases/download"
|
2021-05-20 01:16:57 +00:00
|
|
|
|
|
|
|
buildRelPath=$(
|
|
|
|
curl -fsSL "${canyonJob}/${CANYON_BUILD}/api/json" |
|
|
|
|
jq -r '.artifacts[0].relativePath'
|
|
|
|
)
|
|
|
|
buildNumber=$(
|
|
|
|
curl -fsSL "${canyonJob}/${CANYON_BUILD}/api/json" |
|
|
|
|
jq -r '.number'
|
|
|
|
)
|
|
|
|
baseName=$(basename "${buildRelPath}")
|
|
|
|
|
|
|
|
# Add build tag to non-tagged builds for version detection
|
|
|
|
if [ ${baseName%.*} = 'canyon-server' ]; then
|
|
|
|
export SERVER=${baseName%.*}_build${buildNumber}.jar
|
|
|
|
else
|
|
|
|
export SERVER="${baseName}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$SERVER" ]; then
|
2023-04-30 15:50:31 +00:00
|
|
|
# If CANYON_BUILD is old artifact, then download from GitHub
|
2023-04-30 13:57:22 +00:00
|
|
|
if [ "${CANYON_BUILD}" = "final" ]; then
|
2023-04-30 15:50:31 +00:00
|
|
|
downloadUrl="${githubUrl}/finalcanyon/canyon-server.jar"
|
2023-04-30 13:57:22 +00:00
|
|
|
log "Downloading final Canyon build from $downloadUrl ..."
|
|
|
|
elif [ "${CANYON_BUILD}" = "6" ]; then
|
2023-04-30 15:50:31 +00:00
|
|
|
downloadUrl="${githubUrl}/CanyonRelease/Canyon-Build-6.jar"
|
2023-04-30 13:57:22 +00:00
|
|
|
log "Downloading Canyon build 6 from $downloadUrl ..."
|
|
|
|
elif [ "${CANYON_BUILD}" = "26" ]; then
|
2023-04-30 15:50:31 +00:00
|
|
|
downloadUrl="${githubUrl}/CanyonRelease/canyon-build-26.jar"
|
2023-04-30 13:57:22 +00:00
|
|
|
log "Downloading Canyon build 26 from $downloadUrl ..."
|
2023-04-30 15:50:31 +00:00
|
|
|
# Builds greater than 32 are on Jenkins
|
2023-04-30 13:57:22 +00:00
|
|
|
else
|
|
|
|
downloadUrl="${canyonJob}/${CANYON_BUILD}/artifact/${buildRelPath}"
|
|
|
|
log "Downloading Canyon build ${buildNumber} from $downloadUrl ..."
|
|
|
|
fi
|
2021-05-20 01:16:57 +00:00
|
|
|
curl -fsSL -o "$SERVER" "$downloadUrl"
|
|
|
|
if [ ! -f "$SERVER" ]; then
|
|
|
|
log "ERROR: failed to download from $downloadUrl (status=$?)"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Normalize on Spigot for later operations
|
2021-12-11 02:50:40 +00:00
|
|
|
export FAMILY=SPIGOT
|
2021-05-20 01:16:57 +00:00
|
|
|
|
|
|
|
exec ${SCRIPTS:-/}start-spiget "$@"
|