2019-07-10 03:19:59 +00:00
|
|
|
#!/bin/bash
|
2019-09-15 14:54:13 +00:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
. /start-utils
|
2019-07-10 03:19:59 +00:00
|
|
|
|
|
|
|
export TYPE=FABRIC
|
|
|
|
|
|
|
|
FABRIC_INSTALLER=${FABRIC_INSTALLER:-}
|
|
|
|
FABRIC_INSTALLER_URL=${FABRIC_INSTALLER_URL:-}
|
|
|
|
FABRICVERSION=${FABRICVERSION:-LATEST}
|
|
|
|
if [[ -z $FABRIC_INSTALLER && -z $FABRIC_INSTALLER_URL ]]; then
|
|
|
|
echo "Checking Fabric version information."
|
|
|
|
case $FABRICVERSION in
|
|
|
|
LATEST)
|
2019-07-13 01:02:10 +00:00
|
|
|
curl -fsSL https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml | xq -c . > /tmp/fabric.json
|
|
|
|
FABRIC_VERSION=$(< /tmp/fabric.json jq -r ".metadata.versioning.release")
|
2019-07-10 03:19:59 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
FABRIC_VERSION=$FABRICVERSION
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
FABRIC_INSTALLER="/tmp/fabric-installer-$FABRIC_VERSION.jar"
|
|
|
|
|
|
|
|
elif [[ -z $FABRIC_INSTALLER ]]; then
|
|
|
|
FABRIC_INSTALLER="/tmp/fabric-installer.jar"
|
|
|
|
elif [[ ! -e $FABRIC_INSTALLER ]]; then
|
|
|
|
echo "ERROR: the given Fabric installer doesn't exist : $FABRIC_INSTALLER"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2019-09-15 03:29:54 +00:00
|
|
|
installMarker=".fabric-installed-${VANILLA_VERSION}-${FABRIC_VERSION:-manual}"
|
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
|
|
|
|
echo "Downloading $FABRIC_VERSION"
|
|
|
|
downloadUrl="https://maven.fabricmc.net/net/fabricmc/fabric-installer/$FABRIC_VERSION/fabric-installer-$FABRIC_VERSION.jar"
|
|
|
|
echo "...trying $downloadUrl"
|
|
|
|
curl -o $FABRIC_INSTALLER -fsSL $downloadUrl
|
|
|
|
else
|
|
|
|
echo "Downloading $FABRIC_INSTALLER_URL ..."
|
|
|
|
if ! curl -o $FABRIC_INSTALLER -fsSL $FABRIC_INSTALLER_URL; then
|
|
|
|
echo "Failed to download from given location $FABRIC_INSTALLER_URL"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-09-15 14:54:13 +00:00
|
|
|
if isDebugging; then
|
|
|
|
debug "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER with mcversion ${VANILLA_VERSION}"
|
|
|
|
else
|
|
|
|
echo "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER"
|
|
|
|
fi
|
2019-07-10 03:19:59 +00:00
|
|
|
tries=3
|
|
|
|
set +e
|
|
|
|
while ((--tries >= 0)); do
|
2019-07-21 14:05:54 +00:00
|
|
|
java -jar $FABRIC_INSTALLER server -mcversion $VANILLA_VERSION -downloadMinecraft
|
2019-07-10 03:19:59 +00:00
|
|
|
if [[ $? == 0 ]]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
set -e
|
|
|
|
if (($tries < 0)); then
|
|
|
|
echo "Fabric failed to install after several tries." >&2
|
|
|
|
exit 10
|
|
|
|
fi
|
|
|
|
export SERVER=fabric-server-launch.jar
|
|
|
|
echo "Using server $SERVER"
|
|
|
|
echo $SERVER > $installMarker
|
|
|
|
|
|
|
|
else
|
|
|
|
export SERVER=$(< $installMarker)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Contineut to Final Setup
|
|
|
|
exec /start-finalSetup01World $@
|