Use mc-image-helper to install vanilla Minecraft. (#4165)

Co-authored-by: Geoff Bourne <itzgeoff@gmail.com>
This commit is contained in:
Josh Cotton
2026-07-19 15:54:07 -05:00
committed by GitHub
co-authored by Geoff Bourne
parent cd2c5628f2
commit 3c4c94e1ad
4 changed files with 23 additions and 46 deletions
+16 -40
View File
@@ -5,52 +5,28 @@
isDebugging && set -x
set -o pipefail
resolveVersion
export SERVER="minecraft_server.${VERSION// /_}.jar"
resultsFile=/data/.install-vanilla.env
if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
debug "Finding version manifest for $VERSION"
versionManifestUrl=$(get 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VERSION "$VERSION" --raw-output '[.versions[]|select(.id == $VERSION)][0].url')
result=$?
if [ $result != 0 ]; then
logError "Failed to obtain version manifest URL ($result)"
exit 1
fi
if [ "$versionManifestUrl" = "null" ]; then
logError "Couldn't find a matching manifest entry for $VERSION"
exit 1
fi
debug "Found version manifest at $versionManifestUrl"
args=(
--output-directory=/data
--results-file="${resultsFile}"
--version="${VERSION}"
)
if ! serverDownloadUrl=$(get --json-path '$.downloads.server.url' "${versionManifestUrl}"); then
logError "Failed to obtain version manifest from $versionManifestUrl ($result)"
exit 1
elif [ "$serverDownloadUrl" = "null" ]; then
logError "There is not a server download for version $VERSION"
exit 1
fi
log "Downloading $VERSION server..."
debug "Downloading server from $serverDownloadUrl"
get -o "$SERVER" "$serverDownloadUrl"
result=$?
if [ $result != 0 ]; then
logError "Failed to download server from $serverDownloadUrl ($result)"
exit 1
fi
if isTrue "${FORCE_REDOWNLOAD}"; then
log "Forcing re-install of Minecraft"
args+=(--force-reinstall)
fi
minecraftServerJarPath=/data/minecraft_server.jar
if versionLessThan 1.6; then
if ! [[ -L $minecraftServerJarPath && $minecraftServerJarPath -ef "/data/$SERVER" ]]; then
rm -f $minecraftServerJarPath
ln -s "/data/$SERVER" $minecraftServerJarPath
fi
SERVER=minecraft_server.jar
elif [[ -L $minecraftServerJarPath ]]; then
rm -f $minecraftServerJarPath
if ! mc-image-helper install-vanilla "${args[@]}"; then
logError "Failed to install vanilla Minecraft version $VERSION"
exit 1
fi
applyResultsFile "${resultsFile}"
log "Successfully setup vanilla Minecraft version $VERSION"
isDebugging && ls -l
export FAMILY=VANILLA
exec "$(dirname "$0")/start-setupWorld" "$@"