diff --git a/README.md b/README.md index 3a9083f2..0aa245fa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/itzg/minecraft-server.svg)](https://hub.docker.com/r/itzg/minecraft-server/) [![Docker Stars](https://img.shields.io/docker/stars/itzg/minecraft-server.svg?maxAge=2592000)](https://hub.docker.com/r/itzg/minecraft-server/) [![GitHub Issues](https://img.shields.io/github/issues-raw/itzg/docker-minecraft-server.svg)](https://github.com/itzg/docker-minecraft-server/issues) -[![Discord](https://img.shields.io/discord/660567679458869252)](https://discord.gg/DXfKpjB) +[![Discord](https://img.shields.io/discord/660567679458869252?label=Discord&logo=discord)](https://discord.gg/DXfKpjB) [![Build and Publish](https://github.com/itzg/docker-minecraft-server/workflows/Build%20and%20Publish/badge.svg)](https://github.com/itzg/docker-minecraft-server/actions) [![](https://img.shields.io/badge/Donate-Buy%20me%20a%20coffee-orange.svg)](https://www.buymeacoffee.com/itzg) @@ -147,6 +147,7 @@ To use a different version of Java, please use a docker tag to run your Minecraf | Tag name | Description | Linux | | -------------- | ------------------------------------------- | ------------ | | latest | **Default**. Uses Java version 8 update 212 | Alpine Linux | +| adopt14 | Uses Java version 14 latest update | Alpine Linux | | adopt13 | Uses Java version 13 latest update | Alpine Linux | | adopt11 | Uses Java version 11 latest update | Alpine Linux | | openj9 | Uses Eclipse OpenJ9 JVM | Alpine Linux | @@ -226,6 +227,10 @@ describes period of the daemonized state machine, that handles the pausing of th The [examples directory](https://github.com/itzg/docker-minecraft-server/tree/master/examples) also provides examples of deploying the [itzg/minecraft-server](https://hub.docker.com/r/itzg/minecraft-server/) Docker image. +### Amazon Web Services (AWS) Deployment + +If you're looking for a simple way to deploy this to the Amazon Web Services Cloud, check out the [Minecraft Server Deployment (CloudFormation) repository](https://github.com/vatertime/minecraft-spot-pricing). This repository contains a CloudFormation template that will get you up and running in AWS in a matter of minutes. Optionally it uses Spot Pricing so the server is very cheap, and you can easily turn it off when not in use. + ## Running a Forge Server Enable Forge server mode by adding a `-e TYPE=FORGE` to your command-line. @@ -296,7 +301,7 @@ or downloading a world with the `WORLD` option. There are two additional volumes that can be mounted; `/mods` and `/config`. Any files in either of these filesystems will be copied over to the main -`/data` filesystem before starting Minecraft. +`/data` filesystem before starting Minecraft. If you want old mods to be removed as the `/mods` content is updated, then add `-e REMOVE_OLD_MODS=TRUE`. This works well if you want to have a common set of modules in a separate location, but still have multiple worlds with different server requirements @@ -557,29 +562,31 @@ Just change it with `SPONGEBRANCH`, such as: ## Running a Fabric Server -Enable Fabric server mode by adding a `-e TYPE=FABRIC` to your command-line. -By default the container will run the latest version of [Fabric server](http://fabricmc.net/use/) -but you can also choose to run a specific version with `-e FABRICVERSION=0.5.0.32`. +Enable [Fabric server](http://fabricmc.net/use/) mode by adding a `-e TYPE=FABRIC` to your command-line. By default, the container will run the latest version, but you can also choose to run a specific version with `VERSION`. - $ docker run -d -v /path/on/host:/data \ - -e TYPE=FABRIC -e FABRICVERSION=0.5.0.32 \ - -p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server +``` +docker run -d -v /path/on/host:/data \ + -e TYPE=FABRIC \ + -p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server +``` -To use a pre-downloaded Fabric installer, place it in the attached `/data` directory and -specify the name of the installer file with `FABRIC_INSTALLER`, such as: +A specific installer version can be requested using `FABRIC_INSTALLER_VERSION`. - $ docker run -d -v /path/on/host:/data ... \ - -e FABRIC_INSTALLER=fabric-installer-0.5.0.32.jar ... +To use a pre-downloaded Fabric installer, place it in a directory attached into the container, such as the `/data` volume and specify the name of the installer file with `FABRIC_INSTALLER`, such as: -To download a Fabric installer from a custom location, such as your own file repository, specify -the URL with `FABRIC_INSTALLER_URL`, such as: +``` +docker run -d -v /path/on/host:/data ... \ + -e FABRIC_INSTALLER=fabric-installer-0.5.0.32.jar ... +``` - $ docker run -d -v /path/on/host:/data ... \ - -e FORGE_INSTALLER_URL=http://HOST/fabric-installer-0.5.0.32.jar ... +To download a Fabric installer from a custom location, such as your own file repository, specify the URL with `FABRIC_INSTALLER_URL`, such as: -In both of the cases above, there is no need for the `VERSION` or `FABRICVERSION` variables. +``` +docker run -d -v /path/on/host:/data ... \ + -e FABRIC_INSTALLER_URL=http://HOST/fabric-installer-0.5.0.32.jar ... +``` -In order to add mods, you have two options. +In order to add mods, you have two options: ### Using the /data volume @@ -1114,4 +1121,4 @@ To run this image on a RaspberryPi 3 B+, 4, or newer, use the image tag itzg/minecraft-server:multiarch -> NOTE: you may need to lower the memory allocation, such as `-e MEMORY=750m` +> NOTE: you may need to lower the memory allocation, such as `-e MEMORY=750m` \ No newline at end of file diff --git a/docker-versions-create.sh b/docker-versions-create.sh index 8ed98c54..b9a4c0a9 100755 --- a/docker-versions-create.sh +++ b/docker-versions-create.sh @@ -1,7 +1,7 @@ #!/bin/bash #set -x # Use this variable to indicate a list of branches that docker hub is watching -branches_list=('openj9' 'openj9-nightly' 'adopt11' 'adopt13' 'multiarch') +branches_list=('openj9' 'openj9-nightly' 'adopt11' 'adopt13' 'adopt14' 'multiarch' 'multiarch-latest') function TrapExit { echo "Checking out back in master" diff --git a/files/autopause/autopause-fcns.sh b/files/autopause/autopause-fcns.sh index aea37a6f..5ebae93c 100644 --- a/files/autopause/autopause-fcns.sh +++ b/files/autopause/autopause-fcns.sh @@ -13,7 +13,7 @@ rcon_client_exists() { } mc_server_listening() { - [[ -n $(netstat -tln | grep "0.0.0.0:$SERVER_PORT" | grep LISTEN) ]] + [[ -n $(netstat -tln | grep -e "0.0.0.0:$SERVER_PORT" -e ":::$SERVER_PORT" | grep LISTEN) ]] } java_clients_connected() { @@ -29,7 +29,7 @@ java_clients_connected() { # remember, that the host network mode does not work with autopause because of the knockd utility for (( i=0; i<${#connections[@]}; i++ )) do - if [[ ! $(echo "${connections[$i]}" | awk '{print $5}') =~ ^\s*127\.0\.0\.1:.*$ ]] ; then + if [[ ! $(echo "${connections[$i]}" | awk '{print $5}') =~ ^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$ ]] ; then # not localhost return 0 fi diff --git a/start-deployBukkitSpigot b/start-deployBukkitSpigot index cb2309e5..37b59269 100644 --- a/start-deployBukkitSpigot +++ b/start-deployBukkitSpigot @@ -1,6 +1,7 @@ #!/bin/bash . ${SCRIPTS:-/}start-utils +isDebugging && set -x set -e @@ -58,16 +59,24 @@ function downloadSpigot { ;; esac + if [[ ${VERSION^^} = LATEST ]]; then + VANILLA_VERSION=$(restify https://getbukkit.org/download/spigot --attribute='property=og:title' | jq -r '.[0] | .attributes | select(.property == "og:title") | .content | split(" ") | .[-1]') + fi + if [[ -z $downloadUrl ]]; then downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar" fi + setServerVar if [ -f $SERVER ]; then # tell curl to only download when newer - zarg="-z $SERVER" + curlArgs="-z $SERVER" + fi + if isDebugging; then + curlArgs="$curlArgs -v" fi log "Downloading $match from $downloadUrl ..." - curl -fsSL -o $SERVER $zarg "$downloadUrl" + curl -fsSL -o $SERVER $curlArgs "$downloadUrl" if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then cat <&1) +build=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}" -H "accept: application/json" \ + | jq '.builds[-1]') case $? in 0) ;; - 22) # = 404 HTTP status - if versions=$(curl -fsSL https://papermc.io/api/v1/paper 2> /dev/null); then - if [[ $VERSION = LATEST ]]; then - VANILLA_VERSION=$(echo $versions | jq -r '.versions[0]') + 22) + versions=$(curl -fsSL "https://papermc.io/api/v2/projects/paper" -H "accept: application/json") + if [[ $VERSION = LATEST ]]; then + VANILLA_VERSION=$(echo "$versions" | jq -r '.versions[-1]') log "WARN: using ${VANILLA_VERSION} since that's the latest provided by PaperMC" # re-execute the current script with the newly computed version exec $0 "$@" - fi - log "ERROR: ${VANILLA_VERSION} is not (yet) published by PaperMC" - log " Set VERSION to one of the following: " - log " $(echo $versions | jq -r '.versions | join(", ")')" - else - log "ERROR: failed to retrieve versions from https://papermc.io/api/v1/paper" fi - exit 3 + log "ERROR: ${VANILLA_VERSION} is not published by PaperMC" + log " Set VERSION to one of the following: " + log " $(echo "$versions" | jq -r '.versions | join(", ")')" + exit 1 ;; *) - log "ERROR: failed to contact PaperMC at $downloadUrl" - log " $out" - exit 3 + echo "ERROR: unknown error while looking up PaperMC version=${VANILLA_VERSION}" + exit 1 ;; esac +if [ $? != 0 ]; then + echo "ERROR: failed to lookup PaperMC build from version ${VANILLA_VERSION}" + exit 1 +fi + +export SERVER=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}" -H "accept: application/json" \ + | jq -r '.downloads.application.name') +if [ $? != 0 ]; then + echo "ERROR: failed to lookup PaperMC download file from version=${VANILLA_VERSION} build=${build}" + exit 1 +fi + +if [ -f "$SERVER" ]; then + zarg=(-z "$SERVER") +fi + +log "Downloading PaperMC $VANILLA_VERSION (build $build) ..." +curl -fsSL -o "$SERVER" "${zarg[@]}" \ + "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}/downloads/${SERVER}" \ + -H "accept: application/java-archive" +if [ $? != 0 ]; then + echo "ERROR: failed to download PaperMC from version=${VANILLA_VERSION} build=${build} download=${SERVER}" + exit 1 +fi # Normalize on Spigot for downstream operations export TYPE=SPIGOT diff --git a/start-minecraftFinalSetup b/start-minecraftFinalSetup index c2377d3a..c19a2a13 100644 --- a/start-minecraftFinalSetup +++ b/start-minecraftFinalSetup @@ -54,7 +54,10 @@ done if [ -d /mods ]; then log "Copying any mods over..." mkdir -p /data/mods - rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs --update /mods /data + if isTrue "${REMOVE_OLD_MODS}"; then + rsyncArgs=(--delete) + fi + rsync -a --out-format="update:%f:Last Modified %M" "${rsyncArgs[@]}" --prune-empty-dirs --update /mods /data fi [ -d /data/config ] || mkdir /data/config