mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-03-05 06:16:25 +00:00
New logger with color and specific types. Code cleanup (#3108)
This commit is contained in:
@@ -9,42 +9,47 @@ ftbInstallMarker=".ftb-installed"
|
||||
isDebugging && set -x
|
||||
set -e
|
||||
|
||||
function getVersion() {
|
||||
jq -r --arg name "$1" '.targets|unique[] | select(.name == $name) | .version' version.json
|
||||
}
|
||||
|
||||
if [[ $(getDistro) = alpine ]]; then
|
||||
log "ERROR: the FTBA installer is not supported on Alpine. Use the java8-multiarch image tag instead."
|
||||
logError "The FTBA installer is not supported on Alpine. Use the java8-multiarch image tag instead."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [[ -v FTB_MODPACK_ID ]]; then
|
||||
log "ERROR FTB_MODPACK_ID is required with TYPE=FTB"
|
||||
logError "FTB_MODPACK_ID is required with TYPE=FTB"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [[ ${FTB_MODPACK_ID} =~ [0-9]+ ]]; then
|
||||
log "ERROR FTB_MODPACK_ID needs to be numeric"
|
||||
logError "FTB_MODPACK_ID needs to be numeric"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! $FTB_MODPACK_VERSION_ID ]]; then
|
||||
if ! FTB_MODPACK_VERSION_ID=$(curl -fsSL https://api.modpacks.ch/public/modpack/${FTB_MODPACK_ID} | jq -r '.versions | sort_by(.updated)[-1].id'); then
|
||||
log "ERROR unable to resolve latest modpack version ID for modpack ${FTB_MODPACK_ID}"
|
||||
logError "Unable to resolve latest modpack version ID for modpack ${FTB_MODPACK_ID}"
|
||||
exit 1
|
||||
fi
|
||||
elif ! [[ ${FTB_MODPACK_VERSION_ID} =~ [0-9]+ ]]; then
|
||||
log "ERROR FTB_MODPACK_VERSION_ID needs to be numeric"
|
||||
logError "FTB_MODPACK_VERSION_ID needs to be numeric"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if isTrue "$FTB_FORCE_REINSTALL" || ! [ -f "${ftbInstallMarker}" ] || [ "$(cat "${ftbInstallMarker}")" != "${FTB_MODPACK_ID}=${FTB_MODPACK_VERSION_ID}" ]; then
|
||||
ftbInstaller=/data/ftb-installer
|
||||
arm=
|
||||
if ! [[ -f "${ftbInstaller}" ]]; then
|
||||
log "Downloading FTB installer"
|
||||
if [ "$(uname -m)" == "aarch64" ]; then
|
||||
log "Downloading ARM installer"
|
||||
curl -fsSL https://api.modpacks.ch/public/modpack/1/1/server/arm/linux -o "${ftbInstaller}"
|
||||
$arm=/arm
|
||||
else
|
||||
log "Downloading x86 installer"
|
||||
curl -fsSL https://api.modpacks.ch/public/modpack/1/1/server/linux -o "${ftbInstaller}"
|
||||
fi
|
||||
curl -fsSL https://api.modpacks.ch/public/modpack/1/1/server${arm}/linux -o "${ftbInstaller}"
|
||||
chmod +x "${ftbInstaller}"
|
||||
fi
|
||||
|
||||
@@ -63,9 +68,9 @@ else
|
||||
log "FTB modpack ID ${FTB_MODPACK_ID}, version ID ${FTB_MODPACK_VERSION_ID} is ready to go"
|
||||
fi
|
||||
|
||||
forgeVersion=$(jq -r '.targets|unique[] | select(.name == "forge") | .version' version.json)
|
||||
fabricVersion=$(jq -r '.targets|unique[] | select(.name == "fabric") | .version' version.json)
|
||||
mcVersion=$(jq -r '.targets|unique[] | select(.name == "minecraft") | .version' version.json)
|
||||
forgeVersion=$(getVersion "forge")
|
||||
fabricVersion=$(getVersion "fabric")
|
||||
mcVersion=$(getVersion "minecraft")
|
||||
VERSION="$mcVersion"
|
||||
export VERSION
|
||||
|
||||
@@ -83,8 +88,8 @@ for f in "${variants[@]}"; do
|
||||
fi
|
||||
done
|
||||
if ! [ -v SERVER ]; then
|
||||
log "ERROR unable to locate the installed FTB server jar"
|
||||
log " Tried looking for ${variants[*]}"
|
||||
logError "Unable to locate the installed FTB server jar"
|
||||
logError " Tried looking for ${variants[*]}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
@@ -100,7 +105,7 @@ if [[ $SERVER = run.sh ]]; then
|
||||
export FAMILY=FABRIC
|
||||
export TYPE=FABRIC
|
||||
else
|
||||
log "ERROR: unrecognized loader type in $SERVER"
|
||||
logError "Unrecognized loader type in $SERVER"
|
||||
cat "$SERVER"
|
||||
exit 1
|
||||
fi
|
||||
@@ -112,7 +117,7 @@ elif [[ $SERVER = fabric* ]]; then
|
||||
export FAMILY=FABRIC
|
||||
export TYPE=FABRIC
|
||||
else
|
||||
log "ERROR: unrecognized loader type from $SERVER"
|
||||
logError "Unrecognized loader type from $SERVER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user