Switch to mc-image-helper for installing Paper/Folia (#2211)
This commit is contained in:
parent
24f40c84ee
commit
fc7d48e33f
|
@ -46,7 +46,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||||
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
|
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
|
||||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||||
|
|
||||||
ARG MC_HELPER_VERSION=1.29.2
|
ARG MC_HELPER_VERSION=1.30.1
|
||||||
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
|
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
|
||||||
# used for cache busting local copy of mc-image-helper
|
# used for cache busting local copy of mc-image-helper
|
||||||
ARG MC_HELPER_REV=1
|
ARG MC_HELPER_REV=1
|
||||||
|
|
|
@ -8,4 +8,4 @@ if [[ $FOLIABUILD ]]; then
|
||||||
export PAPERBUILD="$FOLIABUILD"
|
export PAPERBUILD="$FOLIABUILD"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PAPER_PROJECT="folia" PAPER_NAME="FoliaMC" exec ${SCRIPTS:-/}start-deployPaper "$@"
|
PAPER_PROJECT="folia" PAPER_NAME="FoliaMC" exec "${SCRIPTS:-/}start-deployPaper" "$@"
|
||||||
|
|
|
@ -5,79 +5,48 @@
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
handleDebugMode
|
handleDebugMode
|
||||||
|
|
||||||
|
: "${PAPER_PROJECT:=paper}"
|
||||||
|
: "${PAPERBUILD:=}"
|
||||||
|
: "${PAPER_DOWNLOAD_URL:=}"
|
||||||
: "${PAPER_CUSTOM_JAR:=}"
|
: "${PAPER_CUSTOM_JAR:=}"
|
||||||
|
|
||||||
ourScript="$0"
|
resultsFile=/data/.paper.env
|
||||||
ourArgs=("$@")
|
|
||||||
|
|
||||||
# Check if we're running Folia.
|
|
||||||
if [[ -z $PAPER_PROJECT ]]; then
|
|
||||||
PAPER_PROJECT="paper"
|
|
||||||
PAPER_NAME="PaperMC"
|
|
||||||
fi
|
|
||||||
|
|
||||||
function handleMissingVersion() {
|
|
||||||
expectedVersion=${VANILLA_VERSION}
|
|
||||||
versions=$(curl -fsSL "https://papermc.io/api/v2/projects/${PAPER_PROJECT}" -H "accept: application/json")
|
|
||||||
if [[ $VERSION = LATEST ]]; then
|
|
||||||
tries=0
|
|
||||||
while ((tries++ < 5)); do
|
|
||||||
VANILLA_VERSION=$(echo "$versions" | jq -r ".versions[$((- tries))]")
|
|
||||||
if [[ $(curl -fsSL "https://papermc.io/api/v2/projects/${PAPER_PROJECT}/versions/${VANILLA_VERSION}" -H "accept: application/json" \
|
|
||||||
| jq '.builds[-1]') != null ]]; then
|
|
||||||
log "WARN: using ${VANILLA_VERSION} since that's the latest provided by ${PAPER_NAME}"
|
|
||||||
# re-execute the current script with the newly computed version
|
|
||||||
exec "$ourScript" "${ourArgs[@]}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
log "ERROR: ${expectedVersion} is not published by ${PAPER_NAME}"
|
|
||||||
log " Set VERSION to one of the following: "
|
|
||||||
log " $(echo "$versions" | jq -r '.versions | join(", ")')"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $PAPER_CUSTOM_JAR ]]; then
|
if [[ $PAPER_CUSTOM_JAR ]]; then
|
||||||
export SERVER="$PAPER_CUSTOM_JAR"
|
export SERVER="$PAPER_CUSTOM_JAR"
|
||||||
elif [[ $PAPER_DOWNLOAD_URL ]]; then
|
elif [[ $PAPER_DOWNLOAD_URL ]]; then
|
||||||
SERVER=$(getFilenameFromUrl "${PAPER_DOWNLOAD_URL}")
|
if ! mc-image-helper install-paper \
|
||||||
export SERVER
|
--output-directory=/data \
|
||||||
|
--results-file="$resultsFile" \
|
||||||
log "Downloading custom ${PAPER_NAME} jar from $PAPER_DOWNLOAD_URL"
|
--url="$PAPER_DOWNLOAD_URL}"; then
|
||||||
if ! mc-image-helper mcopy \
|
log "ERROR: failed to download from custom PaperMC URL"
|
||||||
--scope=papermc \
|
exit 1
|
||||||
--to=/data \
|
|
||||||
"${PAPER_DOWNLOAD_URL}"; then
|
|
||||||
echo "ERROR: failed to download ${PAPER_NAME} from $PAPER_DOWNLOAD_URL"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
# grab SERVER and export it
|
||||||
|
set -a
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "${resultsFile}"
|
||||||
|
set +a
|
||||||
|
|
||||||
else
|
else
|
||||||
# Paper API v2 docs : https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config
|
args=(
|
||||||
|
--output-directory=/data
|
||||||
if ! build=${PAPERBUILD:=$(get --json-path=".builds[-1]" "https://papermc.io/api/v2/projects/${PAPER_PROJECT}/versions/${VANILLA_VERSION}")}; then
|
--results-file="$resultsFile"
|
||||||
log "ERROR: failed to lookup build number for ${PAPER_NAME} version=${VANILLA_VERSION}"
|
--project="$PAPER_PROJECT"
|
||||||
exit 1
|
--version="$VERSION"
|
||||||
|
)
|
||||||
|
if [[ $PAPERBUILD ]]; then
|
||||||
|
args+=(--build="$PAPERBUILD")
|
||||||
fi
|
fi
|
||||||
|
if ! mc-image-helper install-paper "${args[@]}"; then
|
||||||
if [[ $build = null ]]; then
|
log "ERROR: failed to download $PAPER_PROJECT"
|
||||||
handleMissingVersion
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
# grab SERVER and export it
|
||||||
|
set -a
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "${resultsFile}"
|
||||||
|
set +a
|
||||||
|
|
||||||
if ! SERVER=$(get --json-path=.downloads.application.name "https://papermc.io/api/v2/projects/${PAPER_PROJECT}/versions/${VANILLA_VERSION}/builds/${build}"); then
|
|
||||||
echo "ERROR: failed to lookup ${PAPER_NAME} download file from version=${VANILLA_VERSION} build=${build}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
export SERVER
|
|
||||||
|
|
||||||
log "Downloading ${PAPER_NAME} $VANILLA_VERSION (build $build) ..."
|
|
||||||
if ! mc-image-helper mcopy \
|
|
||||||
--scope=papermc \
|
|
||||||
--to=/data \
|
|
||||||
"https://papermc.io/api/v2/projects/${PAPER_PROJECT}/versions/${VANILLA_VERSION}/builds/${build}/downloads/${SERVER}"; then
|
|
||||||
echo "ERROR: failed to download ${PAPER_NAME} from version=${VANILLA_VERSION} build=${build} download=${SERVER}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Normalize on Spigot for downstream operations
|
# Normalize on Spigot for downstream operations
|
||||||
|
|
Loading…
Reference in New Issue