From ce0f1599de3dc740721b56bcf7b4e909aaef214c Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 23 Aug 2025 17:48:44 -0500 Subject: [PATCH] Skip Mohist lookup/download when MOHIST_BUILD provided and server jar exists (#3631) --- examples/mohist/compose.yml | 2 +- scripts/start-deployMohist | 53 +++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/examples/mohist/compose.yml b/examples/mohist/compose.yml index 847f440a..5209b157 100644 --- a/examples/mohist/compose.yml +++ b/examples/mohist/compose.yml @@ -7,7 +7,7 @@ services: EULA: "TRUE" TYPE: MOHIST VERSION: 1.12.2 - DEBUG: "true" + MOHIST_BUILD: 347 volumes: - data:/data diff --git a/scripts/start-deployMohist b/scripts/start-deployMohist index d5afd364..001706b4 100755 --- a/scripts/start-deployMohist +++ b/scripts/start-deployMohist @@ -14,38 +14,39 @@ mohistType="${TYPE,,}" mohistApiUrl="https://api.mohistmc.com/project/${mohistType}" mohistDownloadsPage="https://mohistmc.com/downloadSoftware?project=${mohistType}" -if ! get --exists "${mohistApiUrl}/${VERSION}/builds"; then - logError "${mohistType} builds do not exist for ${VERSION}" - logError " check ${mohistDownloadsPage} for available versions" - logError " and set VERSION accordingly" - exit 1 -fi - -if [[ "${MOHIST_BUILD}" == "lastSuccessfulBuild" ]]; then - # Get the latest build number from the API - if ! buildNumber=$( - get --json-path '$[0].id' "${mohistApiUrl}/${VERSION}/builds" - ); then - logError "failed to list ${mohistType} builds for ${VERSION}" +if [[ "${MOHIST_BUILD}" != "lastSuccessfulBuild" ]] && [[ "${VERSION,,}" != latest ]] && [[ -f "/data/${mohistType}-${VERSION}-${MOHIST_BUILD}-server.jar" ]]; then + log "Skipping Mohist build lookup since server jar exists" + SERVER="/data/${mohistType}-${VERSION}-${MOHIST_BUILD}-server.jar" +else + if ! get --exists "${mohistApiUrl}/${VERSION}/builds"; then + logError "${mohistType} builds do not exist for ${VERSION}" + logError " check ${mohistDownloadsPage} for available versions" + logError " and set VERSION accordingly" exit 1 fi - MOHIST_BUILD="${buildNumber}" -fi -downloadUrl="${mohistApiUrl}/${VERSION}/builds/${MOHIST_BUILD}/download" + if [[ "${MOHIST_BUILD}" == "lastSuccessfulBuild" ]]; then + # Get the latest build number from the API + if ! buildNumber=$( + get --json-path '$[0].id' "${mohistApiUrl}/${VERSION}/builds" + ); then + logError "failed to list ${mohistType} builds for ${VERSION}" + exit 1 + fi + MOHIST_BUILD="${buildNumber}" + fi -if [[ -z "${downloadUrl}" ]]; then - logError "Could not find build ${MOHIST_BUILD} for version ${VERSION}" - logError " check ${mohistDownloadsPage} for available versions" - logError " and set VERSION accordingly" - exit 1 -fi + downloadUrl="${mohistApiUrl}/${VERSION}/builds/${MOHIST_BUILD}/download" -SERVER="/data/${mohistType}-${VERSION}-${MOHIST_BUILD}-server.jar" + if [[ -z "${downloadUrl}" ]]; then + logError "Could not find build ${MOHIST_BUILD} for version ${VERSION}" + logError " check ${mohistDownloadsPage} for available versions" + logError " and set VERSION accordingly" + exit 1 + fi -if [ ! -f "${SERVER}" ]; then - log "Downloading ${mohistType^} build ${MOHIST_BUILD} for ${VERSION}" - get -o "${SERVER}" "${downloadUrl}" + SERVER="/data/${mohistType}-${VERSION}-${MOHIST_BUILD}-server.jar" + get --skip-existing -o "${SERVER}" "${downloadUrl}" fi if [[ "${mohistType}" == "mohist" ]]; then