2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-11-26 14:45:51 +00:00
|
|
|
ftbInstallMarker=".ftb-installed"
|
|
|
|
|
2020-06-19 20:01:28 +00:00
|
|
|
. ${SCRIPTS:-/}start-utils
|
2020-05-31 23:18:54 +00:00
|
|
|
isDebugging && set -x
|
|
|
|
set -e
|
2019-01-22 03:07:38 +00:00
|
|
|
|
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
|
|
|
|
|
2020-05-31 23:18:54 +00:00
|
|
|
if ! [[ -v 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}"
|
|
|
|
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
|
|
|
|
|
2020-11-26 03:36:22 +00:00
|
|
|
if ! [ -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
|
|
|
rm -rf forge*jar mods config libraries defaultconfigs changelogs
|
2019-06-08 21:47:28 +00:00
|
|
|
|
2020-05-31 23:18:54 +00:00
|
|
|
log "Installing modpack ID ${FTB_MODPACK_ID}, version ID ${FTB_MODPACK_VERSION_ID}"
|
|
|
|
${ftbInstaller} ${FTB_MODPACK_ID} ${FTB_MODPACK_VERSION_ID} --noscript --auto
|
|
|
|
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-05-31 23:18:54 +00:00
|
|
|
isDebugging && cat version.json
|
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)
|
2020-05-31 23:18:54 +00:00
|
|
|
|
|
|
|
variants=(
|
|
|
|
forge-${mcVersion}-${forgeVersion}.jar
|
|
|
|
forge-${mcVersion}-${forgeVersion}-universal.jar
|
|
|
|
forge-${mcVersion}-${forgeVersion}-${mcVersion}-universal.jar
|
2021-06-20 17:27:18 +00:00
|
|
|
fabric-${mcVersion}-${fabricVersion}-server-launch.jar
|
2020-05-31 23:18:54 +00:00
|
|
|
)
|
|
|
|
for f in ${variants[@]}; do
|
|
|
|
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"
|
2020-05-31 23:18:54 +00:00
|
|
|
ls *.jar
|
|
|
|
exit 2
|
2018-07-14 03:33:55 +00:00
|
|
|
fi
|
|
|
|
|
2021-09-16 02:27:48 +00:00
|
|
|
exec ${SCRIPTS:-/}start-setupWorld $@
|