From d9c2f265061d6d897bd813f458414cf8d455e53d Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 12 Aug 2018 17:25:16 -0500 Subject: [PATCH] mc: handle FTB style start script within CurseForge subdirs mc: upgrade mc-server-runner to launch start scripts via bash --- minecraft-server/Dockerfile | 2 +- .../examples/docker-compose-curseforge.yml | 11 +++++++ minecraft-server/start-configuration | 20 ++++++------- minecraft-server/start-deployFTB | 29 +++++++++++++------ minecraft-server/start-minecraftFinalSetup | 6 ++-- 5 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 minecraft-server/examples/docker-compose-curseforge.yml diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index c7f3abf1..372fc499 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -28,7 +28,7 @@ EXPOSE 25565 25575 ARG RESTIFY_VER=1.1.4 ARG RCON_CLI_VER=1.4.0 -ARG MC_SERVER_RUNNER_VER=1.1.2 +ARG MC_SERVER_RUNNER_VER=1.2.0 ARG ARCH=amd64 ADD https://github.com/itzg/restify/releases/download/${RESTIFY_VER}/restify_${RESTIFY_VER}_linux_${ARCH}.tar.gz /tmp/restify.tgz diff --git a/minecraft-server/examples/docker-compose-curseforge.yml b/minecraft-server/examples/docker-compose-curseforge.yml new file mode 100644 index 00000000..8bdc844e --- /dev/null +++ b/minecraft-server/examples/docker-compose-curseforge.yml @@ -0,0 +1,11 @@ +version: '3.2' + +services: + mc: + image: itzg/minecraft-server + environment: + EULA: "true" + TYPE: FTB + FTB_SERVER_MOD: https://minecraft.curseforge.com/projects/all-the-mods-expert-remastered/files/2493900/download + ports: + - 25565:25565 diff --git a/minecraft-server/start-configuration b/minecraft-server/start-configuration index d6f6283f..348f1b3c 100755 --- a/minecraft-server/start-configuration +++ b/minecraft-server/start-configuration @@ -24,7 +24,7 @@ if [ ! -e /data/eula.txt ]; then fi fi -echo "Running as '$(id -u):$(id -g)' with /data as '$(ls -lnd /data)'" +echo "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'" if ! touch /data/.verify_access; then echo "ERROR: /data doesn't seem to be writable. Please make sure attached directory is writable by uid=$(id -u)" @@ -61,37 +61,37 @@ esac cd /data -export ORIGINAL_TYPE=${TYPE} +export ORIGINAL_TYPE=${TYPE^^} echo "Checking type information." -case "$TYPE" in - *BUKKIT|*bukkit|SPIGOT|spigot) +case "${TYPE^^}" in + *BUKKIT|SPIGOT) exec /start-deployBukkitSpigot $@ ;; - PAPER|paper) + PAPER) exec /start-deployPaper $@ ;; - FORGE|forge) + FORGE) exec /start-deployForge $@ ;; - FTB|ftb) + FTB|CURSEFORGE) exec /start-deployFTB $@ ;; - VANILLA|vanilla) + VANILLA) exec /start-deployVanilla $@ ;; - SPONGEVANILLA|spongevanilla) + SPONGEVANILLA) exec /start-deploySpongeVanilla $@ ;; *) echo "Invalid type: '$TYPE'" - echo "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTB, SPONGEVANILLA" + echo "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTB, CURSEFORGE, SPONGEVANILLA" exit 1 ;; diff --git a/minecraft-server/start-deployFTB b/minecraft-server/start-deployFTB index 33cda449..0eae0e0d 100755 --- a/minecraft-server/start-deployFTB +++ b/minecraft-server/start-deployFTB @@ -2,9 +2,8 @@ . /start-utils -export FTB_DIR=/data/FeedTheBeast +export FTB_BASE_DIR=/data/FeedTheBeast legacyJavaFixerUrl=http://ftb.cursecdn.com/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar -legacyJavaFixerPath=${FTB_DIR}/mods/legacyjavafixer.jar export TYPE=FEED-THE-BEAST echo "Looking for Feed-The-Beast server modpack." @@ -15,11 +14,20 @@ if [[ -z $FTB_SERVER_MOD ]]; then exit 2 fi +if [[ -d ${FTB_BASE_DIR} ]]; then + startScriptCount=$(find ${FTB_BASE_DIR} -name ServerStart.sh |wc -l) + if [[ $startScriptCount > 1 ]]; then + echo "Conflicting FTB/CurseForge packages have been installed. Please cleanup ${FTB_BASE_DIR}" + exit 2 + fi +else + startScriptCount=0 +fi + # 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 -export FTB_SERVER_START=${FTB_DIR}/ServerStart.sh -if [ ! -f ${FTB_SERVER_START} ]; then +if [[ $startScriptCount = 0 ]]; then srv_modpack=${FTB_SERVER_MOD} if isURL ${srv_modpack}; then case $srv_modpack in @@ -56,13 +64,16 @@ if [ ! -f ${FTB_SERVER_START} ]; then fi echo "Unpacking FTB server modpack ${srv_modpack} ..." - mkdir -p ${FTB_DIR} - unzip -o ${srv_modpack} -d ${FTB_DIR} | awk '{printf "."} END {print ""}' - cp -f /data/eula.txt ${FTB_DIR}/eula.txt + mkdir -p ${FTB_BASE_DIR} + unzip -o ${srv_modpack} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}' fi -chmod a+x ${FTB_SERVER_START} -sed -i "s/-jar/-Dfml.queryResult=confirm -jar/" ${FTB_SERVER_START} +export FTB_SERVER_START=./ServerStart.sh +export FTB_DIR=$(dirname $(find ${FTB_DIR} -name ServerStart.sh)) +chmod a+x ${FTB_DIR}/${FTB_SERVER_START} +sed -i 's/-jar/-Dfml.queryResult=confirm -jar/' ${FTB_DIR}/${FTB_SERVER_START} +sed -i 's/.*read.*Restart now/#\0/' ${FTB_DIR}/${FTB_SERVER_START} +legacyJavaFixerPath=${FTB_DIR}/mods/legacyjavafixer.jar if isTrue ${FTB_LEGACYJAVAFIXER} && [ ! -e ${legacyJavaFixerPath} ]; then echo "Installing legacy java fixer to ${legacyJavaFixerPath}" diff --git a/minecraft-server/start-minecraftFinalSetup b/minecraft-server/start-minecraftFinalSetup index c6c1f306..8357ec2d 100755 --- a/minecraft-server/start-minecraftFinalSetup +++ b/minecraft-server/start-minecraftFinalSetup @@ -84,9 +84,7 @@ if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then cp -f /data/white-list.txt ${FTB_DIR}/ fi - if [ ! -e ${FTB_DIR}/eula.txt ]; then - cp -f /data/eula.txt ${FTB_DIR}/ - fi + cp -f /data/eula.txt ${FTB_DIR}/ cat > ${FTB_DIR}/settings-local.sh <