2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-10-10 17:05:37 +00:00
|
|
|
# shellcheck source=start-utils
|
2021-10-11 20:53:09 +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
|
|
|
|
|
2023-06-17 18:00:22 +00:00
|
|
|
resolveVersion
|
|
|
|
export SERVER="minecraft_server.${VERSION// /_}.jar"
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2021-10-10 17:05:37 +00:00
|
|
|
if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
2023-06-17 18:00:22 +00:00
|
|
|
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')
|
2019-02-03 15:49:59 +00:00
|
|
|
result=$?
|
|
|
|
if [ $result != 0 ]; then
|
2024-10-22 21:04:38 +00:00
|
|
|
logError "Failed to obtain version manifest URL ($result)"
|
2019-02-03 15:49:59 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-10-10 17:05:37 +00:00
|
|
|
if [ "$versionManifestUrl" = "null" ]; then
|
2024-10-22 21:04:38 +00:00
|
|
|
logError "Couldn't find a matching manifest entry for $VERSION"
|
2019-02-03 15:49:59 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
debug "Found version manifest at $versionManifestUrl"
|
|
|
|
|
2022-02-27 03:28:30 +00:00
|
|
|
if ! serverDownloadUrl=$(get --json-path '$.downloads.server.url' "${versionManifestUrl}"); then
|
2024-10-22 21:04:38 +00:00
|
|
|
logError "Failed to obtain version manifest from $versionManifestUrl ($result)"
|
2019-02-03 15:49:59 +00:00
|
|
|
exit 1
|
2021-10-10 17:05:37 +00:00
|
|
|
elif [ "$serverDownloadUrl" = "null" ]; then
|
2024-10-22 21:04:38 +00:00
|
|
|
logError "There is not a server download for version $VERSION"
|
2020-07-19 17:22:15 +00:00
|
|
|
exit 1
|
2019-02-03 15:49:59 +00:00
|
|
|
fi
|
|
|
|
|
2023-06-17 18:00:22 +00:00
|
|
|
log "Downloading $VERSION server..."
|
2019-02-03 15:49:59 +00:00
|
|
|
debug "Downloading server from $serverDownloadUrl"
|
2021-10-10 17:05:37 +00:00
|
|
|
get -o "$SERVER" "$serverDownloadUrl"
|
2019-02-03 15:49:59 +00:00
|
|
|
result=$?
|
|
|
|
if [ $result != 0 ]; then
|
2024-10-22 21:04:38 +00:00
|
|
|
logError "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
|
2024-10-22 21:04:38 +00:00
|
|
|
minecraftServerJarPath=/data/minecraft_server.jar
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2021-11-07 02:35:57 +00:00
|
|
|
if versionLessThan 1.6; then
|
2024-10-22 21:04:38 +00:00
|
|
|
if ! [[ -L $minecraftServerJarPath && $minecraftServerJarPath -ef "/data/$SERVER" ]]; then
|
|
|
|
rm -f $minecraftServerJarPath
|
|
|
|
ln -s "/data/$SERVER" $minecraftServerJarPath
|
2021-11-07 02:34:10 +00:00
|
|
|
fi
|
|
|
|
SERVER=minecraft_server.jar
|
2024-10-22 21:04:38 +00:00
|
|
|
elif [[ -L $minecraftServerJarPath ]]; then
|
|
|
|
rm -f $minecraftServerJarPath
|
2021-11-07 02:34:10 +00:00
|
|
|
fi
|
|
|
|
|
2020-06-07 01:41:09 +00:00
|
|
|
isDebugging && ls -l
|
2021-12-11 02:50:40 +00:00
|
|
|
export FAMILY=VANILLA
|
2021-10-10 17:05:37 +00:00
|
|
|
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|