From b71eb666a7ca650ae188afb16b75d95901fed7d7 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Wed, 10 Feb 2021 14:46:09 -0600 Subject: [PATCH 01/12] Fix PATH to include java when needed #749 --- start-minecraftFinalSetup | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/start-minecraftFinalSetup b/start-minecraftFinalSetup index 4ee8b71c..7b227e12 100644 --- a/start-minecraftFinalSetup +++ b/start-minecraftFinalSetup @@ -168,6 +168,11 @@ function copyFilesForCurseForge() { cp -f /data/eula.txt "${FTB_DIR}/" } +if ! which java > /dev/null; then + log "Fixing PATH to include java" + PATH="${PATH}:/opt/java/openjdk/bin" +fi + mcServerRunnerArgs="--stop-duration ${STOP_DURATION:-60}s" if [[ ${TYPE} == "CURSE_INSTANCE" ]]; then if isTrue ${DEBUG_EXEC}; then From 6fe022ccc886772d2ae3f7280b4a26cc488d7a36 Mon Sep 17 00:00:00 2001 From: Fersandi Pratama Date: Sun, 14 Feb 2021 01:24:58 +0700 Subject: [PATCH 02/12] Fix README: volume should be in list (#767) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 64c8fd80..76acf19f 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ services: EULA: "TRUE" volumes: # attach the relative directory 'data' to the container's /data path - ./data:/data + - ./data:/data ``` ## Versions From 92a15ea85d0323be169d665034081d0917783c03 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Mon, 15 Feb 2021 10:21:18 -0600 Subject: [PATCH 03/12] Updated forge examples to use java8 image #770 --- README.md | 6 ++---- examples/docker-compose-curseforge.yml | 2 +- examples/docker-compose-curseinstance.yml | 20 -------------------- examples/docker-compose-forge.yml | 2 +- examples/docker-compose-ftba.yml | 4 ++-- examples/docker-compose-spongeforge.yml | 2 +- 6 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 examples/docker-compose-curseinstance.yml diff --git a/README.md b/README.md index 76acf19f..8a94d9fb 100644 --- a/README.md +++ b/README.md @@ -729,16 +729,14 @@ every time you want to create new Minecraft server, you can now use ``` minecraft-server: + image: itzg/minecraft-server + ports: - "25565:25565" environment: EULA: "TRUE" - image: itzg/minecraft-server - - container_name: mc - tty: true stdin_open: true restart: always diff --git a/examples/docker-compose-curseforge.yml b/examples/docker-compose-curseforge.yml index fbdd8c89..50c748c4 100644 --- a/examples/docker-compose-curseforge.yml +++ b/examples/docker-compose-curseforge.yml @@ -2,7 +2,7 @@ version: '3.2' services: mc: - image: itzg/minecraft-server + image: itzg/minecraft-server:java8 volumes: - ./modpacks:/modpacks:ro environment: diff --git a/examples/docker-compose-curseinstance.yml b/examples/docker-compose-curseinstance.yml deleted file mode 100644 index c1d62f7f..00000000 --- a/examples/docker-compose-curseinstance.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: "3.7" - -services: - mc: - image: itzg/minecraft-server - ports: - - 25565:25565 - volumes: - # Attach .../Curse/Minecraft/Instances for use at /instances - - ./Instances:/instances:ro - # Attach /data as usual - - ./ServerData:/data - environment: - EULA: "TRUE" - # Modpacks generally need more memory, so let's give at 2 GB - MEMORY: 2G - # Use new CURSE_INSTANCE type - TYPE: CURSE_INSTANCE - # Reference directory of or full path to minecraftinstance.json - CURSE_INSTANCE_JSON: /instances/FTB Presents SkyFactory 3 diff --git a/examples/docker-compose-forge.yml b/examples/docker-compose-forge.yml index 4c9f6c86..2e2a5d59 100644 --- a/examples/docker-compose-forge.yml +++ b/examples/docker-compose-forge.yml @@ -2,7 +2,7 @@ version: "3.7" services: mc: - image: itzg/minecraft-server + image: itzg/minecraft-server:java8 ports: # expose the Minecraft server port outside of container - 25565:25565 diff --git a/examples/docker-compose-ftba.yml b/examples/docker-compose-ftba.yml index 6e07bbbc..81019b59 100644 --- a/examples/docker-compose-ftba.yml +++ b/examples/docker-compose-ftba.yml @@ -2,8 +2,8 @@ version: "3.7" services: mc: - # FTBA support is only available in multiarch image tag - image: itzg/minecraft-server:multiarch + # FTBA support is only available in non-Alpine images + image: itzg/minecraft-server:java8-multiarch ports: # expose the Minecraft server port outside of container - 25565:25565 diff --git a/examples/docker-compose-spongeforge.yml b/examples/docker-compose-spongeforge.yml index 6843b64c..e8b6ae39 100644 --- a/examples/docker-compose-spongeforge.yml +++ b/examples/docker-compose-spongeforge.yml @@ -5,7 +5,7 @@ version: '3' services: minecraft: - image: itzg/minecraft-server + image: itzg/minecraft-server:java8 ports: - "25565:25565" volumes: From c056b9d2dd5b28c71d2bf544ef0cc2f8883cff93 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 20 Feb 2021 17:30:50 -0600 Subject: [PATCH 04/12] Improved handling of ENV_VARIABLE_PREFIX #718 --- start-finalSetupEnvVariables | 41 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/start-finalSetupEnvVariables b/start-finalSetupEnvVariables index ab8d13c8..cfb36413 100644 --- a/start-finalSetupEnvVariables +++ b/start-finalSetupEnvVariables @@ -5,7 +5,7 @@ : ${ENV_VARIABLE_PREFIX:=CFG_} if isTrue "${REPLACE_ENV_VARIABLES}"; then - log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..." + log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX ..." # File excludes fileExcludes= @@ -22,28 +22,27 @@ if isTrue "${REPLACE_ENV_VARIABLES}"; then isDebugging && echo "Using find file exclusions: $fileExcludes" isDebugging && echo "Using find directory exclusions: $dirExcludes" - while IFS='=' read -r name value ; do + for name in $(compgen -v $ENV_VARIABLE_PREFIX); do # check if name of env variable matches the prefix # sanity check environment variables to avoid code injections - if [[ "$name" = $ENV_VARIABLE_PREFIX* ]] \ - && [[ $value =~ ^[0-9a-zA-Z_:/=?.+\-]*$ ]] \ - && [[ $name =~ ^[0-9a-zA-Z_\-]*$ ]]; then - # Read content from file environment - if [[ $name = *"_FILE" ]] && [[ -f $value ]]; then - name="${name/_FILE/}" - value=$(<$value) - fi - - log "Replacing $name with $value ..." - find /data/ \ - $dirExcludes \ - -type f \ - \( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \ - -or -name "*.conf" -or -name "*.properties" \) \ - $fileExcludes \ - -exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \; + # Read content from file environment + if [[ $name = *"_FILE" ]]; then + value=$(<${!name}) + name="${name%_FILE}" + else + value=${!name} fi - done < <(env) + + log "Replacing $name with $value ..." + find /data/ \ + $dirExcludes \ + -type f \ + \( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \ + -or -name "*.conf" -or -name "*.properties" \) \ + $fileExcludes \ + -exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \; + done fi -exec ${SCRIPTS:-/}start-minecraftFinalSetup $@ +#DO NOT COMMIT +#exec ${SCRIPTS:-/}start-minecraftFinalSetup $@ From d47c801b184228e0c623afa2af684c00183c7f20 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 20 Feb 2021 17:34:00 -0600 Subject: [PATCH 05/12] Separated JMX_BINDING from JMX_HOST in ENABLE_JMX usage --- README.md | 6 ++++-- start-minecraftFinalSetup | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8a94d9fb..e2f55197 100644 --- a/README.md +++ b/README.md @@ -1150,9 +1150,11 @@ For some cases, if e.g. after removing mods, it could be necessary to startup mi ### Enable Remote JMX for Profiling -To enable remote JMX, such as for profiling with VisualVM or JMC, add the environment variable `ENABLE_JMX=true` and add a port forwarding of TCP port 7091, such as: +To enable remote JMX, such as for profiling with VisualVM or JMC, add the environment variable `ENABLE_JMX=true`, set `JMX_HOST` to the IP/host running the Docker container, and add a port forwarding of TCP port 7091, such as: - -e ENABLE_JMX=true -p 7091:7091 +``` +-e ENABLE_JMX=true -e JMX_HOST=$HOSTNAME -p 7091:7091 +``` ### Enable Aikar's Flags diff --git a/start-minecraftFinalSetup b/start-minecraftFinalSetup index 7b227e12..0e8fb9d3 100644 --- a/start-minecraftFinalSetup +++ b/start-minecraftFinalSetup @@ -84,7 +84,6 @@ if [ -n "$JVM_DD_OPTS" ]; then fi if isTrue ${ENABLE_JMX}; then - : ${JMX_HOST:=0.0.0.0} : ${JMX_PORT:=7091} JVM_OPTS="${JVM_OPTS} -Dcom.sun.management.jmxremote.local.only=false @@ -92,8 +91,8 @@ if isTrue ${ENABLE_JMX}; then -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false - -Dcom.sun.management.jmxremote.host=${JMX_HOST} - -Djava.rmi.server.hostname=${JMX_HOST}" + -Dcom.sun.management.jmxremote.host=${JMX_BINDING:-0.0.0.0} + -Djava.rmi.server.hostname=${JMX_HOST:-localhost}" log "JMX is enabled. Make sure you have port forwarding for ${JMX_PORT}" fi From 0cbfb81b4cf0399d9f185d9fab00fef8a8bbe423 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 20 Feb 2021 17:35:26 -0600 Subject: [PATCH 06/12] misc: Removed debug --- start-finalSetupEnvVariables | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/start-finalSetupEnvVariables b/start-finalSetupEnvVariables index cfb36413..1113162e 100644 --- a/start-finalSetupEnvVariables +++ b/start-finalSetupEnvVariables @@ -44,5 +44,4 @@ if isTrue "${REPLACE_ENV_VARIABLES}"; then done fi -#DO NOT COMMIT -#exec ${SCRIPTS:-/}start-minecraftFinalSetup $@ +exec ${SCRIPTS:-/}start-minecraftFinalSetup $@ From fa53abdfb7866212a1744f7bacaf6066ebb984c7 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 21 Feb 2021 14:32:41 -0600 Subject: [PATCH 07/12] Add missing server.properties when needed #776 --- start-configuration | 1 - start-finalSetupServerProperties | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/start-configuration b/start-configuration index 60e38fd5..602616c6 100644 --- a/start-configuration +++ b/start-configuration @@ -61,7 +61,6 @@ if [[ $RCON_PASSWORD_FILE ]]; then log "" fi -export SERVER_PROPERTIES=/data/server.properties export VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json case "X$VERSION" in diff --git a/start-finalSetupServerProperties b/start-finalSetupServerProperties index 08f19bef..d1fa9ede 100644 --- a/start-finalSetupServerProperties +++ b/start-finalSetupServerProperties @@ -2,6 +2,8 @@ . ${SCRIPTS:-/}start-utils +: ${SERVER_PROPERTIES:=/data/server.properties} + # FUNCTIONS function setServerProp { local prop=$1 @@ -12,8 +14,13 @@ function setServerProp { TRUE|FALSE) var=${var,,} ;; esac - log "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}" - sed -i "/^${prop}\s*=/ c ${prop}=${var//\\/\\\\}" "$SERVER_PROPERTIES" + if grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then + log "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}" + sed -i "/^${prop}\s*=/ c ${prop}=${var//\\/\\\\}" "$SERVER_PROPERTIES" + else + log "Adding ${prop} with '${var}' in ${SERVER_PROPERTIES}" + echo "${prop}=${var//\\/\\\\}" >> "$SERVER_PROPERTIES" + fi else log "Skip setting ${prop}" fi From 32bc0382d63d618d051d45cd18c24d6d239ba783 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 21 Feb 2021 14:36:03 -0600 Subject: [PATCH 08/12] Only show skipped properties when debugging --- start-finalSetupServerProperties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start-finalSetupServerProperties b/start-finalSetupServerProperties index d1fa9ede..a4c7c62c 100644 --- a/start-finalSetupServerProperties +++ b/start-finalSetupServerProperties @@ -22,7 +22,7 @@ function setServerProp { echo "${prop}=${var//\\/\\\\}" >> "$SERVER_PROPERTIES" fi else - log "Skip setting ${prop}" + isDebugging && log "Skip setting ${prop}" fi } From e5e97a35607d2462d8314b482966ab20147b182d Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Tue, 23 Feb 2021 20:04:34 -0600 Subject: [PATCH 09/12] Use file to speed up removal of old PaperMC server jars #779 --- start-deployPaper | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/start-deployPaper b/start-deployPaper index 10a88d25..6058be2b 100644 --- a/start-deployPaper +++ b/start-deployPaper @@ -57,8 +57,9 @@ else fi log "Removing old PaperMC versions ..." - paperJarSearchString=${SERVER/$build/[0-9]*} - find . -maxdepth 1 -name "$paperJarSearchString" ! -name "$SERVER" -delete -print + for f in paper-*.jar; do + [[ $f != $SERVER ]] && rm $f + done log "Downloading PaperMC $VANILLA_VERSION (build $build) ..." curl -fsSL -o "$SERVER" "${zarg[@]}" \ From 9299f00d2010899b77624c5edaafe1725804ca92 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Thu, 25 Feb 2021 19:07:16 -0600 Subject: [PATCH 10/12] Pre-process special characters in REPLACE_ENV_VARIABLES #718 --- start-finalSetupEnvVariables | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/start-finalSetupEnvVariables b/start-finalSetupEnvVariables index 1113162e..e1508576 100644 --- a/start-finalSetupEnvVariables +++ b/start-finalSetupEnvVariables @@ -34,6 +34,10 @@ if isTrue "${REPLACE_ENV_VARIABLES}"; then fi log "Replacing $name with $value ..." + + value=${value//\\/\\\\} + value=${value//#/\\#} + find /data/ \ $dirExcludes \ -type f \ From 53f5fbb77ffed8afc7ff9e3bd024d6e00a3fbdf3 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 27 Feb 2021 11:05:16 -0600 Subject: [PATCH 11/12] docs: Fixed examples of quoting SEED and MOTD #782 --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e2f55197..4c574e0c 100644 --- a/README.md +++ b/README.md @@ -944,7 +944,11 @@ It determines the server-side viewing distance. If you want to create the Minecraft level with a specific seed, use `SEED`, such as - docker run -d -e SEED=1785852800490497919 ... + -e SEED=1785852800490497919 + +If using a negative value for the seed, make sure to quote the value such as: + + -e SEED="-1785852800490497919" ### Game Mode @@ -966,16 +970,13 @@ For example: The message of the day, shown below each server entry in the UI, can be changed with the `MOTD` environment variable, such as - docker run -d -e 'MOTD=My Server' ... + -e MOTD="My Server" If you leave it off, a default is computed from the server type and version, such as A Paper Minecraft Server powered by Docker -when `TYPE` is `PAPER`. That way you can easily differentiate between several servers you may have started. - -_The example shows how to specify a server message of the day that contains spaces by putting quotes -around the whole thing._ +That way you can easily differentiate between several servers you may have started. ### PVP Mode From 861aec6bd616cc0b3a84ca8c1cb6e2d10fa9f610 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 27 Feb 2021 20:37:59 -0600 Subject: [PATCH 12/12] Added option for MOHIST_BUILD #781 --- README.md | 3 +++ start-deployMohist | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4c574e0c..3a0adec9 100644 --- a/README.md +++ b/README.md @@ -528,6 +528,9 @@ A [Mohist](https://github.com/Mohist-Community/Mohist) server can be used with > **NOTE** there are limited base versions supported, so you will also need to set `VERSION`, such as "1.12.2" +By default the latest build will be used; however, a specific build number can be selected by setting `MOHIST_BUILD`, such as + + -e VERSION=1.16.5 -e MOHIST_BUILD=374 ## Running a Catserver type server diff --git a/start-deployMohist b/start-deployMohist index 1c67bd08..0cc96484 100644 --- a/start-deployMohist +++ b/start-deployMohist @@ -6,6 +6,7 @@ set -e isDebugging && set -x requireVar VANILLA_VERSION +: ${MOHIST_BUILD:=lastSuccessfulBuild} mohistJobs=https://ci.codemc.io/job/Mohist-Community/job/ mohistJob=${mohistJobs}Mohist-${VANILLA_VERSION}/ @@ -17,12 +18,12 @@ if ! curl -X HEAD -o /dev/null -fsSL "${mohistJob}"; then exit 1 fi -latestBuildRelPath=$( - curl -fsSL "${mohistJob}lastSuccessfulBuild/api/json" | +buildRelPath=$( + curl -fsSL "${mohistJob}${MOHIST_BUILD}/api/json" | jq -r '.artifacts[0].relativePath' ) -baseName=$(basename "${latestBuildRelPath}") +baseName=$(basename "${buildRelPath}") if [[ ${baseName} != *-server.jar* ]]; then log "ERROR: mohist build for ${VANILLA_VERSION} is not a valid server jar, found ${baseName}" log " check https://ci.codemc.io/job/Mohist-Community/ for available versions" @@ -34,7 +35,7 @@ export SERVER="/data/${baseName}" if [ ! -f ${SERVER} ]; then log "Downloading ${baseName}" - curl -o "${SERVER}" -fsSL "${mohistJob}lastSuccessfulBuild/artifact/${latestBuildRelPath}" + curl -o "${SERVER}" -fsSL "${mohistJob}${MOHIST_BUILD}/artifact/${buildRelPath}" fi export SKIP_LOG4J_CONFIG=true