Compare commits

...

47 Commits

Author SHA1 Message Date
Geoff Bourne
6bb2323c46 Auto-merging docker-versions-create.sh
CONFLICT (content): Merge conflict in docker-versions-create.sh
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
2021-02-07 09:07:30 -06:00
Geoff Bourne
beeaf1a996 ci: Added java8-multiarch to build and docs 2021-02-06 15:48:27 -06:00
Geoff Bourne
96aa1054dc Upgraded mainline/latest to Java 11 2021-02-06 15:21:20 -06:00
Geoff Bourne
e7937206af ci: Added java15 to multiarch build 2021-02-06 15:12:34 -06:00
Geoff Bourne
081b2c11e4 ci: Introduced java15 branch
ci: Deprecated adopt13, adopt14, openj9-nightly
2021-02-06 15:11:03 -06:00
Geoff Bourne
f342f4aa98 ci: Introduced java15 branch
ci: Deprecated adopt13, adopt14, openj9-nightly
2021-02-06 15:07:42 -06:00
Geoff Bourne
4e73e69342 ci: Added build-multiarch.yml to align merges 2021-02-06 14:52:20 -06:00
Geoff Bourne
c6ff80b71c docs: Clarify MEMORY limits vs overall container memory
Related to #691
2021-02-01 21:15:33 -06:00
M*C*O
37cad3f255 docs: Document LEVEL_TYPE: BIOMESOP (#741) 2021-02-01 12:39:55 -06:00
Geoff Bourne
7814ca21b5 Merge branch 'master' into java8
# Conflicts:
#	README.md
#	start-configuration
2021-01-30 18:56:33 -06:00
Geoff Bourne
5700f36a6f Renamed forge branch to java8 2021-01-30 18:49:46 -06:00
Geoff Bourne
b8806629ec Merged latest from master 2021-01-30 16:48:11 -06:00
Geoff Bourne
4a7f838a0f Upgraded mainline/latest to Java 11 2021-01-30 16:16:36 -06:00
Geoff Bourne
34f800d815 ci: Added forge branch to builds 2021-01-30 16:02:15 -06:00
Geoff Bourne
2d07dee4df Prepared forge branch's Dockerfile 2021-01-30 15:58:03 -06:00
Geoff Bourne
ffec50141a Fixed MODS provides from github release URLs
For #731
2021-01-28 20:55:08 -06:00
Geoff Bourne
54027049d3 docs: Added compose example to data attaching section 2021-01-24 12:31:56 -06:00
Geoff Bourne
4c2829e3d2 docs: Added a simple docker compose example 2021-01-21 13:36:41 -06:00
Geoff Bourne
69e308d420 Split eula header into two lines of comments
#728
- Found that https://github.com/Yoosk/ServerStarter hard coded expectation that eula property was on third line
2021-01-19 21:36:21 -06:00
Geoff Bourne
ad46f10b55 Added option to override whitelist and ops files
#726
2021-01-17 10:09:41 -06:00
Eugene
cd0fdfc95b Add an option to override the icon which already has been set. (#723) 2021-01-13 16:47:15 -06:00
Geoff Bourne
d95abfce82 ci: Added openj9-11 tags pattern 2021-01-12 17:33:03 -06:00
Geoff Bourne
942a125e04 ci: Added non-versioned cache as restore-key fallback 2021-01-12 17:30:58 -06:00
Geoff Bourne
a3677d5aa8 ci: Enabled pull in build step 2021-01-12 17:20:57 -06:00
Geoff Bourne
f927933c46 Added openj9 JDK11 variant
For #721
2021-01-12 17:18:08 -06:00
Geoff Bourne
5ab83bcb21 ci: Switched build to docker/build-push-action@v2 2021-01-09 14:13:18 -06:00
Dubhar
fdf5fb46bc fix/681 (#719)
* [shellcheck] prevent globbing

* fix/681 remove old PaperMC before downloading new

Fixes #681 

Co-authored-by: Dubhar <thorsten.jerosch@gmail.com>
2021-01-09 11:03:21 -06:00
Geoff Bourne
8c6ca5e999 Restored the ability for PAPERBUILD to be used with TYPE=PAPER
For #715
2021-01-07 20:03:42 -06:00
Geoff Bourne
bb2b9eeea9 docs: Changed FORGEVERSION example to use a valid combination
For #716
2021-01-07 11:02:19 -06:00
Geoff Bourne
d1cbce3f89 docs: Clarified usage of VERSION with FORGE type
For #716
2021-01-06 22:49:22 -06:00
Geoff Bourne
55b5f6821f Fixed ops and white-list setup for CurseForge modpacks named with spaces
For #717
2021-01-06 22:38:18 -06:00
Michael Kirsch
2fb01b4adf Autopause update: allow network interface selection (#711)
* Cherry-pick: Fixing AUTOPAUSE on Raspberry Pi 4s (#708)

* implement autopause interface selection

* concentrate ps calls in function file

* wording and add note about PAPER's etc watchdogs
2021-01-02 11:27:03 -06:00
Geoff Bourne
02bce8c3a8 docs: Documented adopt15 and multiarch-latest tags 2021-01-02 11:12:07 -06:00
Nathanial L. McConnell
468671a3fa Update README.md (#712)
Change "Please" to "Place"
2021-01-01 15:23:04 -06:00
Geoff Bourne
8ee650f38d Allowed CF_BASE_DIR/FTB_BASE_DIR to be configured
For #518
2020-12-31 13:11:37 -06:00
Geoff Bourne
3de2bf88df Escaped backslashes when setting server property value (#706)
* Escaped backslashes when setting server property value
For #446

* Fixed pattern substitution to "replace all"
2020-12-30 09:42:29 -06:00
Geoff Bourne
1fcbd8410f Allow CUSTOM_SERVER to reference not-yet-existing file from GENERIC_PACK
For #703
2020-12-29 10:56:05 -06:00
Gabriel Fontes
d40bbdc3a5 Envvars in files from /config and /mods now replaced as expected (#701)
Envvars in files from `/config` and `/mods` now replaced as expected (#701)
2020-12-27 22:01:03 -06:00
aspro-at
61c291ae4e Fixed REMOVE_OLD_MODS with missing /data/mods or /data/plugins #667 (#697) 2020-12-23 13:25:14 -06:00
Geoff Bourne
f613228619 Restored support for PAPER_DOWNLOAD_URL
Fixes #687
2020-12-15 20:40:00 -06:00
Silthus
ca9f883352 feat: add COPY_CONFIG_DEST option (#689) 2020-12-15 13:31:51 -06:00
Silthus
9d68fa3b88 feat: improvde REMOVE_OLD_MODS option (#688) 2020-12-13 20:00:06 -06:00
Geoff Bourne
d3a5885d95 Fixed handling of query parameters in MODS url
For #684
2020-12-12 15:22:07 -06:00
Geoff Bourne
c1db13c1f6 Fixed dirname handling in find for SPIGOT WORLD handling
For #685
2020-12-12 11:10:13 -06:00
Mike Wilson
31b0f711b8 Fixing some spigot world import issues (#683)
* Fixing adding an existing spigot world and removing incorrectly identifying spigot worlds as multiple worlds

* Update start-finalSetupWorld

Co-authored-by: Geoff Bourne <itzgeoff@gmail.com>

Co-authored-by: Geoff Bourne <itzgeoff@gmail.com>
2020-12-12 08:26:32 -06:00
Geoff Bourne
59ca1ce3a6 Improved URL handling for GENERIC_PACK
For #684
2020-12-11 21:12:44 -06:00
Geoff Bourne
0f7bd5f4fd ci: Added adopt15 branch releases 2020-12-07 10:54:36 -06:00
26 changed files with 569 additions and 259 deletions

80
.github/workflows/build-multiarch.yml vendored Normal file
View File

@@ -0,0 +1,80 @@
name: Build and publish multiarch
on:
push:
branches:
- multiarch
- java8-multiarch
- multiarch-latest
- java15
- test/multiarch/*
tags:
- "[0-9]+.[0-9]+.[0-9]+-multiarch"
- "[0-9]+.[0-9]+.[0-9]+-multiarch-latest"
- "[0-9]+.[0-9]+.[0-9]+-java15"
jobs:
docker-buildx:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.2.0
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=itzg/minecraft-server
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
if [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=${GITHUB_REF#refs/heads/}
if [[ $VERSION == master ]]; then
VERSION=latest
fi
fi
TAGS="${DOCKER_IMAGE}:${VERSION//\//-}"
echo ::set-output name=tags::${TAGS}
echo ::set-output name=cache_from::${TAGS}
echo ::set-output name=version::${VERSION//\//-}
echo ::set-output name=cache_version::${VERSION//\//-}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
labels: |
org.opencontainers.image.documentation=https://github.com/itzg/docker-minecraft-server
org.opencontainers.image.source=https://github.com/itzg/docker-minecraft-server
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@@ -4,22 +4,22 @@ on:
push: push:
branches: branches:
- master - master
- java8
- openj9 - openj9
- openj9-nightly - openj9-11
- adopt11 - adopt11
- adopt13 - test/*
- adopt14
tags: tags:
- "[0-9]+.[0-9]+.[0-9]+" - "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-java8"
- "[0-9]+.[0-9]+.[0-9]+-openj9" - "[0-9]+.[0-9]+.[0-9]+-openj9"
- "[0-9]+.[0-9]+.[0-9]+-openj9-11"
- "[0-9]+.[0-9]+.[0-9]+-openj9-nightly" - "[0-9]+.[0-9]+.[0-9]+-openj9-nightly"
- "[0-9]+.[0-9]+.[0-9]+-adopt11" - "[0-9]+.[0-9]+.[0-9]+-adopt11"
- "[0-9]+.[0-9]+.[0-9]+-adopt13"
- "[0-9]+.[0-9]+.[0-9]+-adopt14"
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@@ -30,20 +30,68 @@ jobs:
build: build:
needs: needs:
- test - test
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build and push Docker images - name: Prepare
uses: docker/build-push-action@v1.1.0 id: prep
run: |
DOCKER_IMAGE=itzg/minecraft-server
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
if [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=${GITHUB_REF#refs/heads/}
if [[ $VERSION == master ]]; then
VERSION=latest
fi
fi
TAGS="${DOCKER_IMAGE}:${VERSION//\//-}"
echo ::set-output name=tags::${TAGS}
echo ::set-output name=cache_from::${TAGS}
echo ::set-output name=version::${VERSION//\//-}
echo ::set-output name=cache_version::${VERSION//\//-}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with: with:
repository: itzg/minecraft-server
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
tag_with_ref: true
tag_with_sha: false - name: Build and push
cache_froms: itzg/minecraft-server:latest id: docker_build
add_git_labels: true uses: docker/build-push-action@v2
labels: org.opencontainers.image.url=https://github.com/itzg/docker-minecraft-server,org.opencontainers.image.documentation=https://github.com/itzg/docker-minecraft-server with:
context: .
file: ./Dockerfile
# ensure latest base image is used
pull: true
# publish
push: true push: true
# tags determined by prep step
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
labels: |
org.opencontainers.image.documentation=https://github.com/itzg/docker-minecraft-server
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.source=https://github.com/itzg/docker-minecraft-server
org.opencontainers.image.revision=${{ github.sha }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@@ -1,4 +1,4 @@
FROM openjdk:8u212-jre-alpine FROM adoptopenjdk/openjdk11:alpine-jre
LABEL org.opencontainers.image.authors="Geoff Bourne <itzgeoff@gmail.com>" LABEL org.opencontainers.image.authors="Geoff Bourne <itzgeoff@gmail.com>"
@@ -74,7 +74,8 @@ ENV UID=1000 GID=1000 \
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \ TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \ PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
LEVEL_TYPE=DEFAULT SERVER_PORT=25565 ONLINE_MODE=TRUE SERVER_NAME="Dedicated Server" \ LEVEL_TYPE=DEFAULT SERVER_PORT=25565 ONLINE_MODE=TRUE SERVER_NAME="Dedicated Server" \
ENABLE_AUTOPAUSE=false AUTOPAUSE_TIMEOUT_EST=3600 AUTOPAUSE_TIMEOUT_KN=120 AUTOPAUSE_TIMEOUT_INIT=600 AUTOPAUSE_PERIOD=10 ENABLE_AUTOPAUSE=false AUTOPAUSE_TIMEOUT_EST=3600 AUTOPAUSE_TIMEOUT_KN=120 AUTOPAUSE_TIMEOUT_INIT=600 \
AUTOPAUSE_PERIOD=10 AUTOPAUSE_KNOCK_INTERFACE=eth0
COPY start* / COPY start* /
COPY health.sh / COPY health.sh /

120
README.md
View File

@@ -116,8 +116,24 @@ to map a directory on your host machine to the container's `/data` directory, su
docker run -d -v /path/on/host:/data ... docker run -d -v /path/on/host:/data ...
When attached in this way you can stop the server, edit the configuration under your attached `/path/on/host` When attached in this way you can stop the server, edit the configuration under your attached `/path/on/host` and start the server again with `docker start CONTAINER_ID` to pick up the new configuration.
and start the server again with `docker start CONTAINERID` to pick up the new configuration.
As example, using Docker compose, create the following `docker-compose.yml` in its own directory and the container will automatically create/attach the relative directory `data` to the container:
```yaml
version: "3"
services:
mc:
image: itzg/minecraft-server
ports:
- 25565:25565
environment:
EULA: "TRUE"
volumes:
# attach the relative directory 'data' to the container's /data path
./data:/data
```
## Versions ## Versions
@@ -144,21 +160,31 @@ the server jar remain in the `/data` directory. It is safe to remove those._
To use a different version of Java, please use a docker tag to run your Minecraft server. To use a different version of Java, please use a docker tag to run your Minecraft server.
| Tag name | Description | Linux | | Tag name | Java version | Linux | JVM Type | Architecture |
| -------------- | ------------------------------------------- | ------------ | | -------------- | -------------|--------|----------|-------------------|
| latest | **Default**. Uses Java version 8 update 212 | Alpine Linux | | latest | 11 | Alpine | Hotspot | amd64 |
| adopt14 | Uses Java version 14 latest update | Alpine Linux | | java8 | 8 | Alpine | Hotspot | amd64 |
| adopt13 | Uses Java version 13 latest update | Alpine Linux | | java8-multiarch | 8 | Debian | Hotspot | amd64,arm64,armv7 |
| adopt11 | Uses Java version 11 latest update | Alpine Linux | | java15 | 15 | Debian | Hotspot | amd64,arm64,armv7 |
| openj9 | Uses Eclipse OpenJ9 JVM | Alpine Linux | | adopt11 | 11 | Alpine | Hotspot | amd64 |
| openj9-nightly | Uses Eclipse OpenJ9 JVM testing builds | Alpine Linux | | openj9 | 8 | Alpine | OpenJ9 | amd64 |
| multiarch | Uses Java version 8 latest update | Debian Linux | | openj9-11 | 11 | Alpine | OpenJ9 | amd64 |
| multiarch | 11 | Debian | Hotspot | amd64,arm64,armv7 |
| multiarch-latest | 15+ | Debian | Hotspot | amd64,arm64,armv7 |
For example, to use a Java version 13: For example, to use Java version 15 on any supported architecture:
docker run --name mc itzg/minecraft-server:adopt13 docker run --name mc itzg/minecraft-server:java15
Keep in mind that some versions of Minecraft server can't work on the newest versions of Java. Also, FORGE doesn't support openj9 JVM implementation. > Keep in mind that some versions of Minecraft server can't work on the newest versions of Java. Also, FORGE doesn't support openj9 JVM implementation.
### Deprecated Image Tags
The following image tags have been deprecated and are no longer receiving updates:
- adopt13
- adopt14
- adopt15
- openj9-nightly
## Healthcheck ## Healthcheck
@@ -180,22 +206,22 @@ healthy
Some orchestration systems, such as Portainer, don't allow for disabling the default `HEALTHCHECK` declared by this image. In those cases you can approximate the disabling of healthchecks by setting the environment variable `DISABLE_HEALTHCHECK` to `true`. Some orchestration systems, such as Portainer, don't allow for disabling the default `HEALTHCHECK` declared by this image. In those cases you can approximate the disabling of healthchecks by setting the environment variable `DISABLE_HEALTHCHECK` to `true`.
## Autopause (experimental) ## Autopause
### Description ### Description
> EXPERIMENTAL: this feature only works with default bridge networking using official Docker distributions. Host networking and container management software, such as Portainer, and NAS solutions do not seem to provide compatible networking.
There are various bug reports on [Mojang](https://bugs.mojang.com) about high CPU usage of servers with newer versions, even with few or no clients connected (e.g. [this one](https://bugs.mojang.com/browse/MC-149018), in fact the functionality is based on [this comment in the thread](https://bugs.mojang.com/browse/MC-149018?focusedCommentId=593606&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-593606)). There are various bug reports on [Mojang](https://bugs.mojang.com) about high CPU usage of servers with newer versions, even with few or no clients connected (e.g. [this one](https://bugs.mojang.com/browse/MC-149018), in fact the functionality is based on [this comment in the thread](https://bugs.mojang.com/browse/MC-149018?focusedCommentId=593606&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-593606)).
An autopause functionality has been added to this image to monitor whether clients are connected to the server. If for a specified time no client is connected, the Java process is stopped. When knocking on the server port (e.g. by the ingame Multiplayer server overview), the process is resumed. The experience for the client does not change. An autopause functionality has been added to this image to monitor whether clients are connected to the server. If for a specified time no client is connected, the Java process is stopped. When knocking on the server port (e.g. by the ingame Multiplayer server overview), the process is resumed. The experience for the client does not change.
Of course, even loaded chunks are not ticked when the process is stopped. Of course, even loaded chunks are not ticked when the process is stopped.
From the server's point of view, the pausing causes a single tick to take as long as the process is stopped, so the server watchdog might intervene after the process is continued, possibly forcing a container restart. To prevent this, ensure that the `max-tick-time` in the `server.properties` file is set correctly. From the server's point of view, the pausing causes a single tick to take as long as the process is stopped, so the server watchdog might intervene after the process is continued, possibly forcing a container restart. To prevent this, ensure that the `max-tick-time` in the `server.properties` file is set correctly. Non-vanilla versions might have their own configuration file, you might have to disable their watchdogs separately (e.g. PAPER Servers).
On startup the `server.properties` file is checked and, if applicable, a warning is printed to the terminal. When the server is created (no data available in the persistent directory), the properties file is created with the Watchdog disabled. On startup the `server.properties` file is checked and, if applicable, a warning is printed to the terminal. When the server is created (no data available in the persistent directory), the properties file is created with the Watchdog disabled.
The utility used to wake the server (`knock(d)`) works at network interface level. So the correct interface has to be set using the `AUTOPAUSE_KNOCK_INTERFACE` variable when using non-default networking environments (e.g. host-networking, Portainer oder NAS solutions). See the description of the variable below.
A starting, example compose file has been provided in [examples/docker-compose-autopause.yml](examples/docker-compose-autopause.yml). A starting, example compose file has been provided in [examples/docker-compose-autopause.yml](examples/docker-compose-autopause.yml).
### Enabling Autopause ### Enabling Autopause
@@ -206,7 +232,7 @@ Enable the Autopause functionality by setting:
-e ENABLE_AUTOPAUSE=TRUE -e ENABLE_AUTOPAUSE=TRUE
``` ```
There are 4 more environment variables that define the behaviour: The following environment variables define the behaviour of auto-pausing:
* `AUTOPAUSE_TIMEOUT_EST`, default `3600` (seconds) * `AUTOPAUSE_TIMEOUT_EST`, default `3600` (seconds)
describes the time between the last client disconnect and the pausing of the process (read as timeout established) describes the time between the last client disconnect and the pausing of the process (read as timeout established)
* `AUTOPAUSE_TIMEOUT_INIT`, default `600` (seconds) * `AUTOPAUSE_TIMEOUT_INIT`, default `600` (seconds)
@@ -215,6 +241,8 @@ describes the time between server start and the pausing of the process, when no
describes the time between knocking of the port (e.g. by the main menu ping) and the pausing of the process, when no client connects inbetween (read as timeout knocked) describes the time between knocking of the port (e.g. by the main menu ping) and the pausing of the process, when no client connects inbetween (read as timeout knocked)
* `AUTOPAUSE_PERIOD`, default `10` (seconds) * `AUTOPAUSE_PERIOD`, default `10` (seconds)
describes period of the daemonized state machine, that handles the pausing of the process (resuming is done independently) describes period of the daemonized state machine, that handles the pausing of the process (resuming is done independently)
* `AUTOPAUSE_KNOCK_INTERFACE`, default `eth0`
<br>Describes the interface passed to the `knockd` daemon. If the default interface does not work, run the `ifconfig` command inside the container and derive the interface receiving the incoming connection from its output. The passed interface must exist inside the container. Using the loopback interface (`lo`) does likely not yield the desired results.
## Deployment Templates and Examples ## Deployment Templates and Examples
@@ -233,12 +261,13 @@ If you're looking for a simple way to deploy this to the Amazon Web Services Clo
## Running a Forge Server ## Running a Forge Server
Enable Forge server mode by adding a `-e TYPE=FORGE` to your command-line. Enable [Forge server](http://www.minecraftforge.net/wiki/) mode by adding a `-e TYPE=FORGE` to your command-line.
By default the container will run the `RECOMMENDED` version of [Forge server](http://www.minecraftforge.net/wiki/)
but you can also choose to run a specific version with `-e FORGEVERSION=10.13.4.1448`. The overall version is specified by `VERSION`, [as described in the section above](#versions) and will run the recommended Forge version by default. You can also choose to run a specific Forge version with `FORGEVERSION`, such as `-e FORGEVERSION=14.23.5.2854`.
$ docker run -d -v /path/on/host:/data \ $ docker run -d -v /path/on/host:/data \
-e TYPE=FORGE -e FORGEVERSION=10.13.4.1448 \ -e TYPE=FORGE \
-e VERSION=1.12.2 -e FORGEVERSION=14.23.5.2854 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server -p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
To use a pre-downloaded Forge installer, place it in the attached `/data` directory and To use a pre-downloaded Forge installer, place it in the attached `/data` directory and
@@ -301,13 +330,17 @@ or downloading a world with the `WORLD` option.
There are two additional volumes that can be mounted; `/mods` and `/config`. 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 Any files in either of these filesystems will be copied over to the main
`/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`. `/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`. If you are running a `BUKKIT` distribution this will affect all files inside the `plugins/` directory. You can fine tune the removal process by specifing the `REMOVE_OLD_MODS_INCLUDE` and `REMOVE_OLD_MODS_EXCLUDE` variables. By default everything will be removed. You can also specify the `REMOVE_OLD_MODS_DEPTH` (default 16) variable to only delete files up to a certain level.
> For example: `-e REMOVE_OLD_MODS=TRUE -e REMOVE_OLD_MODS_INCLUDE="*.jar" -e REMOVE_OLD_MODS_DEPTH=1` will remove all old jar files that are directly inside the `plugins/` or `mods/` directory.
This works well if you want to have a common set of modules in a separate 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 location, but still have multiple worlds with different server requirements
in either persistent volumes or a downloadable archive. in either persistent volumes or a downloadable archive.
You can specify the destination of the configs that are located inside the `/config` mount by setting the `COPY_CONFIG_DEST` variable. The configs are copied recursivly to the `/data/config` directory by default. If a file was updated directly inside the `/data/*` directoy and is newer than the file in the `/config/*` mount it will not be overriden.
> For example: `-v ./config:/config -e COPY_CONFIG_DEST=/data` will allow you to copy over your `bukkit.yml` and so on directly into the server directory.
### Replacing variables inside configs ### Replacing variables inside configs
@@ -482,7 +515,7 @@ A [Catserver](http://catserver.moe/) type server can be used with
## Running a server with a Feed the Beast modpack ## Running a server with a Feed the Beast modpack
> **NOTE** requires `itzg/minecraft-server:multiarch` image > **NOTE** requires one of the Debian based images listed in [the Java versions section](#running-minecraft-server-on-different-java-version).
[Feed the Beast application](https://www.feed-the-beast.com/) modpacks are supported by using `-e TYPE=FTBA` (**note** the "A" at the end of the type). This server type will automatically take care of downloading and installing the modpack and appropriate version of Forge, so the `VERSION` does not need to be specified. [Feed the Beast application](https://www.feed-the-beast.com/) modpacks are supported by using `-e TYPE=FTBA` (**note** the "A" at the end of the type). This server type will automatically take care of downloading and installing the modpack and appropriate version of Forge, so the `VERSION` does not need to be specified.
@@ -531,6 +564,12 @@ The following example uses `/modpacks` as the container path as the pre-download
-e CF_SERVER_MOD=/modpacks/SkyFactory_4_Server_4.1.0.zip \ -e CF_SERVER_MOD=/modpacks/SkyFactory_4_Server_4.1.0.zip \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server -p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
#### Modpack data directory
By default, CurseForge modpacks are expanded into the sub-directory `/data/FeedTheBeast` and executed from there. (The default location was chosen for legacy reasons, when Curse and FTB were maintained together.)
The directory can be changed by setting `CF_BASE_DIR`, such as `-e CF_BASE_DIR=/data`.
#### Buggy start scripts #### Buggy start scripts
Some modpacks have buggy or overly complex start scripts. You can avoid using the bundled start script and use this image's standard server-starting logic by adding `-e USE_MODPACK_START_SCRIPT=false`. Some modpacks have buggy or overly complex start scripts. You can avoid using the bundled start script and use this image's standard server-starting logic by adding `-e USE_MODPACK_START_SCRIPT=false`.
@@ -737,12 +776,18 @@ To whitelist players for your Minecraft server, pass the Minecraft usernames sep
If the `WHITELIST` environment variable is not used, any user can join your Minecraft server if it's publicly accessible. If the `WHITELIST` environment variable is not used, any user can join your Minecraft server if it's publicly accessible.
> NOTE: When `WHITELIST` is used the server property `white-list` will automatically get set to `true`.
> By default, the players in `WHITELIST` are **added** to the final `whitelist.json` file by the Minecraft server. If you set `OVERRIDE_WHITELIST` to "true" then the `whitelist.json` file will be recreated on each server startup.
### Op/Administrator Players ### Op/Administrator Players
To add more "op" (aka adminstrator) users to your Minecraft server, pass the Minecraft usernames separated by commas via the `OPS` environment variable, such as To add more "op" (aka adminstrator) users to your Minecraft server, pass the Minecraft usernames separated by commas via the `OPS` environment variable, such as
docker run -d -e OPS=user1,user2 ... docker run -d -e OPS=user1,user2 ...
> By default, the players in `OPS` are **added** to the final `ops.json` file by the Minecraft server. If you set `OVERRIDE_OPS` to "true" then the `ops.json` file will be recreated on each server startup.
### Server icon ### Server icon
A server icon can be configured using the `ICON` variable. The image will be automatically A server icon can be configured using the `ICON` variable. The image will be automatically
@@ -750,6 +795,10 @@ downloaded, scaled, and converted from any other image format:
docker run -d -e ICON=http://..../some/image.png ... docker run -d -e ICON=http://..../some/image.png ...
The server icon which has been set doesn't get overridden by default. It can be changed and overridden by setting `OVERRIDE_ICON` to `TRUE`.
docker run -d -e ICON=http://..../some/other/image.png -e OVERRIDE_ICON=TRUE...
### Rcon ### Rcon
To use rcon use the `ENABLE_RCON` and `RCON_PASSORD` variables. To use rcon use the `ENABLE_RCON` and `RCON_PASSORD` variables.
@@ -916,7 +965,7 @@ environment variable set to `false`, such as
### Level Type and Generator Settings ### Level Type and Generator Settings
By default, a standard world is generated with hills, valleys, water, etc. A different level type can By default, a standard world is generated with hills, valleys, water, etc. A different level type can
be configured by setting `LEVEL_TYPE` to an expected type, such as be configured by setting `LEVEL_TYPE` to an expected type, for example
- DEFAULT - DEFAULT
- FLAT - FLAT
@@ -924,6 +973,8 @@ be configured by setting `LEVEL_TYPE` to an expected type, such as
- AMPLIFIED - AMPLIFIED
- CUSTOMIZED - CUSTOMIZED
- BUFFET - BUFFET
- BIOMESOP (Biomes O' Plenty for 1.12 and older)
- BIOMESOPLENTY (Biomes O' Plenty for 1.15 and above)
Descriptions are available at the [gamepedia](http://minecraft.gamepedia.com/Server.properties). Descriptions are available at the [gamepedia](http://minecraft.gamepedia.com/Server.properties).
@@ -1054,19 +1105,18 @@ is passed to `docker run`.
### Memory Limit ### Memory Limit
By default, the image declares a Java initial and maximum memory limit of 1 GB. There are several By default, the image declares an initial and maximum Java memory-heap limit of 1 GB. There are several ways to adjust the memory settings:
ways to adjust the memory settings:
- `MEMORY`, "1G" by default, can be used to adjust both initial (`Xms`) and max (`Xmx`) - `MEMORY`: "1G" by default, can be used to adjust both initial (`Xms`) and max (`Xmx`) memory heap settings of the JVM
memory settings of the JVM - `INIT_MEMORY`: independently sets the initial heap size
- `INIT_MEMORY`, independently sets the initial heap size - `MAX_MEMORY`: independently sets the max heap size
- `MAX_MEMORY`, independently sets the max heap size
The values of all three are passed directly to the JVM and support format/units as The values of all three are passed directly to the JVM and support format/units as `<size>[g|G|m|M|k|K]`. For example:
`<size>[g|G|m|M|k|K]`. For example:
-e MEMORY=2G -e MEMORY=2G
> NOTE: the settings above only set the Java **heap** limits. Memory resource requests and limits on the overall container should also account for non-heap memory usage. An extra 25% is [a general best practice](https://dzone.com/articles/best-practices-java-memory-arguments-for-container).
### JVM Options ### JVM Options
General JVM options can be passed to the Minecraft Server invocation by passing a `JVM_OPTS` General JVM options can be passed to the Minecraft Server invocation by passing a `JVM_OPTS`
@@ -1121,4 +1171,4 @@ To run this image on a RaspberryPi 3 B+, 4, or newer, use the image tag
itzg/minecraft-server:multiarch 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`

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#set -x #set -x
# Use this variable to indicate a list of branches that docker hub is watching # Use this variable to indicate a list of branches that docker hub is watching
branches_list=('openj9' 'openj9-nightly' 'adopt11' 'adopt13' 'adopt14' 'multiarch' 'multiarch-latest') branches_list=('java8' 'java8-multiarch' 'openj9' 'openj9-11' 'adopt11' 'java15' 'multiarch' 'multiarch-latest')
function TrapExit { function TrapExit {
echo "Checking out back in master" echo "Checking out back in master"

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,12 @@
version: "3"
services:
mc:
image: itzg/minecraft-server
ports:
- 25565:25565
environment:
EULA: "TRUE"
volumes:
# attach the relative directory 'data' to the container's /data path
./data:/data

View File

@@ -1,3 +1,3 @@
Please server [modpacks downloaded from CurseForge](https://www.curseforge.com/minecraft/modpacks) in this directory. Place server [modpacks downloaded from CurseForge](https://www.curseforge.com/minecraft/modpacks) in this directory.
The example [`docker-compose-curseforge.yml`](../docker-compose-curseforge.yml) references a modpack downloaded from <https://www.curseforge.com/minecraft/modpacks/skyfactory-4/files/2787018>. The example [`docker-compose-curseforge.yml`](../docker-compose-curseforge.yml) references a modpack downloaded from <https://www.curseforge.com/minecraft/modpacks/skyfactory-4/files/2787018>.

View File

@@ -2,23 +2,48 @@
. /autopause/autopause-fcns.sh . /autopause/autopause-fcns.sh
. /start-utils . ${SCRIPTS:-/}start-utils
sudo /usr/sbin/knockd -c /tmp/knockd-config.cfg -d
if [ $? -ne 0 ] ; then autopause_error_loop() {
logAutopause "Available interfaces within the docker container:"
INTERFACES=$(echo /sys/class/net/*)
INTERFACES=${INTERFACES//\/sys\/class\/net\//}
logAutopause " $INTERFACES"
logAutopause "Please set the environment variable AUTOPAUSE_KNOCK_INTERFACE to the interface that handles incoming connections."
logAutopause "If unsure which interface to choose, run the ifconfig command in the container."
logAutopause "Autopause failed to initialize. This log entry will be printed every 30 minutes."
while : while :
do do
if [[ -n $(ps -o comm | grep java) ]] ; then sleep 1800
break logAutopause "Autopause failed to initialize."
fi
sleep 0.1
done done
}
# wait for java process to be started
while :
do
if java_process_exists ; then
break
fi
sleep 0.1
done
# check for interface existence
if [[ -z "$AUTOPAUSE_KNOCK_INTERFACE" ]] ; then
logAutopause "AUTOPAUSE_KNOCK_INTERFACE variable must not be empty!"
autopause_error_loop
fi
if ! [[ -d "/sys/class/net/$AUTOPAUSE_KNOCK_INTERFACE" ]] ; then
logAutopause "Selected interface \"$AUTOPAUSE_KNOCK_INTERFACE\" does not exist!"
autopause_error_loop
fi
sudo /usr/sbin/knockd -c /tmp/knockd-config.cfg -d -i "$AUTOPAUSE_KNOCK_INTERFACE"
if [ $? -ne 0 ] ; then
logAutopause "Failed to start knockd daemon." logAutopause "Failed to start knockd daemon."
logAutopause "Possible cause: docker's host network mode." logAutopause "Probable cause: Unable to attach to interface \"$AUTOPAUSE_KNOCK_INTERFACE\"."
logAutopause "Recreate without host mode or disable autopause functionality." autopause_error_loop
logAutopause "Stopping server."
killall -SIGTERM java
exit 1
fi fi
STATE=INIT STATE=INIT

View File

@@ -8,6 +8,10 @@ java_running() {
[[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]]
} }
java_process_exists() {
[[ -n "$(ps -a -o comm | grep 'java')" ]]
}
rcon_client_exists() { rcon_client_exists() {
[[ -n "$(ps -a -o comm | grep 'rcon-cli')" ]] [[ -n "$(ps -a -o comm | grep 'rcon-cli')" ]]
} }

View File

@@ -17,5 +17,5 @@ if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] ; th
# finally pause the process # finally pause the process
logAutopauseAction "Pausing Java process" logAutopauseAction "Pausing Java process"
killall -q -STOP java pkill -STOP java
fi fi

View File

@@ -4,5 +4,5 @@
if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^T.*$ ]] ; then if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^T.*$ ]] ; then
logAutopauseAction "Knocked, resuming Java process" logAutopauseAction "Knocked, resuming Java process"
killall -q -CONT java pkill -CONT java
fi fi

View File

@@ -1,2 +1,2 @@
%minecraft ALL=(ALL) NOPASSWD:/usr/bin/killall %minecraft ALL=(ALL) NOPASSWD:/usr/bin/pkill
%minecraft ALL=(ALL) NOPASSWD:/usr/sbin/knockd %minecraft ALL=(ALL) NOPASSWD:/usr/sbin/knockd

View File

@@ -46,10 +46,15 @@ if ! [[ $AUTOPAUSE_TIMEOUT_INIT =~ ^[0-9]+$ ]] ; then
export AUTOPAUSE_TIMEOUT_INIT export AUTOPAUSE_TIMEOUT_INIT
log "Warning: AUTOPAUSE_TIMEOUT_INIT is not numeric, set to 600 (seconds)" log "Warning: AUTOPAUSE_TIMEOUT_INIT is not numeric, set to 600 (seconds)"
fi fi
if [[ "$AUTOPAUSE_KNOCK_INTERFACE" == "lo" ]] ; then
log "Warning: AUTOPAUSE_KNOCK_INTERFACE is set to the local loopback interface."
log " This is not advisable, as incoming connections are likely not picked up there."
log " Continuing with this setting."
fi
if [[ -n $MAX_TICK_TIME ]] ; then if [[ -n "$MAX_TICK_TIME" && "$MAX_TICK_TIME" != "-1" ]] ; then
log "Warning: MAX_TICK_TIME is non-default, for autopause to work properly, this check should be disabled (-1 for versions >= 1.8.1)" log "Warning: MAX_TICK_TIME is non-default, for autopause to work properly, this check should be disabled (-1 for versions >= 1.8.1)"
else elif [[ -z "$MAX_TICK_TIME" ]] ; then
if versionLessThan 1.8.1; then if versionLessThan 1.8.1; then
# 10 years # 10 years
MAX_TICK_TIME=315360000000 MAX_TICK_TIME=315360000000

View File

@@ -95,6 +95,10 @@ case "${TYPE^^}" in
;; ;;
FORGE) FORGE)
log "**********************************************************************"
log "WARNING: The image tag itzg/minecraft-server:java8 is recommended"
log " since some mods require Java 8"
log "**********************************************************************"
exec ${SCRIPTS:-/}start-deployForge "$@" exec ${SCRIPTS:-/}start-deployForge "$@"
;; ;;

View File

@@ -5,7 +5,9 @@ set -e
. ${SCRIPTS:-/}start-utils . ${SCRIPTS:-/}start-utils
isDebugging && set -x isDebugging && set -x
export FTB_BASE_DIR=/data/FeedTheBeast : ${FTB_BASE_DIR:=${CF_BASE_DIR:-/data/FeedTheBeast}}
export FTB_BASE_DIR
legacyJavaFixerUrl=https://ftb.forgecdn.net/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar legacyJavaFixerUrl=https://ftb.forgecdn.net/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar
export TYPE=FEED-THE-BEAST export TYPE=FEED-THE-BEAST

View File

@@ -17,12 +17,16 @@ if isURL ${CUSTOM_SERVER}; then
fi fi
elif [[ -f ${CUSTOM_SERVER} ]]; then elif [[ -f ${CUSTOM_SERVER} ]]; then
log "Using custom server jar at ${CUSTOM_SERVER} ..." export SERVER=${CUSTOM_SERVER}
elif [[ ${GENERIC_PACK} ]]; then
log "Using custom server jar from generic pack at ${CUSTOM_SERVER} ..."
export SERVER=${CUSTOM_SERVER} export SERVER=${CUSTOM_SERVER}
else else
log "CUSTOM_SERVER is not properly set to a URL or existing jar file" log "CUSTOM_SERVER is not properly set to a URL or existing jar file"
exit 2 exit 2
fi fi
export SKIP_LOG4J_CONFIG=true export SKIP_LOG4J_CONFIG=true

View File

@@ -4,54 +4,70 @@
set -o pipefail set -o pipefail
isDebugging && set -x isDebugging && set -x
# PaperMC API v2 docs : https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config if [[ $PAPER_DOWNLOAD_URL ]]; then
export SERVER=$(getFilenameFromUrl "${PAPER_DOWNLOAD_URL}")
build=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}" -H "accept: application/json" \ if [ -f "$SERVER" ]; then
| jq '.builds[-1]') zarg=(-z "$SERVER")
case $? in fi
0)
;; echo "Preparing custom PaperMC jar from $PAPER_DOWNLOAD_URL"
22)
versions=$(curl -fsSL "https://papermc.io/api/v2/projects/paper" -H "accept: application/json") curl -fsSL -o "$SERVER" "${zarg[@]}" "${PAPER_DOWNLOAD_URL}"
if [[ $VERSION = LATEST ]]; then else
VANILLA_VERSION=$(echo "$versions" | jq -r '.versions[-1]') # PaperMC API v2 docs : https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config
log "WARN: using ${VANILLA_VERSION} since that's the latest provided by PaperMC"
# re-execute the current script with the newly computed version build=${PAPERBUILD:=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}" -H "accept: application/json" \
exec $0 "$@" | jq '.builds[-1]')}
fi case $? in
log "ERROR: ${VANILLA_VERSION} is not published by PaperMC" 0)
log " Set VERSION to one of the following: " ;;
log " $(echo "$versions" | jq -r '.versions | join(", ")')" 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 published by PaperMC"
log " Set VERSION to one of the following: "
log " $(echo "$versions" | jq -r '.versions | join(", ")')"
exit 1
;;
*)
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 exit 1
;; fi
*)
echo "ERROR: unknown error while looking up PaperMC version=${VANILLA_VERSION}" 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 exit 1
;; fi
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" \ if [ -f "$SERVER" ]; then
| jq -r '.downloads.application.name') zarg=(-z "$SERVER")
if [ $? != 0 ]; then fi
echo "ERROR: failed to lookup PaperMC download file from version=${VANILLA_VERSION} build=${build}"
exit 1
fi
if [ -f "$SERVER" ]; then log "Removing old PaperMC versions ..."
zarg=(-z "$SERVER") paperJarSearchString=${SERVER/$build/[0-9]*}
fi find . -name "$paperJarSearchString" ! -name "$SERVER" -delete -print
log "Downloading PaperMC $VANILLA_VERSION (build $build) ..." log "Downloading PaperMC $VANILLA_VERSION (build $build) ..."
curl -fsSL -o "$SERVER" "${zarg[@]}" \ curl -fsSL -o "$SERVER" "${zarg[@]}" \
"https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}/downloads/${SERVER}" \ "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}/downloads/${SERVER}" \
-H "accept: application/java-archive" -H "accept: application/java-archive"
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "ERROR: failed to download PaperMC from version=${VANILLA_VERSION} build=${build} download=${SERVER}" echo "ERROR: failed to download PaperMC from version=${VANILLA_VERSION} build=${build} download=${SERVER}"
exit 1 exit 1
fi
fi fi
# Normalize on Spigot for downstream operations # Normalize on Spigot for downstream operations
@@ -59,4 +75,4 @@ export TYPE=SPIGOT
export SKIP_LOG4J_CONFIG=true export SKIP_LOG4J_CONFIG=true
# Continue to Final Setup # Continue to Final Setup
exec ${SCRIPTS:-/}start-finalSetupWorld $@ exec ${SCRIPTS:-/}start-finalSetupWorld "$@"

View File

@@ -24,4 +24,4 @@ case "X$MODCONFIG" in
esac esac
fi fi
exec ${SCRIPTS:-/}start-finalSetupPlugins $@ exec ${SCRIPTS:-/}start-finalSetupMounts $@

View File

@@ -1,18 +1,30 @@
#!/bin/bash #!/bin/bash
set -e set -e -o pipefail
. ${SCRIPTS:-/}start-utils . ${SCRIPTS:-/}start-utils
if isDebugging; then
set -x
fi
# CURSE_URL_BASE used in manifest downloads below # CURSE_URL_BASE used in manifest downloads below
CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects} CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects}
# Remove old mods/plugins # Remove old mods/plugins
if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then if isTrue ${REMOVE_OLD_MODS}; then
if [ "$TYPE" = "SPIGOT" ]; then remove_mods_dest="/data/mods"
rm -rf /data/plugins/* case ${TYPE} in
SPIGOT|BUKKIT|PAPER)
remove_mods_dest="/data/plugins"
;;
esac
# only try to remove existing mods dir
if [ -d "$remove_mods_dest" ]; then
log "Removing old mods in $remove_mods_dest..."
find $remove_mods_dest -mindepth 1 -maxdepth ${REMOVE_OLD_MODS_DEPTH:-16} -wholename "${REMOVE_OLD_MODS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_MODS_EXCLUDE}" -delete
else else
rm -rf /data/mods/* log "Directory $remove_mods_dest does not exist; removing nothing."
fi fi
fi fi
@@ -22,7 +34,7 @@ if [[ "$MODPACK" ]]; then
if [[ "${MODPACK}" == *.zip ]]; then if [[ "${MODPACK}" == *.zip ]]; then
downloadUrl="${MODPACK}" downloadUrl="${MODPACK}"
else else
downloadUrl=$(curl -Ls -o /dev/null -w %{url_effective} $MODPACK) downloadUrl=$(curl -Ls -o /dev/null -w %{effective_url} $MODPACK)
if ! [[ $downloadUrl == *.zip ]]; then if ! [[ $downloadUrl == *.zip ]]; then
log "ERROR Invalid URL given for MODPACK: $downloadUrl resolved from $MODPACK" log "ERROR Invalid URL given for MODPACK: $downloadUrl resolved from $MODPACK"
log " Must be HTTP or HTTPS and a ZIP file" log " Must be HTTP or HTTPS and a ZIP file"
@@ -58,39 +70,38 @@ fi
# If supplied with a URL for a plugin download it. # If supplied with a URL for a plugin download it.
if [[ "$MODS" ]]; then if [[ "$MODS" ]]; then
if [ "$TYPE" = "SPIGOT" ]; then
out_dir=/data/plugins
else
out_dir=/data/mods
fi
mkdir -p "$out_dir"
for i in ${MODS//,/ } for i in ${MODS//,/ }
do do
if isURL $i; then if isURL $i; then
if [[ $i == *.jar ]]; then log "Downloading mod/plugin $i ..."
EFFECTIVE_MOD_URL=$i if isValidFileURL jar "$i"; then
if ! curl -fsSL -o "${out_dir}/$(getFilenameFromUrl "${i}")" "${i}"; then
log "ERROR: failed to download from $i into $out_dir"
exit 2
fi
else else
EFFECTIVE_MOD_URL=$(curl -Ls -o /dev/null -w %{url_effective} $i) effective_url=$(resolveEffectiveUrl "$i")
if ! [[ $EFFECTIVE_MOD_URL == *.jar ]]; then if isValidFileURL jar "${effective_url}"; then
log "ERROR Invalid URL given in MODS: $EFFECTIVE_MOD_URL resolved from $i" out_file=$(getFilenameFromUrl "${effective_url}")
log " Must be HTTP or HTTPS and a JAR file" if ! curl -fsSL -o "${out_dir}/$out_file" "${effective_url}"; then
exit 1 log "ERROR: failed to download from $i into $out_dir"
exit 2
fi
else
log "ERROR: $effective_url resolved from $i is not a valid jar URL"
exit 2
fi fi
fi fi
log "Downloading mod/plugin via HTTP"
log " from $EFFECTIVE_MOD_URL ..."
if ! curl -sSL -o /tmp/${EFFECTIVE_MOD_URL##*/} $EFFECTIVE_MOD_URL; then
log "ERROR: failed to download from $EFFECTIVE_MOD_URL to /tmp/${EFFECTIVE_MOD_URL##*/}"
exit 2
fi
if [ "$TYPE" = "SPIGOT" ]; then
mkdir -p /data/plugins
mv /tmp/${EFFECTIVE_MOD_URL##*/} /data/plugins/${EFFECTIVE_MOD_URL##*/}
else
mkdir -p /data/mods
mv /tmp/${EFFECTIVE_MOD_URL##*/} /data/mods/${EFFECTIVE_MOD_URL##*/}
fi
rm -f /tmp/${EFFECTIVE_MOD_URL##*/}
else else
log "ERROR Invalid URL given in MODS: $i" log "ERROR Invalid URL given in MODS: $i"
exit 1 exit 2
fi fi
done done
fi fi
@@ -100,7 +111,7 @@ if [[ "$MANIFEST" ]]; then
EFFECTIVE_MANIFEST_FILE=$MANIFEST EFFECTIVE_MANIFEST_FILE=$MANIFEST
elif isURL "$MANIFEST"; then elif isURL "$MANIFEST"; then
EFFECTIVE_MANIFEST_FILE=/tmp/manifest.json EFFECTIVE_MANIFEST_FILE=/tmp/manifest.json
EFFECTIVE_MANIFEST_URL=$(curl -Ls -o /dev/null -w %{url_effective} $MANIFEST) EFFECTIVE_MANIFEST_URL=$(curl -Ls -o /dev/null -w %{effective_url} $MANIFEST)
curl -Ls -o $EFFECTIVE_MANIFEST_FILE "$EFFECTIVE_MANIFEST_URL" curl -Ls -o $EFFECTIVE_MANIFEST_FILE "$EFFECTIVE_MANIFEST_URL"
else else
log "MANIFEST='$MANIFEST' is not a valid manifest url or location" log "MANIFEST='$MANIFEST' is not a valid manifest url or location"
@@ -121,7 +132,7 @@ case "X$EFFECTIVE_MANIFEST_FILE" in
do do
if [ ! -f $MOD_DIR/${p}_${f}.jar ] if [ ! -f $MOD_DIR/${p}_${f}.jar ]
then then
redirect_url="$(curl -Ls -o /dev/null -w %{url_effective} ${CURSE_URL_BASE}/${p})" redirect_url="$(curl -Ls -o /dev/null -w %{effective_url} ${CURSE_URL_BASE}/${p})"
url="$redirect_url/download/${f}/file" url="$redirect_url/download/${f}/file"
log Downloading curseforge mod $url log Downloading curseforge mod $url
# Manifest usually doesn't have mod names. Using id should be fine, tho # Manifest usually doesn't have mod names. Using id should be fine, tho
@@ -140,17 +151,17 @@ fi
if [[ "${GENERIC_PACK}" ]]; then if [[ "${GENERIC_PACK}" ]]; then
if isURL "${GENERIC_PACK}"; then if isURL "${GENERIC_PACK}"; then
generic_pack_url=${GENERIC_PACK} log "Downloading generic pack ..."
GENERIC_PACK=/tmp/$(basename ${generic_pack_url}) curl -fsSL -o /tmp/generic_pack.zip "${GENERIC_PACK}"
log "Downloading generic pack from ${generic_pack_url} ..." GENERIC_PACK=/tmp/generic_pack.zip
curl -fsSL -o ${GENERIC_PACK} ${generic_pack_url}
fi fi
sum_file=/data/.generic_pack.sum sum_file=/data/.generic_pack.sum
if ! sha256sum -c ${sum_file} -s 2> /dev/null; then if ! sha256sum -c ${sum_file} -s 2> /dev/null; then
base_dir=/tmp/generic_pack_base base_dir=/tmp/generic_pack_base
mkdir -p ${base_dir} mkdir -p ${base_dir}
unzip -q -d ${base_dir} ${GENERIC_PACK} isDebugging && ls -l "${GENERIC_PACK}"
unzip -q -d ${base_dir} "${GENERIC_PACK}"
if [ -f /data/manifest.txt ]; then if [ -f /data/manifest.txt ]; then
log "Manifest exists from older generic pack, cleaning up ..." log "Manifest exists from older generic pack, cleaning up ..."
while read f; do while read f; do
@@ -168,7 +179,7 @@ if [[ "${GENERIC_PACK}" ]]; then
for d in $(find ${base_dir} -type d); do mkdir -p "$(sed "s#${base_dir}#/data#" <<< $d)"; done for d in $(find ${base_dir} -type d); do mkdir -p "$(sed "s#${base_dir}#/data#" <<< $d)"; done
for f in $(find ${base_dir} -type f); do cp -f "$f" "$(sed "s#${base_dir}#/data#" <<< $f)"; done for f in $(find ${base_dir} -type f); do cp -f "$f" "$(sed "s#${base_dir}#/data#" <<< $f)"; done
rm -rf ${base_dir} rm -rf ${base_dir}
sha256sum ${GENERIC_PACK} > ${sum_file} sha256sum "${GENERIC_PACK}" > ${sum_file}
fi fi
fi fi

38
start-finalSetupMounts Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
. ${SCRIPTS:-/}start-utils
: ${PLUGINS_SYNC_UPDATE:=true}
isDebugging && set -x
if [ -d /plugins ]; then
case ${TYPE} in
SPIGOT|BUKKIT|PAPER|MAGMA)
mkdir -p /data/plugins
log "Copying plugins over..."
if isTrue ${PLUGINS_SYNC_UPDATE}; then
updateArg="--update"
fi
# Copy plugins over using rsync to allow deeply nested updates of plugins
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs $updateArg /plugins /data
;;
esac
fi
# If any modules have been provided, copy them over
if [ -d /mods ]; then
log "Copying any mods over..."
mkdir -p /data/mods
rsync -a --out-format="update:%f:Last Modified %M" "${rsyncArgs[@]}" --prune-empty-dirs --update /mods /data
fi
: ${COPY_CONFIG_DEST:="/data/config"}
if [ -d /config ]; then
log "Copying any configs from /config to $COPY_CONFIG_DEST"
mkdir -p $COPY_CONFIG_DEST
rsync -a --out-format="update:%f:Last Modified %M" "${rsyncArgs[@]}" --prune-empty-dirs --update /config/ $COPY_CONFIG_DEST
fi
exec ${SCRIPTS:-/}start-finalSetupServerProperties $@

View File

@@ -1,23 +0,0 @@
#!/bin/bash
. ${SCRIPTS:-/}start-utils
: ${PLUGINS_SYNC_UPDATE:=true}
isDebugging && set -x
if [ -d /plugins ]; then
case ${TYPE} in
SPIGOT|BUKKIT|PAPER)
mkdir -p /data/plugins
log "Copying plugins over..."
if isTrue ${PLUGINS_SYNC_UPDATE}; then
updateArg="--update"
fi
# Copy plugins over using rsync to allow deeply nested updates of plugins
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs $updateArg /plugins /data
;;
esac
fi
exec ${SCRIPTS:-/}start-finalSetupServerProperties $@

View File

@@ -13,7 +13,7 @@ function setServerProp {
var=${var,,} ;; var=${var,,} ;;
esac esac
log "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}" log "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
log "Skip setting ${prop}" log "Skip setting ${prop}"
fi fi

View File

@@ -25,7 +25,12 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
mkdir -p /tmp/world-data mkdir -p /tmp/world-data
(cd /tmp/world-data && unzip -o -q "$zipSrc") (cd /tmp/world-data && unzip -o -q "$zipSrc")
baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;) if [ "$TYPE" = "SPIGOT" ]; then
baseDirs=$(find /tmp/world-data -name "level.dat" -not -path "*_nether*" -not -path "*_the_end*" -exec dirname "{}" \;)
else
baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;)
fi
count=$(echo "$baseDirs" | wc -l) count=$(echo "$baseDirs" | wc -l)
if [[ $count -gt 1 ]]; then if [[ $count -gt 1 ]]; then
baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)" baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)"
@@ -38,6 +43,11 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
exit 1 exit 1
fi fi
rsync --remove-source-files --recursive --delete "$baseDir/" "$worldDest" rsync --remove-source-files --recursive --delete "$baseDir/" "$worldDest"
if [ "$TYPE" = "SPIGOT" ]; then
log "Copying end and nether ..."
[ -d "${baseDir}_nether" ] && rsync --remove-source-files --recursive --delete "${baseDir}_nether/" "${worldDest}_nether"
[ -d "${baseDir}_the_end" ] && rsync --remove-source-files --recursive --delete "${baseDir}_the_end/" "${worldDest}_the_end"
fi
else else
log "Cloning world directory from $WORLD ..." log "Cloning world directory from $WORLD ..."
rsync --recursive --delete "${WORLD%/}"/ "$worldDest" rsync --recursive --delete "${WORLD%/}"/ "$worldDest"

View File

@@ -3,28 +3,40 @@
. ${SCRIPTS:-/}start-utils . ${SCRIPTS:-/}start-utils
if [ -n "$OPS" ]; then if [ -n "$OPS" ]; then
log "Setting/adding ops" log "Updating ops"
rm -rf /data/ops.txt.converted rm -f /data/ops.txt.converted
echo $OPS | awk -v RS=, '{print}' > /data/ops.txt echo $OPS | awk -v RS=, '{print}' > /data/ops.txt
if isTrue "${OVERRIDE_OPS}"; then
log "Recreating ops.json file at server startup"
rm -f /data/ops.json
fi
fi fi
if [ -n "$WHITELIST" ]; then if [ -n "$WHITELIST" ]; then
log "Setting whitelist" log "Updating whitelist"
rm -rf /data/white-list.txt.converted rm -f /data/white-list.txt.converted
echo $WHITELIST | awk -v RS=, '{print}' > /data/white-list.txt echo $WHITELIST | awk -v RS=, '{print}' > /data/white-list.txt
if isTrue "${OVERRIDE_WHITELIST}"; then
log "Recreating whitelist.json file at server startup"
rm -f /data/whitelist.json
fi
fi fi
if [ -n "$ICON" -a ! -e server-icon.png ]; then if [ -n "$ICON" ]; then
log "Using server icon from $ICON..." if [ ! -e server-icon.png ] || [ "${OVERRIDE_ICON}" == "TRUE" ]; then
# Not sure what it is yet...call it "img" log "Using server icon from $ICON..."
curl -sSL -o /tmp/icon.img $ICON # Not sure what it is yet...call it "img"
specs=$(identify /tmp/icon.img | awk '{print $2,$3}') curl -sSL -o /tmp/icon.img $ICON
if [ "$specs" = "PNG 64x64" ]; then specs=$(identify /tmp/icon.img | awk '{print $2,$3}')
mv /tmp/icon.img /data/server-icon.png if [ "$specs" = "PNG 64x64" ]; then
else mv /tmp/icon.img /data/server-icon.png
log "Converting image to 64x64 PNG..." else
convert /tmp/icon.img -resize 64x64! /data/server-icon.png log "Converting image to 64x64 PNG..."
fi convert /tmp/icon.img -resize 64x64! /data/server-icon.png
fi
fi
fi fi
if ! isTrue ${SKIP_LOG4J_CONFIG}; then if ! isTrue ${SKIP_LOG4J_CONFIG}; then
@@ -49,26 +61,6 @@ for j in $JSON_FILES; do
fi fi
done done
# If any modules have been provided, copy them over
if [ -d /mods ]; then
log "Copying any mods over..."
mkdir -p /data/mods
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
for c in /config/*
do
if [ -f "$c" ]; then
log Copying configuration $(basename "$c")
cp -rf "$c" /data/config
fi
done
EXTRA_ARGS="" EXTRA_ARGS=""
# Optional disable console # Optional disable console
if versionLessThan 1.14 && [[ ${CONSOLE,,} = false ]]; then if versionLessThan 1.14 && [[ ${CONSOLE,,} = false ]]; then
@@ -166,11 +158,11 @@ JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
function copyFilesForCurseForge() { function copyFilesForCurseForge() {
# copy player modification files unconditionally since their # copy player modification files unconditionally since their
# processing into json is additive anyway # processing into json is additive anyway
[ -f /data/ops.txt ] && cp -f /data/ops.txt ${FTB_DIR}/ [ -f /data/ops.txt ] && cp -f /data/ops.txt "${FTB_DIR}/"
[ -f /data/white-list.txt ] && cp -f /data/white-list.txt ${FTB_DIR}/ [ -f /data/white-list.txt ] && cp -f /data/white-list.txt "${FTB_DIR}/"
if [ ! -e "${FTB_DIR}/server-icon.png" -a -e /data/server-icon.png ]; then if [ ! -e "${FTB_DIR}/server-icon.png" -a -e /data/server-icon.png ]; then
cp -f /data/server-icon.png ${FTB_DIR}/ cp -f /data/server-icon.png "${FTB_DIR}/"
fi fi
cp -f /data/eula.txt "${FTB_DIR}/" cp -f /data/eula.txt "${FTB_DIR}/"

View File

@@ -1,8 +1,14 @@
#!/bin/bash #!/bin/bash
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } function join_by() {
local d=$1
shift
echo -n "$1"
shift
printf "%s" "${@/#/$d}"
}
function isURL { function isURL() {
local value=$1 local value=$1
if [[ ${value:0:8} == "https://" || ${value:0:7} == "http://" ]]; then if [[ ${value:0:8} == "https://" || ${value:0:7} == "http://" ]]; then
@@ -12,90 +18,114 @@ function isURL {
fi fi
} }
function isTrue { function isValidFileURL() {
suffix=${1:?Missing required suffix arg}
url=${2:?Missing required url arg}
[[ "$url" == http*://*.${suffix} || "$url" == http*://*.${suffix}\?* ]]
}
function resolveEffectiveUrl() {
url="${1:?Missing required url argument}"
if ! curl -Ls -o /dev/null -w %{url_effective} "$url"; then
log "ERROR failed to resolve effective URL from $url"
exit 2
fi
}
function getFilenameFromUrl() {
url="${1:?Missing required url argument}"
strippedOfQuery="${url%\?*}"
basename "$strippedOfQuery"
}
function isTrue() {
local value=${1,,} local value=${1,,}
result= result=
case ${value} in case ${value} in
true|on) true | on)
result=0 result=0
;; ;;
*) *)
result=1 result=1
;; ;;
esac esac
return ${result} return ${result}
} }
function isDebugging { function isDebugging() {
if [[ -v DEBUG ]] && [[ ${DEBUG^^} = TRUE ]]; then if [[ -v DEBUG ]] && [[ ${DEBUG^^} == TRUE ]]; then
return 0 return 0
else else
return 1 return 1
fi fi
} }
function debug { function debug() {
if isDebugging; then if isDebugging; then
log "DEBUG: $*" log "DEBUG: $*"
fi fi
} }
function logn { function logn() {
echo -n "[init] $*" echo -n "[init] $*"
} }
function log { function log() {
echo "[init] $*" echo "[init] $*"
} }
function logAutopause { function logAutopause() {
echo "[Autopause loop] $*" echo "[Autopause loop] $*"
} }
function logAutopauseAction { function logAutopauseAction() {
echo "[$(date -Iseconds)] [Autopause] $*" echo "[$(date -Iseconds)] [Autopause] $*"
} }
function normalizeMemSize { function normalizeMemSize() {
local scale=1 local scale=1
case ${1,,} in case ${1,,} in
*k) *k)
scale=1024;; scale=1024
*m) ;;
scale=1048576;; *m)
*g) scale=1048576
scale=1073741824;; ;;
*g)
scale=1073741824
;;
esac esac
val=${1:0: -1} val=${1:0:-1}
echo $(( val * scale )) echo $((val * scale))
} }
function versionLessThan { function versionLessThan() {
local activeParts local activeParts
IFS=. read -ra activeParts <<< "${VANILLA_VERSION}" IFS=. read -ra activeParts <<<"${VANILLA_VERSION}"
local givenParts local givenParts
IFS=. read -ra givenParts <<< "$1" IFS=. read -ra givenParts <<<"$1"
if (( ${#activeParts[@]} < 2 )); then if ((${#activeParts[@]} < 2)); then
return 1 return 1
fi fi
if (( ${#activeParts[@]} == 2 )); then if ((${#activeParts[@]} == 2)); then
if (( activeParts[0] < givenParts[0] )) || \ if ((activeParts[0] < givenParts[0])) ||
(( activeParts[0] == givenParts[0] && activeParts[1] < givenParts[1] )); then ((activeParts[0] == givenParts[0] && activeParts[1] < givenParts[1])); then
return 0 return 0
else else
return 1 return 1
fi fi
else else
if (( activeParts[0] < givenParts[0] )) || \ if ((activeParts[0] < givenParts[0])) ||
(( activeParts[0] == givenParts[0] && activeParts[1] < givenParts[1] )) || \ ((activeParts[0] == givenParts[0] && activeParts[1] < givenParts[1])) ||
(( activeParts[0] == givenParts[0] && activeParts[1] == givenParts[1] && activeParts[2] < givenParts[2] )); then ((activeParts[0] == givenParts[0] && activeParts[1] == givenParts[1] && activeParts[2] < givenParts[2])); then
return 0 return 0
else else
return 1 return 1
@@ -115,10 +145,11 @@ requireVar() {
} }
function writeEula() { function writeEula() {
if ! echo "# Generated via Docker on $(date) if ! echo "# Generated via Docker
# $(date)
eula=${EULA,,} eula=${EULA,,}
" > /data/eula.txt; then " >/data/eula.txt; then
log "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}" log "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
exit 2 exit 2
fi fi
} }