2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-07 23:18:45 +00:00
|
|
|
. /start-utils
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2018-08-12 22:25:16 +00:00
|
|
|
export FTB_BASE_DIR=/data/FeedTheBeast
|
2018-01-07 23:18:45 +00:00
|
|
|
legacyJavaFixerUrl=http://ftb.cursecdn.com/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar
|
|
|
|
export TYPE=FEED-THE-BEAST
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2019-01-22 03:07:38 +00:00
|
|
|
FTB_SERVER_MOD=${FTB_SERVER_MOD:-$CF_SERVER_MOD}
|
|
|
|
|
|
|
|
echo "Looking for Feed-The-Beast / CurseForge server modpack."
|
2017-11-01 05:42:44 +00:00
|
|
|
if [[ -z $FTB_SERVER_MOD ]]; then
|
|
|
|
echo "Environment variable FTB_SERVER_MOD not set."
|
|
|
|
echo "Set FTB_SERVER_MOD to the file name of the FTB server modpack."
|
|
|
|
echo "(And place the modpack in the /data directory.)"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2019-01-22 03:07:38 +00:00
|
|
|
entryScriptExpr="-name ServerStart.sh -o -name ServerStartLinux.sh -o -name LaunchServer.sh"
|
|
|
|
|
2018-08-12 22:25:16 +00:00
|
|
|
if [[ -d ${FTB_BASE_DIR} ]]; then
|
2019-01-22 03:07:38 +00:00
|
|
|
startScriptCount=$(find ${FTB_BASE_DIR} $entryScriptExpr |wc -l)
|
2018-08-12 22:25:16 +00:00
|
|
|
if [[ $startScriptCount > 1 ]]; then
|
|
|
|
echo "Conflicting FTB/CurseForge packages have been installed. Please cleanup ${FTB_BASE_DIR}"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
startScriptCount=0
|
|
|
|
fi
|
|
|
|
|
2018-05-15 01:52:49 +00:00
|
|
|
# only download and install if a mod pack isn't already installed
|
|
|
|
# also check for the start script rather than just the folder
|
|
|
|
# this allows saving just the world separate from the rest of the data directory
|
2018-08-12 22:25:16 +00:00
|
|
|
if [[ $startScriptCount = 0 ]]; then
|
2018-05-15 01:52:49 +00:00
|
|
|
srv_modpack=${FTB_SERVER_MOD}
|
|
|
|
if isURL ${srv_modpack}; then
|
|
|
|
case $srv_modpack in
|
2018-09-30 19:39:37 +00:00
|
|
|
https://www.feed-the-beast.com/*/download|https://minecraft.curseforge.com/*/download)
|
2018-05-15 01:52:49 +00:00
|
|
|
;;
|
2018-09-30 19:39:37 +00:00
|
|
|
https://www.feed-the-beast.com/*|https://minecraft.curseforge.com/*)
|
2018-05-15 01:52:49 +00:00
|
|
|
srv_modpack=${srv_modpack}/download;;
|
|
|
|
esac
|
|
|
|
file=$(basename $(dirname $srv_modpack))
|
|
|
|
downloaded=/data/${file}.zip
|
|
|
|
if [ ! -e $downloaded ]; then
|
|
|
|
echo "Downloading FTB modpack...
|
|
|
|
$srv_modpack -> $downloaded"
|
|
|
|
curl -sSL -o $downloaded $srv_modpack
|
|
|
|
fi
|
|
|
|
srv_modpack=$downloaded
|
|
|
|
fi
|
|
|
|
if [[ ${srv_modpack:0:5} == "data/" ]]; then
|
|
|
|
# Prepend with "/"
|
|
|
|
srv_modpack=/${srv_modpack}
|
|
|
|
fi
|
|
|
|
if [[ ! ${srv_modpack:0:1} == "/" ]]; then
|
|
|
|
# If not an absolute path, assume file is in "/data"
|
|
|
|
srv_modpack=/data/${srv_modpack}
|
|
|
|
fi
|
|
|
|
if [[ ! -f ${srv_modpack} ]]; then
|
|
|
|
echo "FTB server modpack ${srv_modpack} not found."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
if [[ ! ${srv_modpack: -4} == ".zip" ]]; then
|
|
|
|
echo "FTB server modpack ${srv_modpack} is not a zip archive."
|
|
|
|
echo "Please set FTB_SERVER_MOD to a file with a .zip extension."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
echo "Unpacking FTB server modpack ${srv_modpack} ..."
|
2018-08-12 22:25:16 +00:00
|
|
|
mkdir -p ${FTB_BASE_DIR}
|
|
|
|
unzip -o ${srv_modpack} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}'
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
2018-05-15 01:52:49 +00:00
|
|
|
|
2019-06-08 21:47:28 +00:00
|
|
|
if [[ $(find ${FTB_BASE_DIR} $entryScriptExpr | wc -l) = 0 ]]; then
|
2019-03-11 02:50:42 +00:00
|
|
|
|
|
|
|
forgeJar=$(find ${FTB_BASE_DIR} -name 'forge*.jar' -a -not -name 'forge*installer')
|
2019-06-08 21:47:28 +00:00
|
|
|
if [[ "$forgeJar" ]]; then
|
2019-07-01 23:19:50 +00:00
|
|
|
export FTB_BASE_DIR=$(dirname "${forgeJar}")
|
2019-03-11 02:50:42 +00:00
|
|
|
echo "No entry script found, so building one for ${forgeJar}"
|
2019-07-01 23:19:50 +00:00
|
|
|
cat > "${FTB_BASE_DIR}/ServerStart.sh" <<EOF
|
2019-03-11 02:50:42 +00:00
|
|
|
#!/bin/sh
|
|
|
|
. ./settings-local.sh
|
2019-07-01 23:19:50 +00:00
|
|
|
java \${JAVA_PARAMETERS} -Xmx\${MAX_RAM} -jar $(basename "${forgeJar}") nogui
|
2019-03-11 02:50:42 +00:00
|
|
|
EOF
|
2019-07-01 23:19:50 +00:00
|
|
|
chmod +x "${FTB_BASE_DIR}/ServerStart.sh"
|
2019-03-11 02:50:42 +00:00
|
|
|
else
|
|
|
|
echo "Please make sure you are using the server version of the FTB modpack!"
|
|
|
|
exit 2
|
|
|
|
fi
|
2018-08-14 15:45:51 +00:00
|
|
|
fi
|
|
|
|
|
2019-07-01 23:19:50 +00:00
|
|
|
scriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr | wc -l)
|
2019-06-08 21:47:28 +00:00
|
|
|
if [[ $scriptCount = 0 ]]; then
|
2018-09-30 19:39:37 +00:00
|
|
|
echo "Please make sure you are using the server version of the FTB modpack!"
|
|
|
|
exit 2
|
2019-06-08 21:47:28 +00:00
|
|
|
elif [[ $scriptCount > 1 ]]; then
|
|
|
|
echo "Ambigous startup scripts in FTB modpack!"
|
|
|
|
echo "found:"
|
|
|
|
find ${FTB_BASE_DIR} $entryScriptExpr
|
|
|
|
exit 2
|
2018-09-30 19:39:37 +00:00
|
|
|
fi
|
|
|
|
|
2019-07-01 23:19:50 +00:00
|
|
|
export FTB_SERVER_START=$(find "${FTB_BASE_DIR}" $entryScriptExpr)
|
2019-06-08 21:47:28 +00:00
|
|
|
|
|
|
|
export FTB_DIR=$(dirname "${FTB_SERVER_START}")
|
|
|
|
chmod a+x "${FTB_SERVER_START}"
|
|
|
|
sed -i 's/-jar/-Dfml.queryResult=confirm -jar/' "${FTB_SERVER_START}"
|
|
|
|
sed -i 's/.*read.*Restart now/#\0/' "${FTB_SERVER_START}"
|
|
|
|
legacyJavaFixerPath="${FTB_DIR}/mods/legacyjavafixer.jar"
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2019-06-08 21:47:28 +00:00
|
|
|
if isTrue ${FTB_LEGACYJAVAFIXER} && [ ! -e "${legacyJavaFixerPath}" ]; then
|
2018-01-07 23:18:45 +00:00
|
|
|
echo "Installing legacy java fixer to ${legacyJavaFixerPath}"
|
2019-06-08 21:47:28 +00:00
|
|
|
curl -sSL -o "${legacyJavaFixerPath}" ${legacyJavaFixerUrl}
|
2018-01-07 23:18:45 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-08 21:47:28 +00:00
|
|
|
if [ -e "${FTB_DIR}/FTBInstall.sh" ]; then
|
|
|
|
pushd "${FTB_DIR}"
|
2018-09-18 23:27:34 +00:00
|
|
|
sh FTBInstall.sh
|
2018-07-14 03:33:55 +00:00
|
|
|
popd
|
2019-06-08 21:47:28 +00:00
|
|
|
elif [ -e "${FTB_DIR}/Install.sh" ]; then
|
|
|
|
pushd "${FTB_DIR}"
|
2018-09-18 23:27:34 +00:00
|
|
|
sh Install.sh
|
2018-07-14 03:33:55 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
# Continue to Final Setup
|
|
|
|
exec /start-finalSetup01World $@
|