2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-07-30 01:09:54 +00:00
|
|
|
: "${FTB_FORCE_REINSTALL:=false}"
|
|
|
|
|
2020-11-26 14:45:51 +00:00
|
|
|
ftbInstallMarker=".ftb-installed"
|
|
|
|
|
2022-01-29 20:53:34 +00:00
|
|
|
# shellcheck source=start-utils
|
|
|
|
. "${SCRIPTS:-/}start-utils"
|
2020-05-31 23:18:54 +00:00
|
|
|
isDebugging && set -x
|
|
|
|
set -e
|
2019-01-22 03:07:38 +00:00
|
|
|
|
2022-08-06 02:42:58 +00:00
|
|
|
if [[ $(getDistro) = alpine ]]; then
|
|
|
|
log "ERROR: the FTBA installer is not supported on Alpine. Use the java8-multiarch image tag instead."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-05-31 23:18:54 +00:00
|
|
|
if ! [[ -v FTB_MODPACK_ID ]]; then
|
|
|
|
log "ERROR FTB_MODPACK_ID is required with TYPE=FTB"
|
|
|
|
exit 1
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
2020-05-31 23:18:54 +00:00
|
|
|
if ! [[ ${FTB_MODPACK_ID} =~ [0-9]+ ]]; then
|
|
|
|
log "ERROR FTB_MODPACK_ID needs to be numeric"
|
|
|
|
exit 1
|
2018-08-12 22:25:16 +00:00
|
|
|
fi
|
|
|
|
|
2021-10-23 14:40:36 +00:00
|
|
|
if [[ ! $FTB_MODPACK_VERSION_ID ]]; then
|
2020-05-31 23:18:54 +00:00
|
|
|
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}"
|
|
|
|
exit 1
|
2018-05-15 01:52:49 +00:00
|
|
|
fi
|
2020-05-31 23:18:54 +00:00
|
|
|
elif ! [[ ${FTB_MODPACK_VERSION_ID} =~ [0-9]+ ]]; then
|
|
|
|
log "ERROR FTB_MODPACK_VERSION_ID needs to be numeric"
|
|
|
|
exit 1
|
2018-08-14 15:45:51 +00:00
|
|
|
fi
|
|
|
|
|
2023-07-30 01:09:54 +00:00
|
|
|
if isTrue "$FTB_FORCE_REINSTALL" || ! [ -f "${ftbInstallMarker}" ] || [ "$(cat "${ftbInstallMarker}")" != "${FTB_MODPACK_ID}=${FTB_MODPACK_VERSION_ID}" ]; then
|
2020-11-26 14:45:51 +00:00
|
|
|
ftbInstaller=/data/ftb-installer
|
|
|
|
if ! [[ -f "${ftbInstaller}" ]]; then
|
|
|
|
log "Downloading FTB installer"
|
2021-08-10 17:53:01 +00:00
|
|
|
if [ "$(uname -m)" == "aarch64" ]; then
|
|
|
|
log "Downloading ARM installer"
|
|
|
|
curl -fsSL https://api.modpacks.ch/public/modpack/1/1/server/arm/linux -o "${ftbInstaller}"
|
|
|
|
else
|
|
|
|
log "Downloading x86 installer"
|
|
|
|
curl -fsSL https://api.modpacks.ch/public/modpack/1/1/server/linux -o "${ftbInstaller}"
|
|
|
|
fi
|
2020-11-26 14:45:51 +00:00
|
|
|
chmod +x "${ftbInstaller}"
|
|
|
|
fi
|
|
|
|
|
2020-05-31 23:18:54 +00:00
|
|
|
log "Installing modpack ID ${FTB_MODPACK_ID}, version ID ${FTB_MODPACK_VERSION_ID}"
|
2022-12-01 13:52:14 +00:00
|
|
|
log "This could take a while..."
|
|
|
|
${ftbInstaller} "${FTB_MODPACK_ID}" "${FTB_MODPACK_VERSION_ID}" --noscript --auto > ftb-installer.log
|
2020-05-31 23:18:54 +00:00
|
|
|
rm -f forge*installer.jar
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2020-05-31 23:18:54 +00:00
|
|
|
echo "${FTB_MODPACK_ID}=${FTB_MODPACK_VERSION_ID}" > ${ftbInstallMarker}
|
2020-07-26 18:50:57 +00:00
|
|
|
|
|
|
|
writeEula
|
2021-02-27 22:58:25 +00:00
|
|
|
|
|
|
|
# some modpacks result in --w----r-- permissions
|
|
|
|
chmod a+r version.json
|
2020-05-31 23:18:54 +00:00
|
|
|
else
|
|
|
|
log "FTB modpack ID ${FTB_MODPACK_ID}, version ID ${FTB_MODPACK_VERSION_ID} is ready to go"
|
2018-01-07 23:18:45 +00:00
|
|
|
fi
|
|
|
|
|
2020-12-26 20:44:37 +00:00
|
|
|
forgeVersion=$(jq -r '.targets|unique[] | select(.name == "forge") | .version' version.json)
|
2021-06-20 17:27:18 +00:00
|
|
|
fabricVersion=$(jq -r '.targets|unique[] | select(.name == "fabric") | .version' version.json)
|
2020-12-26 20:44:37 +00:00
|
|
|
mcVersion=$(jq -r '.targets|unique[] | select(.name == "minecraft") | .version' version.json)
|
2023-07-07 01:05:15 +00:00
|
|
|
VERSION="$mcVersion"
|
|
|
|
export VERSION
|
2020-05-31 23:18:54 +00:00
|
|
|
|
|
|
|
variants=(
|
2022-08-06 21:24:47 +00:00
|
|
|
"forge-${mcVersion}-${forgeVersion}.jar"
|
|
|
|
"forge-${mcVersion}-${forgeVersion}-universal.jar"
|
|
|
|
"forge-${mcVersion}-${forgeVersion}-${mcVersion}-universal.jar"
|
|
|
|
"fabric-${mcVersion}-${fabricVersion}-server-launch.jar"
|
2022-05-19 12:29:52 +00:00
|
|
|
run.sh
|
2020-05-31 23:18:54 +00:00
|
|
|
)
|
2021-11-24 20:30:20 +00:00
|
|
|
for f in "${variants[@]}"; do
|
2020-05-31 23:18:54 +00:00
|
|
|
if [ -f $f ]; then
|
|
|
|
export SERVER=$f
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if ! [ -v SERVER ]; then
|
2021-06-20 17:27:18 +00:00
|
|
|
log "ERROR unable to locate the installed FTB server jar"
|
2022-08-06 21:24:47 +00:00
|
|
|
log " Tried looking for ${variants[*]}"
|
2020-05-31 23:18:54 +00:00
|
|
|
exit 2
|
2018-07-14 03:33:55 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-11 02:50:40 +00:00
|
|
|
export FAMILY=FORGE
|
2022-01-29 20:53:34 +00:00
|
|
|
|
2022-08-06 21:24:47 +00:00
|
|
|
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|