Files
docker-minecraft-server/scripts/start-deployLeaf
T

42 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# shellcheck source=start-utils
. "${SCRIPTS:-$(dirname "$0")}/start-utils"
set -o pipefail
set -e
isDebugging && set -x
resolveVersion
: "${LEAF_BUILD:=LATEST}"
leafApiUrl="https://dl.leafmc.one/v3/projects/leaf"
if [[ "${LEAF_BUILD^^}" == "LATEST" ]]; then
LEAF_BUILD=latest
fi
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 ! 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}" "${downloadUrl}"; then
logError "Failed to download"
exit 1
fi
export FAMILY=SPIGOT
export SERVER
exec "$(dirname "$0")/start-spiget" "$@"