2019-07-10 03:19:59 +00:00
|
|
|
#!/bin/bash
|
2019-09-15 14:54:13 +00:00
|
|
|
set -eu
|
|
|
|
|
2021-10-09 20:22:42 +00:00
|
|
|
# shellcheck source=start-utils
|
2021-12-12 21:34:24 +00:00
|
|
|
. "${SCRIPTS:-/}start-utils"
|
2019-07-10 03:19:59 +00:00
|
|
|
|
2021-07-10 19:56:10 +00:00
|
|
|
requireVar VANILLA_VERSION
|
2019-07-10 03:19:59 +00:00
|
|
|
export TYPE=FABRIC
|
2021-12-12 21:34:24 +00:00
|
|
|
: "${FABRIC_INSTALLER_VERSION:=${FABRICVERSION:-LATEST}}"
|
|
|
|
: "${FABRIC_INSTALLER:=}"
|
|
|
|
: "${FABRIC_INSTALLER_URL:=}"
|
|
|
|
: "${FABRIC_LOADER_VERSION:=LATEST}"
|
2019-07-10 03:19:59 +00:00
|
|
|
|
2021-07-10 19:56:10 +00:00
|
|
|
isDebugging && set -x
|
2019-07-10 03:19:59 +00:00
|
|
|
|
2021-12-12 21:34:24 +00:00
|
|
|
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
|
2019-07-10 03:19:59 +00:00
|
|
|
|
2021-12-12 21:34:24 +00:00
|
|
|
export SERVER=fabric-server-${VANILLA_VERSION}-${FABRIC_INSTALLER_VERSION}.jar
|
2021-07-10 19:56:10 +00:00
|
|
|
|
2021-12-13 19:50:20 +00:00
|
|
|
if [ ! \( -e ${SERVER} -a -e "server-${VANILLA_VERSION}.jar" \) ]; then
|
2019-07-10 03:19:59 +00:00
|
|
|
|
2021-12-12 21:34:24 +00:00
|
|
|
if [[ -z $FABRIC_INSTALLER && -z $FABRIC_INSTALLER_URL ]]; then
|
2021-07-10 19:56:10 +00:00
|
|
|
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
|
2019-07-10 03:19:59 +00:00
|
|
|
|
2021-10-17 19:43:41 +00:00
|
|
|
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
|
|
|
|
|
2019-07-10 03:19:59 +00:00
|
|
|
if [[ ! -e $FABRIC_INSTALLER ]]; then
|
2021-07-10 19:56:10 +00:00
|
|
|
log "Downloading $FABRIC_INSTALLER_URL ..."
|
2021-10-09 20:22:42 +00:00
|
|
|
if ! get -o "$FABRIC_INSTALLER" "$FABRIC_INSTALLER_URL"; then
|
2021-07-10 19:56:10 +00:00
|
|
|
log "Failed to download from given location $FABRIC_INSTALLER_URL"
|
|
|
|
exit 2
|
2019-07-10 03:19:59 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-10-17 19:43:41 +00:00
|
|
|
log "Installing Fabric ${VANILLA_VERSION} using $FABRIC_INSTALLER with loader version $FABRIC_LOADER_VERSION"
|
2021-07-10 19:56:10 +00:00
|
|
|
|
2019-07-10 03:19:59 +00:00
|
|
|
tries=3
|
|
|
|
set +e
|
|
|
|
while ((--tries >= 0)); do
|
2021-03-11 21:36:34 +00:00
|
|
|
java -jar $FABRIC_INSTALLER server \
|
|
|
|
-mcversion $VANILLA_VERSION \
|
2021-10-17 19:43:41 +00:00
|
|
|
-loader $FABRIC_LOADER_VERSION \
|
2021-03-11 21:36:34 +00:00
|
|
|
-downloadMinecraft \
|
|
|
|
-dir /data
|
2019-07-10 03:19:59 +00:00
|
|
|
if [[ $? == 0 ]]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
set -e
|
|
|
|
if (($tries < 0)); then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Fabric failed to install after several tries." >&2
|
2019-07-10 03:19:59 +00:00
|
|
|
exit 10
|
|
|
|
fi
|
|
|
|
|
2021-12-13 19:50:20 +00:00
|
|
|
mv server.jar "server-${VANILLA_VERSION}.jar"
|
2021-10-10 14:33:17 +00:00
|
|
|
mv fabric-server-launch.jar "${SERVER}"
|
2019-07-10 03:19:59 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-13 19:50:20 +00:00
|
|
|
# Specify which server jar to run
|
|
|
|
echo "serverJar=server-${VANILLA_VERSION}.jar" > fabric-server-launcher.properties
|
|
|
|
|
2021-12-11 02:50:40 +00:00
|
|
|
export FAMILY=FABRIC
|
2021-12-12 21:34:24 +00:00
|
|
|
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|