mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
4e44f33db9
See #1192 for an in-depth explanation of the problem. Reported-by: Erik "Coding-Kiwi"
82 lines
2.7 KiB
Bash
Executable File
82 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eu
|
|
|
|
# shellcheck source=start-utils
|
|
. "${SCRIPTS:-/}start-utils"
|
|
|
|
requireVar VANILLA_VERSION
|
|
export TYPE=FABRIC
|
|
: "${FABRIC_INSTALLER_VERSION:=${FABRICVERSION:-LATEST}}"
|
|
: "${FABRIC_INSTALLER:=}"
|
|
: "${FABRIC_INSTALLER_URL:=}"
|
|
: "${FABRIC_LOADER_VERSION:=LATEST}"
|
|
|
|
isDebugging && set -x
|
|
|
|
log "Checking Fabric version information."
|
|
if [[ $FABRIC_INSTALLER ]]; then
|
|
FABRIC_INSTALLER_VERSION=$(echo -n "$FABRIC_INSTALLER" | mc-image-helper hash)
|
|
elif [[ $FABRIC_INSTALLER_URL ]]; then
|
|
FABRIC_INSTALLER_VERSION=$(echo -n "$FABRIC_INSTALLER_URL" | mc-image-helper hash)
|
|
elif [[ ${FABRIC_INSTALLER_VERSION^^} = LATEST ]]; then
|
|
FABRIC_INSTALLER_VERSION=$(maven-metadata-release https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml)
|
|
fi
|
|
|
|
export SERVER=fabric-server-${VANILLA_VERSION}-${FABRIC_INSTALLER_VERSION}.jar
|
|
|
|
if [ ! \( -e ${SERVER} -a -e "server-${VANILLA_VERSION}.jar" \) ]; then
|
|
|
|
if [[ -z $FABRIC_INSTALLER && -z $FABRIC_INSTALLER_URL ]]; then
|
|
FABRIC_INSTALLER="fabric-installer-${FABRIC_INSTALLER_VERSION}.jar"
|
|
FABRIC_INSTALLER_URL="https://maven.fabricmc.net/net/fabricmc/fabric-installer/${FABRIC_INSTALLER_VERSION}/fabric-installer-${FABRIC_INSTALLER_VERSION}.jar"
|
|
elif [[ -z $FABRIC_INSTALLER ]]; then
|
|
FABRIC_INSTALLER="fabric-installer.jar"
|
|
elif [[ ! -e $FABRIC_INSTALLER ]]; then
|
|
log "ERROR: the given Fabric installer doesn't exist : $FABRIC_INSTALLER"
|
|
exit 2
|
|
fi
|
|
|
|
if [[ -z $FABRIC_LOADER_VERSION || ${FABRIC_LOADER_VERSION^^} = LATEST ]]; then
|
|
log "Checking Fabric Loader version information."
|
|
|
|
FABRIC_LOADER_VERSION=$(maven-metadata-release https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml)
|
|
fi
|
|
|
|
if [[ ! -e $FABRIC_INSTALLER ]]; then
|
|
log "Downloading $FABRIC_INSTALLER_URL ..."
|
|
if ! get -o "$FABRIC_INSTALLER" "$FABRIC_INSTALLER_URL"; then
|
|
log "Failed to download from given location $FABRIC_INSTALLER_URL"
|
|
exit 2
|
|
fi
|
|
fi
|
|
|
|
log "Installing Fabric ${VANILLA_VERSION} using $FABRIC_INSTALLER with loader version $FABRIC_LOADER_VERSION"
|
|
|
|
tries=3
|
|
set +e
|
|
while ((--tries >= 0)); do
|
|
java -jar $FABRIC_INSTALLER server \
|
|
-mcversion $VANILLA_VERSION \
|
|
-loader $FABRIC_LOADER_VERSION \
|
|
-downloadMinecraft \
|
|
-dir /data
|
|
if [[ $? == 0 ]]; then
|
|
break
|
|
fi
|
|
done
|
|
set -e
|
|
if (($tries < 0)); then
|
|
log "Fabric failed to install after several tries." >&2
|
|
exit 10
|
|
fi
|
|
|
|
mv server.jar "server-${VANILLA_VERSION}.jar"
|
|
mv fabric-server-launch.jar "${SERVER}"
|
|
fi
|
|
|
|
# Specify which server jar to run
|
|
echo "serverJar=server-${VANILLA_VERSION}.jar" > fabric-server-launcher.properties
|
|
|
|
export FAMILY=FABRIC
|
|
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|