2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-19 16:05:32 +00:00
|
|
|
. ${SCRIPTS:-/}start-utils
|
2020-06-07 01:41:09 +00:00
|
|
|
isDebugging && set -x
|
2019-02-03 15:49:59 +00:00
|
|
|
set -o pipefail
|
|
|
|
|
2019-04-12 00:50:29 +00:00
|
|
|
export SERVER="minecraft_server.${VANILLA_VERSION// /_}.jar"
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2019-06-12 18:33:10 +00:00
|
|
|
if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Downloading $SERVER ..."
|
2019-02-03 15:49:59 +00:00
|
|
|
debug "Finding version manifest for $VANILLA_VERSION"
|
|
|
|
versionManifestUrl=$(curl -fsSL 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url')
|
|
|
|
result=$?
|
|
|
|
if [ $result != 0 ]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "ERROR failed to obtain version manifest URL ($result)"
|
2019-02-03 15:49:59 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ $versionManifestUrl = "null" ]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "ERROR couldn't find a matching manifest entry for $VANILLA_VERSION"
|
2019-02-03 15:49:59 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
debug "Found version manifest at $versionManifestUrl"
|
|
|
|
|
|
|
|
serverDownloadUrl=$(curl -fsSL ${versionManifestUrl} | jq --raw-output '.downloads.server.url')
|
|
|
|
result=$?
|
|
|
|
if [ $result != 0 ]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "ERROR failed to obtain version manifest from $versionManifestUrl ($result)"
|
2019-02-03 15:49:59 +00:00
|
|
|
exit 1
|
2020-07-19 17:22:15 +00:00
|
|
|
elif [ $serverDownloadUrl = null ]; then
|
|
|
|
log "ERROR version $VANILLA_VERSION does not provide a server download"
|
|
|
|
exit 1
|
2019-02-03 15:49:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
debug "Downloading server from $serverDownloadUrl"
|
|
|
|
if isDebugging; then
|
|
|
|
verbose=-v
|
|
|
|
fi
|
|
|
|
curl $verbose -fsSL -o $SERVER $serverDownloadUrl
|
|
|
|
result=$?
|
|
|
|
if [ $result != 0 ]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "ERROR failed to download server from $serverDownloadUrl ($result)"
|
2019-02-03 15:49:59 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
2020-06-07 01:41:09 +00:00
|
|
|
isDebugging && ls -l
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
# Continue to Final Setup
|
2020-07-06 22:16:51 +00:00
|
|
|
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|