docker-minecraft-server/start-deployFabric

80 lines
2.3 KiB
Text
Raw Normal View History

2019-07-10 03:19:59 +00:00
#!/bin/bash
2019-09-15 14:54:13 +00:00
set -eu
. ${SCRIPTS:-/}start-utils
2019-07-10 03:19:59 +00:00
export TYPE=FABRIC
FABRIC_INSTALLER=${FABRIC_INSTALLER:-}
FABRIC_INSTALLER_URL=${FABRIC_INSTALLER_URL:-}
FABRIC_INSTALLER_VERSION=${FABRIC_INSTALLER_VERSION:-${FABRICVERSION:-LATEST}}
2019-07-10 03:19:59 +00:00
if [[ -z $FABRIC_INSTALLER && -z $FABRIC_INSTALLER_URL ]]; then
2020-03-06 15:52:17 +00:00
log "Checking Fabric version information."
case $FABRIC_INSTALLER_VERSION in
2019-07-10 03:19:59 +00:00
LATEST)
FABRIC_INSTALLER_VERSION=$(maven-metadata-release https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml)
2019-07-10 03:19:59 +00:00
;;
esac
FABRIC_INSTALLER="/tmp/fabric-installer-${FABRIC_INSTALLER_VERSION}.jar"
markerVersion=$FABRIC_INSTALLER_VERSION
2019-07-10 03:19:59 +00:00
elif [[ -z $FABRIC_INSTALLER ]]; then
FABRIC_INSTALLER="/tmp/fabric-installer.jar"
markerVersion=custom
2019-07-10 03:19:59 +00:00
elif [[ ! -e $FABRIC_INSTALLER ]]; then
2020-03-06 15:52:17 +00:00
log "ERROR: the given Fabric installer doesn't exist : $FABRIC_INSTALLER"
2019-07-10 03:19:59 +00:00
exit 2
fi
installMarker="/data/.fabric-installed-${VANILLA_VERSION}-${markerVersion}"
2019-07-10 03:19:59 +00:00
2019-09-15 14:54:13 +00:00
debug Checking for installMarker ${installMarker}
2019-07-10 03:19:59 +00:00
if [[ ! -e $installMarker ]]; then
if [[ ! -e $FABRIC_INSTALLER ]]; then
if [[ -z $FABRIC_INSTALLER_URL ]]; then
log "Downloading installer version $FABRIC_INSTALLER_VERSION"
downloadUrl="https://maven.fabricmc.net/net/fabricmc/fabric-installer/${FABRIC_INSTALLER_VERSION}/fabric-installer-${FABRIC_INSTALLER_VERSION}.jar"
2020-03-06 15:52:17 +00:00
log "...trying $downloadUrl"
2019-07-10 03:19:59 +00:00
curl -o $FABRIC_INSTALLER -fsSL $downloadUrl
else
2020-03-06 15:52:17 +00:00
log "Downloading $FABRIC_INSTALLER_URL ..."
2019-07-10 03:19:59 +00:00
if ! curl -o $FABRIC_INSTALLER -fsSL $FABRIC_INSTALLER_URL; then
2020-03-06 15:52:17 +00:00
log "Failed to download from given location $FABRIC_INSTALLER_URL"
2019-07-10 03:19:59 +00:00
exit 2
fi
fi
fi
2019-09-15 14:54:13 +00:00
if isDebugging; then
debug "Installing Fabric ${VANILLA_VERSION} using $FABRIC_INSTALLER"
2019-09-15 14:54:13 +00:00
else
log "Installing Fabric using $FABRIC_INSTALLER"
2019-09-15 14:54:13 +00:00
fi
2019-07-10 03:19:59 +00:00
tries=3
set +e
while ((--tries >= 0)); do
java -jar $FABRIC_INSTALLER server \
-mcversion $VANILLA_VERSION \
-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
export SERVER=fabric-server-launch.jar
2020-03-06 15:52:17 +00:00
log "Using server $SERVER"
2019-07-10 03:19:59 +00:00
echo $SERVER > $installMarker
else
export SERVER=$(< $installMarker)
fi
# Contineut to Final Setup
exec ${SCRIPTS:-/}start-finalSetupWorld $@