From 0e2fb80de3d16f2a98b742c896599a48169c3fc1 Mon Sep 17 00:00:00 2001 From: Wachira Choomsiri Date: Thu, 26 Nov 2026 02:12:46 +0700 Subject: [PATCH] Fix Leaf downloads after the move to Fill v3 (#4413) --- Dockerfile | 2 +- scripts/start-deployLeaf | 38 ++++++++++++++------------------------ scripts/start-finalExec | 6 ++++++ 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8ff7c35e..3850c6e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \ --from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz # renovate: datasource=github-releases packageName=itzg/mc-image-helper versioning=loose -ARG MC_HELPER_VERSION=1.78.3 +ARG MC_HELPER_VERSION=1.79.0 ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION} # used for cache busting local copy of mc-image-helper ARG MC_HELPER_REV=1 diff --git a/scripts/start-deployLeaf b/scripts/start-deployLeaf index f8aa7607..dd4e5d0a 100755 --- a/scripts/start-deployLeaf +++ b/scripts/start-deployLeaf @@ -9,38 +9,28 @@ isDebugging && set -x resolveVersion : "${LEAF_BUILD:=LATEST}" -# Docs at https://api.leafmc.one/docs/swagger-ui/index.html -leafApiUrl="https://api.leafmc.one/v2/projects/leaf" -leafDownloadsPage="https://www.leafmc.one/download" +leafApiUrl="https://dl.leafmc.one/v3/projects/leaf" +if [[ "${LEAF_BUILD^^}" == "LATEST" ]]; then + LEAF_BUILD=latest +fi -if ! get --exists "${leafApiUrl}/versions/${VERSION}/builds"; then - logError "Leaf builds do not exist for ${VERSION}" - logError " check ${leafDownloadsPage} for available versions" - logError " and set VERSION accordingly" +if ! build=$( + get --accept application/json \ + "${leafApiUrl}/versions/${VERSION}/builds/${LEAF_BUILD}" +); then + logError "Failed to fetch Leaf build ${LEAF_BUILD} for ${VERSION}" exit 1 fi -if [[ "${LEAF_BUILD^^}" == "LATEST" ]]; then - # Get the latest build number from the API, which will be the last object in the builds array - if ! buildNumber=$( - get --json-path '$.builds[-1].build' "${leafApiUrl}/versions/${VERSION}/builds" - ); then - logError "failed to list Leaf builds for ${VERSION}" - exit 1 - fi - LEAF_BUILD="${buildNumber}" -fi - -if ! filename=$( - get --json-path='$.downloads.primary.name' --json-value-when-missing="" "${leafApiUrl}/versions/${VERSION}/builds/${LEAF_BUILD}" -); then - logError "Failed to retrieve download filename" +if ! filename=$(jq -er '.downloads["server:default"].name | strings | select(test("^[A-Za-z0-9._-]+\\.jar$"))' <<< "$build") || + ! downloadUrl=$(jq -er '.downloads["server:default"].url | strings | select(startswith("https://"))' <<< "$build"); then + logError "Invalid Leaf download metadata for ${VERSION} build ${LEAF_BUILD}" exit 1 fi SERVER="/data/$filename" -if ! get --skip-existing --log-progress-each -o "${SERVER}" "${leafApiUrl}/versions/${VERSION}/builds/${LEAF_BUILD}/downloads/${filename}"; then +if ! get --skip-existing --log-progress-each -o "${SERVER}" "${downloadUrl}"; then logError "Failed to download" exit 1 fi @@ -48,4 +38,4 @@ fi export FAMILY=SPIGOT export SERVER -exec "$(dirname "$0")/start-spiget" "$@" \ No newline at end of file +exec "$(dirname "$0")/start-spiget" "$@" diff --git a/scripts/start-finalExec b/scripts/start-finalExec index c41b5de1..758ff89e 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -141,6 +141,12 @@ fi # shellcheck source=start-finalExec-jvmFlags . "$(dirname "$0")/start-finalExec-jvmFlags" +# Leaf exits on the first start if this file doesn't exist +if isType LEAF && [[ ! -e /data/config/leaf-loader.yml ]]; then + mkdir -p /data/config + touch /data/config/leaf-loader.yml +fi + # Handle GTNH args if isType "GTNH"; then expandedDOpts="${expandedDOpts} -Dfml.readTimeout=180"