mc: allow for CurseForge modpacks with spaces in directory name

Fixed #332
This commit is contained in:
Geoff Bourne 2019-06-08 16:47:28 -05:00
parent 342907dcba
commit 98cec98dd9
3 changed files with 33 additions and 26 deletions

View file

@ -72,10 +72,10 @@ if [[ $startScriptCount = 0 ]]; then
unzip -o ${srv_modpack} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}' unzip -o ${srv_modpack} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}'
fi fi
if [[ $(find ${FTB_BASE_DIR} $entryScriptExpr |wc -l) = 0 ]]; then if [[ $(find ${FTB_BASE_DIR} $entryScriptExpr | wc -l) = 0 ]]; then
forgeJar=$(find ${FTB_BASE_DIR} -name 'forge*.jar' -a -not -name 'forge*installer') forgeJar=$(find ${FTB_BASE_DIR} -name 'forge*.jar' -a -not -name 'forge*installer')
if [[ $forgeJar ]]; then if [[ "$forgeJar" ]]; then
echo "No entry script found, so building one for ${forgeJar}" echo "No entry script found, so building one for ${forgeJar}"
cat > ${FTB_BASE_DIR}/ServerStart.sh <<EOF cat > ${FTB_BASE_DIR}/ServerStart.sh <<EOF
#!/bin/sh #!/bin/sh
@ -89,29 +89,36 @@ EOF
fi fi
fi fi
export FTB_SERVER_START=$(find ${FTB_BASE_DIR} $entryScriptExpr) scriptCount=$(find ${FTB_BASE_DIR} $entryScriptExpr | wc -l)
if [[ $(echo ${FTB_SERVER_START} | wc -w) != 1 ]]; then if [[ $scriptCount = 0 ]]; then
echo "Please make sure you are using the server version of the FTB modpack!" echo "Please make sure you are using the server version of the FTB modpack!"
exit 2 exit 2
elif [[ $scriptCount > 1 ]]; then
echo "Ambigous startup scripts in FTB modpack!"
echo "found:"
find ${FTB_BASE_DIR} $entryScriptExpr
exit 2
fi fi
export FTB_DIR=$(dirname ${FTB_SERVER_START}) export FTB_SERVER_START=$(find ${FTB_BASE_DIR} $entryScriptExpr)
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
if isTrue ${FTB_LEGACYJAVAFIXER} && [ ! -e ${legacyJavaFixerPath} ]; then 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"
if isTrue ${FTB_LEGACYJAVAFIXER} && [ ! -e "${legacyJavaFixerPath}" ]; then
echo "Installing legacy java fixer to ${legacyJavaFixerPath}" echo "Installing legacy java fixer to ${legacyJavaFixerPath}"
curl -sSL -o ${legacyJavaFixerPath} ${legacyJavaFixerUrl} curl -sSL -o "${legacyJavaFixerPath}" ${legacyJavaFixerUrl}
fi fi
if [ -e ${FTB_DIR}/FTBInstall.sh ]; then if [ -e "${FTB_DIR}/FTBInstall.sh" ]; then
pushd ${FTB_DIR} pushd "${FTB_DIR}"
sh FTBInstall.sh sh FTBInstall.sh
popd popd
elif [ -e ${FTB_DIR}/Install.sh ]; then elif [ -e "${FTB_DIR}/Install.sh" ]; then
pushd ${FTB_DIR} pushd "${FTB_DIR}"
sh Install.sh sh Install.sh
popd popd
fi fi

View file

@ -11,7 +11,7 @@ function setServerProp {
var=${var,,} ;; var=${var,,} ;;
esac esac
echo "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}" echo "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}"
sed -i "/^${prop}\s*=/ c ${prop}=${var}" $SERVER_PROPERTIES sed -i "/^${prop}\s*=/ c ${prop}=${var}" "$SERVER_PROPERTIES"
else else
echo "Skip setting ${prop}" echo "Skip setting ${prop}"
fi fi
@ -126,9 +126,9 @@ if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
echo "detected FTB, changing properties path to ${SERVER_PROPERTIES}" echo "detected FTB, changing properties path to ${SERVER_PROPERTIES}"
fi fi
if [ ! -e $SERVER_PROPERTIES ]; then if [ ! -e "$SERVER_PROPERTIES" ]; then
echo "Creating server.properties in ${SERVER_PROPERTIES}" echo "Creating server.properties in ${SERVER_PROPERTIES}"
cp /tmp/server.properties $SERVER_PROPERTIES cp /tmp/server.properties "$SERVER_PROPERTIES"
customizeServerProps customizeServerProps
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
case ${OVERRIDE_SERVER_PROPERTIES^^} in case ${OVERRIDE_SERVER_PROPERTIES^^} in

View file

@ -87,33 +87,33 @@ fi
mcServerRunnerArgs="--stop-duration 60s" mcServerRunnerArgs="--stop-duration 60s"
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
if [ ! -e ${FTB_DIR}/ops.json -a -e /data/ops.txt ]; then if [ ! -e "${FTB_DIR}/ops.json" -a -e /data/ops.txt ]; then
cp -f /data/ops.txt ${FTB_DIR}/ cp -f /data/ops.txt ${FTB_DIR}/
fi fi
if [ ! -e ${FTB_DIR}/whitelist.json -a -e /data/white-list.txt ]; then if [ ! -e "${FTB_DIR}/whitelist.json" -a -e /data/white-list.txt ]; then
cp -f /data/white-list.txt ${FTB_DIR}/ cp -f /data/white-list.txt ${FTB_DIR}/
fi fi
cp -f /data/eula.txt ${FTB_DIR}/ cp -f /data/eula.txt "${FTB_DIR}/"
cat > ${FTB_DIR}/settings-local.sh <<EOF cat > "${FTB_DIR}/settings-local.sh" <<EOF
export MIN_RAM="${INIT_MEMORY}" export MIN_RAM="${INIT_MEMORY}"
export MAX_RAM="${MAX_MEMORY}" export MAX_RAM="${MAX_MEMORY}"
export JAVA_PARAMETERS="-Xms${INIT_MEMORY} $expandedDOpts" export JAVA_PARAMETERS="-Xms${INIT_MEMORY} $expandedDOpts"
EOF EOF
# patch CurseForge cfg file, if present # patch CurseForge cfg file, if present
if [ -f ${FTB_DIR}/settings.cfg ]; then if [ -f "${FTB_DIR}/settings.cfg" ]; then
sed -i "/MAX_RAM=.*/ c MAX_RAM=${MAX_MEMORY};" ${FTB_DIR}/settings.cfg sed -i "/MAX_RAM=.*/ c MAX_RAM=${MAX_MEMORY};" "${FTB_DIR}/settings.cfg"
fi fi
cd ${FTB_DIR} cd "${FTB_DIR}"
echo "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..." echo "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
if isTrue ${DEBUG_EXEC}; then if isTrue ${DEBUG_EXEC}; then
set -x set -x
fi fi
exec mc-server-runner ${mcServerRunnerArgs} ${FTB_SERVER_START} exec mc-server-runner ${mcServerRunnerArgs} "${FTB_SERVER_START}"
else else
# If we have a bootstrap.txt file... feed that in to the server stdin # If we have a bootstrap.txt file... feed that in to the server stdin
if [ -f /data/bootstrap.txt ]; then if [ -f /data/bootstrap.txt ]; then