mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-11-10 06:14:14 +00:00
55 lines
1.8 KiB
Bash
Executable file
55 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# shellcheck source=start-utils
|
|
. "${SCRIPTS:-/}start-utils"
|
|
isDebugging && set -x
|
|
set -o pipefail
|
|
|
|
resolveVersion
|
|
export SERVER="minecraft_server.${VERSION// /_}.jar"
|
|
|
|
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
|
|
log "ERROR: failed to obtain version manifest URL ($result)"
|
|
exit 1
|
|
fi
|
|
if [ "$versionManifestUrl" = "null" ]; then
|
|
log "ERROR: couldn't find a matching manifest entry for $VERSION"
|
|
exit 1
|
|
fi
|
|
debug "Found version manifest at $versionManifestUrl"
|
|
|
|
if ! serverDownloadUrl=$(get --json-path '$.downloads.server.url' "${versionManifestUrl}"); then
|
|
log "ERROR: failed to obtain version manifest from $versionManifestUrl ($result)"
|
|
exit 1
|
|
elif [ "$serverDownloadUrl" = "null" ]; then
|
|
log "ERROR: 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
|
|
log "ERROR: failed to download server from $serverDownloadUrl ($result)"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if versionLessThan 1.6; then
|
|
if ! [[ -L /data/minecraft_server.jar && /data/minecraft_server.jar -ef "/data/$SERVER" ]]; then
|
|
rm -f /data/minecraft_server.jar
|
|
ln -s "/data/$SERVER" /data/minecraft_server.jar
|
|
fi
|
|
SERVER=minecraft_server.jar
|
|
elif [[ -L /data/minecraft_server.jar ]]; then
|
|
rm -f /data/minecraft_server.jar
|
|
fi
|
|
|
|
isDebugging && ls -l
|
|
export FAMILY=VANILLA
|
|
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|