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
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Checking Fabric version information."
|
2019-07-10 03:19:59 +00:00
|
|
|
case $FABRICVERSION in
|
|
|
|
LATEST)
|
2020-01-31 03:24:36 +00:00
|
|
|
FABRIC_VERSION=$(maven-metadata-release https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml)
|
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
|
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
|
|
|
|
|
2020-04-15 13:20:11 +00:00
|
|
|
installMarker="/data/.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
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Downloading $FABRIC_VERSION"
|
2019-07-10 03:19:59 +00:00
|
|
|
downloadUrl="https://maven.fabricmc.net/net/fabricmc/fabric-installer/$FABRIC_VERSION/fabric-installer-$FABRIC_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 $FABRIC_VERSION using $FABRIC_INSTALLER with mcversion ${VANILLA_VERSION}"
|
|
|
|
else
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Installing Fabric $FABRIC_VERSION 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
|
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
|
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 /start-finalSetup01World $@
|