mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-09-06 05:57:57 +00:00
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbb2a0d8d7 | ||
|
|
ee562599f4 | ||
|
|
1ffcb5c221 | ||
|
|
8cdf4d0072 | ||
|
|
1545236cc6 | ||
|
|
2ebcc0fe00 | ||
|
|
e5f818bdf1 | ||
|
|
df497ce3d8 | ||
|
|
f7ff2779d9 | ||
|
|
c9e14864f5 | ||
|
|
ec539a5dd2 | ||
|
|
7427bc9043 | ||
|
|
8ab104f6b7 | ||
|
|
f15cbb4ca1 | ||
|
|
fa235e97c5 |
@@ -18,9 +18,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
# NOTE: the "latest" variant is identified in the Docker meta step's 'latest' config
|
# NOTE: the "latest" variant is identified in the Docker meta step's 'latest' config
|
||||||
variant:
|
variant:
|
||||||
|
- java21-graalvm
|
||||||
- java20
|
- java20
|
||||||
- java20-alpine
|
- java20-alpine
|
||||||
- java20-graalvm
|
|
||||||
- java17
|
- java17
|
||||||
- java17-graalvm
|
- java17-graalvm
|
||||||
- java17-jdk
|
- java17-jdk
|
||||||
@@ -35,6 +35,11 @@ jobs:
|
|||||||
- java11-openj9
|
- java11-openj9
|
||||||
- java11-jdk
|
- java11-jdk
|
||||||
include:
|
include:
|
||||||
|
# JAVA 21:
|
||||||
|
- variant: java21-graalvm
|
||||||
|
baseImage: container-registry.oracle.com/graalvm/jdk:21-ol8
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
mcVersion: 1.20.2
|
||||||
# JAVA 20:
|
# JAVA 20:
|
||||||
- variant: java20
|
- variant: java20
|
||||||
baseImage: eclipse-temurin:20-jre
|
baseImage: eclipse-temurin:20-jre
|
||||||
@@ -44,10 +49,6 @@ jobs:
|
|||||||
baseImage: eclipse-temurin:20-jre-alpine
|
baseImage: eclipse-temurin:20-jre-alpine
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
mcVersion: 1.19.3
|
mcVersion: 1.19.3
|
||||||
- variant: java20-graalvm
|
|
||||||
baseImage: container-registry.oracle.com/graalvm/jdk:20-ol8
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
mcVersion: 1.19.3
|
|
||||||
# JAVA 17:
|
# JAVA 17:
|
||||||
- variant: java17
|
- variant: java17
|
||||||
# jammy doesn't work until minecraft updates to https://github.com/netty/netty/issues/12343
|
# jammy doesn't work until minecraft updates to https://github.com/netty/netty/issues/12343
|
||||||
|
|||||||
+18
-13
@@ -1,6 +1,19 @@
|
|||||||
# syntax = docker/dockerfile:1.3
|
# syntax = docker/dockerfile:1.5-labs
|
||||||
|
|
||||||
ARG BASE_IMAGE=eclipse-temurin:17-jre-focal
|
ARG BASE_IMAGE=eclipse-temurin:17-jre-focal
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
FROM container-registry.oracle.com/graalvm/native-image:21-ol8 AS helper-native-builder
|
||||||
|
|
||||||
|
# findutils provides xargs, needed by gradle wrapper
|
||||||
|
RUN microdnf install findutils
|
||||||
|
|
||||||
|
ADD https://github.com/itzg/mc-image-helper.git#feat/graalvm /helper
|
||||||
|
|
||||||
|
WORKDIR /helper
|
||||||
|
|
||||||
|
RUN ./gradlew nativeCompile
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
# hook into docker BuildKit --platform support
|
# hook into docker BuildKit --platform support
|
||||||
@@ -35,20 +48,14 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
|||||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||||
|
|
||||||
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||||
--var version=0.12.2 --var app=mc-monitor --file {{.app}} \
|
--var version=0.12.3 --var app=mc-monitor --file {{.app}} \
|
||||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||||
|
|
||||||
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||||
--var version=1.9.0 --var app=mc-server-runner --file {{.app}} \
|
--var version=1.9.0 --var app=mc-server-runner --file {{.app}} \
|
||||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||||
|
|
||||||
ARG MC_HELPER_VERSION=1.35.3
|
COPY --from=helper-native-builder /helper/build/native/nativeCompile/mc-image-helper /usr/bin/
|
||||||
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
|
|
||||||
# used for cache busting local copy of mc-image-helper
|
|
||||||
ARG MC_HELPER_REV=1
|
|
||||||
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
|
|
||||||
| tar -C /usr/share -zxf - \
|
|
||||||
&& ln -s /usr/share/mc-image-helper-${MC_HELPER_VERSION}/bin/mc-image-helper /usr/bin
|
|
||||||
|
|
||||||
VOLUME ["/data"]
|
VOLUME ["/data"]
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
@@ -61,9 +68,7 @@ ENV TYPE=VANILLA VERSION=LATEST EULA="" UID=1000 GID=1000
|
|||||||
COPY --chmod=755 scripts/start* /
|
COPY --chmod=755 scripts/start* /
|
||||||
COPY --chmod=755 bin/ /usr/local/bin/
|
COPY --chmod=755 bin/ /usr/local/bin/
|
||||||
COPY --chmod=755 bin/mc-health /health.sh
|
COPY --chmod=755 bin/mc-health /health.sh
|
||||||
COPY --chmod=644 files/log4j2.xml /image/log4j2.xml
|
COPY --chmod=644 files/* /image/
|
||||||
# By default this file gets retrieved from repo, but bundle in image as potential fallback
|
|
||||||
COPY --chmod=644 files/cf-exclude-include.json /image/cf-exclude-include.json
|
|
||||||
COPY --chmod=755 files/auto /auto
|
COPY --chmod=755 files/auto /auto
|
||||||
|
|
||||||
RUN curl -fsSL -o /image/Log4jPatcher.jar https://github.com/CreeperHost/Log4jPatcher/releases/download/v1.0.1/Log4jPatcher-1.0.1.jar
|
RUN curl -fsSL -o /image/Log4jPatcher.jar https://github.com/CreeperHost/Log4jPatcher/releases/download/v1.0.1/Log4jPatcher-1.0.1.jar
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ renders
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
To produce a multi-line MOTD, you will need to double escape the newline such as
|
To produce a multi-line MOTD, embed a newline character as `\n` in the string, such as
|
||||||
|
|
||||||
-e MOTD="Line one\\nLine two"
|
-e MOTD="Line one\nLine two"
|
||||||
|
|
||||||
### Difficulty
|
### Difficulty
|
||||||
|
|
||||||
@@ -353,10 +353,28 @@ If you must, the server port can be set like:
|
|||||||
|
|
||||||
**however**, be sure to change your port mapping accordingly and be prepared for some features to break.
|
**however**, be sure to change your port mapping accordingly and be prepared for some features to break.
|
||||||
|
|
||||||
|
### Custom server properties
|
||||||
|
|
||||||
|
Some mods/plugins utilize custom `server.properties` entries which can be declared via the `CUSTOM_SERVER_PROPERTIES` environment variable. The contents must be newline delimited `name=value` pairs.
|
||||||
|
|
||||||
|
Within a compose file, newline delimited entries can be declared as shown here:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
CUSTOM_SERVER_PROPERTIES: |
|
||||||
|
custom1=value1
|
||||||
|
defaultworldgenerator-port=f8c04631-f744-11ec-b260-f02f74b094e0
|
||||||
|
```
|
||||||
|
|
||||||
|
When using `docker run` from a bash shell, the entries must be quoted with the `$'` syntax, such as
|
||||||
|
|
||||||
|
```
|
||||||
|
-e CUSTOM_SERVER_PROPERTIES=$'k1=v1\nk2=v2'
|
||||||
|
```
|
||||||
|
|
||||||
### Other server property mappings
|
### Other server property mappings
|
||||||
|
|
||||||
| Environment Variable | Server Property |
|
| Environment Variable | Server Property |
|
||||||
| --------------------------------- | --------------------------------- |
|
|-----------------------------------|-----------------------------------|
|
||||||
| BROADCAST_CONSOLE_TO_OPS | broadcast-console-to-ops |
|
| BROADCAST_CONSOLE_TO_OPS | broadcast-console-to-ops |
|
||||||
| BROADCAST_RCON_TO_OPS | broadcast-rcon-to-ops |
|
| BROADCAST_RCON_TO_OPS | broadcast-rcon-to-ops |
|
||||||
| ENABLE_STATUS | enable-status |
|
| ENABLE_STATUS | enable-status |
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
mkdocs == 1.5.3
|
mkdocs == 1.5.3
|
||||||
mkdocs-material-extensions == 1.2
|
mkdocs-material-extensions == 1.2
|
||||||
mkdocs-material == 9.4.3
|
mkdocs-material == 9.4.6
|
||||||
mkdocs-autorefs == 0.5.0
|
mkdocs-autorefs == 0.5.0
|
||||||
mkdocstrings == 0.23.0
|
mkdocstrings == 0.23.0
|
||||||
mkdocs-literate-nav == 0.6.1
|
mkdocs-literate-nav == 0.6.1
|
||||||
mdx-gh-links == 0.3.1
|
mdx-gh-links == 0.3.1
|
||||||
mkdocs-click == 0.8.1
|
mkdocs-click == 0.8.1
|
||||||
mkdocs-static-i18n == 1.0.6
|
mkdocs-static-i18n == 1.1.1
|
||||||
@@ -35,3 +35,23 @@ In both of the cases above, there is no need for the `VERSION` or `FORGE_VERSION
|
|||||||
!!! note
|
!!! note
|
||||||
|
|
||||||
If an error occurred while installing Forge, it might be possible to resolve by temporarily setting `FORGE_FORCE_REINSTALL` to "true". Be sure to remove that variable after successfully starting the server.
|
If an error occurred while installing Forge, it might be possible to resolve by temporarily setting `FORGE_FORCE_REINSTALL` to "true". Be sure to remove that variable after successfully starting the server.
|
||||||
|
|
||||||
|
## Alternatives
|
||||||
|
|
||||||
|
### NeoForge
|
||||||
|
|
||||||
|
Support for [NeoForge](https://neoforged.net/) is also provided. A NeoForge server can be automatically managed by setting `TYPE` to "NEOFORGE". `VERSION` specifies the Minecraft version and `NEOFORGE_VERSION` can be set to select a specific sub-version. By default, the latest NeoForge version available for the requested Minecraft version will be used.
|
||||||
|
|
||||||
|
!!! example
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -e TYPE=NEOFORGE -e VERSION=1.20.1 -e NEOFORGE_VERSION=47.1.79 ...
|
||||||
|
```
|
||||||
|
|
||||||
|
or in a compose file
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
TYPE: NEOFORGE
|
||||||
|
VERSION: "1.20.1"
|
||||||
|
NEOFORGE_VERSION: "47.1.79"
|
||||||
|
```
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ When using the image `itzg/minecraft-server` without a tag, the `latest` image t
|
|||||||
| java17-alpine | 17 | Alpine | Hotspot | amd64 |
|
| java17-alpine | 17 | Alpine | Hotspot | amd64 |
|
||||||
| java20-alpine | 20 | Alpine | Hotspot | amd64 |
|
| java20-alpine | 20 | Alpine | Hotspot | amd64 |
|
||||||
| java20 | 20 | Ubuntu | Hotspot | amd64,arm64 |
|
| java20 | 20 | Ubuntu | Hotspot | amd64,arm64 |
|
||||||
| java20-graalvm | 20 | Oracle | Oracle GraalVM | amd64,arm64 |
|
| java21-graalvm | 21 | Oracle | Oracle GraalVM | amd64,arm64 |
|
||||||
|
|
||||||
For example, to use Java version 8 on any supported architecture:
|
For example, to use Java version 8 on any supported architecture:
|
||||||
|
|
||||||
@@ -55,3 +55,4 @@ The following image tags have been deprecated and are no longer receiving update
|
|||||||
- multiarch-latest
|
- multiarch-latest
|
||||||
- java16/java16-openj9
|
- java16/java16-openj9
|
||||||
- java17-graalvm-ce
|
- java17-graalvm-ce
|
||||||
|
- java20-graalvm
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"motd": {"env": "MOTD"},
|
||||||
|
"gamemode": {"env": "MODE"},
|
||||||
|
"difficulty": {"env": "DIFFICULTY"},
|
||||||
|
"white-list": {"env": "WHITELIST_PROP"},
|
||||||
|
"enforce-whitelist": {"env": "ENFORCE_WHITELIST"},
|
||||||
|
"level-type": {"env": "LEVEL_TYPE"},
|
||||||
|
"server-name": {"env": "SERVER_NAME"},
|
||||||
|
"server-ip": {"env": "SERVER_IP"},
|
||||||
|
"server-port": {"env": "SERVER_PORT"},
|
||||||
|
"allow-nether": {"env": "ALLOW_NETHER"},
|
||||||
|
"announce-player-achievements": {"env": "ANNOUNCE_PLAYER_ACHIEVEMENTS"},
|
||||||
|
"enable-command-block": {"env": "ENABLE_COMMAND_BLOCK"},
|
||||||
|
"spawn-animals": {"env": "SPAWN_ANIMALS"},
|
||||||
|
"spawn-monsters": {"env": "SPAWN_MONSTERS"},
|
||||||
|
"spawn-npcs": {"env": "SPAWN_NPCS"},
|
||||||
|
"spawn-protection": {"env": "SPAWN_PROTECTION"},
|
||||||
|
"generate-structures": {"env": "GENERATE_STRUCTURES"},
|
||||||
|
"view-distance": {"env": "VIEW_DISTANCE"},
|
||||||
|
"hardcore": {"env": "HARDCORE"},
|
||||||
|
"snooper-enabled": {"env": "SNOOPER_ENABLED"},
|
||||||
|
"max-build-height": {"env": "MAX_BUILD_HEIGHT"},
|
||||||
|
"force-gamemode": {"env": "FORCE_GAMEMODE"},
|
||||||
|
"max-tick-time": {"env": "MAX_TICK_TIME"},
|
||||||
|
"enable-query": {"env": "ENABLE_QUERY"},
|
||||||
|
"query.port": {"env": "QUERY_PORT"},
|
||||||
|
"enable-rcon": {"env": "ENABLE_RCON"},
|
||||||
|
"rcon.password": {"env": "RCON_PASSWORD"},
|
||||||
|
"rcon.port": {"env": "RCON_PORT"},
|
||||||
|
"max-players": {"env": "MAX_PLAYERS"},
|
||||||
|
"max-world-size": {"env": "MAX_WORLD_SIZE"},
|
||||||
|
"level-name": {"env": "LEVEL"},
|
||||||
|
"level-seed": {"env": "SEED"},
|
||||||
|
"pvp": {"env": "PVP"},
|
||||||
|
"generator-settings": {"env": "GENERATOR_SETTINGS"},
|
||||||
|
"online-mode": {"env": "ONLINE_MODE"},
|
||||||
|
"allow-flight": {"env": "ALLOW_FLIGHT"},
|
||||||
|
"resource-pack": {"env": "RESOURCE_PACK"},
|
||||||
|
"resource-pack-sha1": {"env": "RESOURCE_PACK_SHA1"},
|
||||||
|
"require-resource-pack": {"env": "RESOURCE_PACK_ENFORCE"},
|
||||||
|
"player-idle-timeout": {"env": "PLAYER_IDLE_TIMEOUT"},
|
||||||
|
"broadcast-console-to-ops": {"env": "BROADCAST_CONSOLE_TO_OPS"},
|
||||||
|
"broadcast-rcon-to-ops": {"env": "BROADCAST_RCON_TO_OPS"},
|
||||||
|
"enable-jmx-monitoring": {"env": "ENABLE_JMX"},
|
||||||
|
"sync-chunk-writes": {"env": "SYNC_CHUNK_WRITES"},
|
||||||
|
"enable-status": {"env": "ENABLE_STATUS"},
|
||||||
|
"entity-broadcast-range-percentage": {"env": "ENTITY_BROADCAST_RANGE_PERCENTAGE"},
|
||||||
|
"function-permission-level": {"env": "FUNCTION_PERMISSION_LEVEL"},
|
||||||
|
"network-compression-threshold": {"env": "NETWORK_COMPRESSION_THRESHOLD"},
|
||||||
|
"op-permission-level": {"env": "OP_PERMISSION_LEVEL"},
|
||||||
|
"prevent-proxy-connections": {"env": "PREVENT_PROXY_CONNECTIONS"},
|
||||||
|
"use-native-transport": {"env": "USE_NATIVE_TRANSPORT"},
|
||||||
|
"simulation-distance": {"env": "SIMULATION_DISTANCE"},
|
||||||
|
"previews-chat": {"env": "PREVIEWS_CHAT"},
|
||||||
|
"enforce-secure-profile": {"env": "ENFORCE_SECURE_PROFILE"},
|
||||||
|
"initial-enabled-packs": {"env": "INITIAL_ENABLED_PACKS"},
|
||||||
|
"initial-disabled-packs": {"env": "INITIAL_DISABLED_PACKS"}
|
||||||
|
}
|
||||||
@@ -185,6 +185,10 @@ case "${TYPE^^}" in
|
|||||||
exec "${SCRIPTS:-/}start-deployForge" "$@"
|
exec "${SCRIPTS:-/}start-deployForge" "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
NEOFORGE|NEOFORGED)
|
||||||
|
exec "${SCRIPTS:-/}start-deployNeoForge" "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
FABRIC)
|
FABRIC)
|
||||||
exec "${SCRIPTS:-/}start-deployFabric" "$@"
|
exec "${SCRIPTS:-/}start-deployFabric" "$@"
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
: "${NEOFORGE_VERSION:=latest}"
|
||||||
|
: "${NEOFORGE_FORCE_REINSTALL:=false}}"
|
||||||
|
|
||||||
|
# shellcheck source=start-utils
|
||||||
|
. "${SCRIPTS:-$(dirname "$0")}/start-utils"
|
||||||
|
isDebugging && set -x
|
||||||
|
|
||||||
|
resultsFile=/data/.run-neoforge.env
|
||||||
|
|
||||||
|
if ! mc-image-helper install-neoforge \
|
||||||
|
--output-directory=/data \
|
||||||
|
--results-file=${resultsFile} \
|
||||||
|
--minecraft-version="${VERSION}" \
|
||||||
|
--neoforge-version="${NEOFORGE_VERSION}" \
|
||||||
|
--force-reinstall="${NEOFORGE_FORCE_REINSTALL}"; then
|
||||||
|
log "ERROR failed to install Forge"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# grab SERVER and export it
|
||||||
|
set -a
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source ${resultsFile}
|
||||||
|
set +a
|
||||||
|
|
||||||
|
export FAMILY=FORGE
|
||||||
|
|
||||||
|
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|
||||||
@@ -239,10 +239,7 @@ function handleModrinthProjects() {
|
|||||||
if [[ $MODRINTH_PROJECTS ]] && isFamily HYBRID FORGE FABRIC SPIGOT; then
|
if [[ $MODRINTH_PROJECTS ]] && isFamily HYBRID FORGE FABRIC SPIGOT; then
|
||||||
if isFamily HYBRID FORGE; then
|
if isFamily HYBRID FORGE; then
|
||||||
loader=forge
|
loader=forge
|
||||||
elif isFamily FABRIC; then
|
|
||||||
loader=fabric
|
|
||||||
else
|
else
|
||||||
# we're left with Bukkit/Spigot down-lines where plugins seem to be
|
|
||||||
loader="${TYPE,,}"
|
loader="${TYPE,,}"
|
||||||
fi
|
fi
|
||||||
mc-image-helper modrinth \
|
mc-image-helper modrinth \
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ IFS=$'\n\t'
|
|||||||
: "${EXISTING_OPS_FILE:=SKIP}"
|
: "${EXISTING_OPS_FILE:=SKIP}"
|
||||||
: "${EXISTING_WHITELIST_FILE:=SKIP}"
|
: "${EXISTING_WHITELIST_FILE:=SKIP}"
|
||||||
|
|
||||||
|
# shellcheck source=start-utils
|
||||||
|
. "${SCRIPTS:-/}start-utils"
|
||||||
|
isDebugging && set -x
|
||||||
|
|
||||||
if [[ -v APPEND_OPS ]] && isTrue "${APPEND_OPS}"; then
|
if [[ -v APPEND_OPS ]] && isTrue "${APPEND_OPS}"; then
|
||||||
EXISTING_OPS_FILE=MERGE
|
EXISTING_OPS_FILE=MERGE
|
||||||
elif [[ -v OVERRIDE_OPS ]] && isTrue "${OVERRIDE_OPS}"; then
|
elif [[ -v OVERRIDE_OPS ]] && isTrue "${OVERRIDE_OPS}"; then
|
||||||
@@ -17,10 +21,6 @@ elif [[ -v OVERRIDE_WHITELIST ]] && isTrue "${OVERRIDE_WHITELIST}"; then
|
|||||||
EXISTING_WHITELIST_FILE=SYNCHRONIZE
|
EXISTING_WHITELIST_FILE=SYNCHRONIZE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck source=start-utils
|
|
||||||
. "${SCRIPTS:-/}start-utils"
|
|
||||||
isDebugging && set -x
|
|
||||||
|
|
||||||
sharedArgs=(--version="$VERSION")
|
sharedArgs=(--version="$VERSION")
|
||||||
if isFalse "${ONLINE_MODE:-true}"; then
|
if isFalse "${ONLINE_MODE:-true}"; then
|
||||||
sharedArgs+=( --offline )
|
sharedArgs+=( --offline )
|
||||||
|
|||||||
@@ -8,49 +8,18 @@
|
|||||||
: "${SKIP_SERVER_PROPERTIES:=false}"
|
: "${SKIP_SERVER_PROPERTIES:=false}"
|
||||||
: "${ENABLE_WHITELIST:=}"
|
: "${ENABLE_WHITELIST:=}"
|
||||||
|
|
||||||
# FUNCTIONS
|
|
||||||
function setServerPropValue {
|
|
||||||
local prop=$1
|
|
||||||
local value=$2
|
|
||||||
# normalize booleans
|
|
||||||
case ${value^^} in
|
|
||||||
TRUE|FALSE)
|
|
||||||
value=${value,,} ;;
|
|
||||||
esac
|
|
||||||
if [[ $prop =~ password ]]; then
|
|
||||||
showValue="*****"
|
|
||||||
else
|
|
||||||
showValue="$value"
|
|
||||||
fi
|
|
||||||
if [ -f "$SERVER_PROPERTIES" ] && grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then
|
|
||||||
debug "Setting ${prop} to '${showValue}' in ${SERVER_PROPERTIES}"
|
|
||||||
sed -i "/^${prop}\s*=/ c ${prop}=${value//\\/\\\\}" "$SERVER_PROPERTIES"
|
|
||||||
else
|
|
||||||
debug "Adding ${prop} with '${showValue}' in ${SERVER_PROPERTIES}"
|
|
||||||
echo "${prop}=${value}" >> "$SERVER_PROPERTIES"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function setServerProp {
|
|
||||||
local prop=$1
|
|
||||||
local varName=$2
|
|
||||||
|
|
||||||
if [ -v $varName ]; then
|
|
||||||
setServerPropValue "$prop" "${!varName}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function customizeServerProps {
|
function customizeServerProps {
|
||||||
local firstSetup=$1
|
local firstSetup=$1
|
||||||
# Whitelist processing
|
# Whitelist processing
|
||||||
if [ -n "$WHITELIST" ] || [ -n "$WHITELIST_FILE" ] || isTrue "${ENABLE_WHITELIST}"; then
|
if [ -n "$WHITELIST" ] || [ -n "$WHITELIST_FILE" ] || isTrue "${ENABLE_WHITELIST}"; then
|
||||||
log "Enabling whitelist functionality"
|
log "Enabling whitelist functionality"
|
||||||
setServerPropValue "white-list" "true"
|
WHITELIST_PROP=true
|
||||||
setServerPropValue "enforce-whitelist" "true"
|
ENFORCE_WHITELIST=true
|
||||||
|
export WHITELIST_PROP ENFORCE_WHITELIST
|
||||||
elif isTrue "$firstSetup" || isFalse "${ENABLE_WHITELIST}"; then
|
elif isTrue "$firstSetup" || isFalse "${ENABLE_WHITELIST}"; then
|
||||||
log "Disabling whitelist functionality"
|
log "Disabling whitelist functionality"
|
||||||
setServerPropValue "white-list" "false"
|
WHITELIST_PROP=false
|
||||||
setServerProp "enforce-whitelist" ENFORCE_WHITELIST
|
export WHITELIST_PROP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# normalize MOTD
|
# normalize MOTD
|
||||||
@@ -60,100 +29,7 @@ function customizeServerProps {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
setServerProp "server-name" SERVER_NAME
|
if [[ -v MODE ]]; then
|
||||||
setServerProp "server-ip" SERVER_IP
|
|
||||||
setServerProp "server-port" SERVER_PORT
|
|
||||||
setServerProp "allow-nether" ALLOW_NETHER
|
|
||||||
setServerProp "announce-player-achievements" ANNOUNCE_PLAYER_ACHIEVEMENTS
|
|
||||||
setServerProp "enable-command-block" ENABLE_COMMAND_BLOCK
|
|
||||||
setServerProp "spawn-animals" SPAWN_ANIMALS
|
|
||||||
setServerProp "spawn-monsters" SPAWN_MONSTERS
|
|
||||||
setServerProp "spawn-npcs" SPAWN_NPCS
|
|
||||||
setServerProp "spawn-protection" SPAWN_PROTECTION
|
|
||||||
setServerProp "generate-structures" GENERATE_STRUCTURES
|
|
||||||
setServerProp "view-distance" VIEW_DISTANCE
|
|
||||||
setServerProp "hardcore" HARDCORE
|
|
||||||
setServerProp "snooper-enabled" SNOOPER_ENABLED
|
|
||||||
setServerProp "max-build-height" MAX_BUILD_HEIGHT
|
|
||||||
setServerProp "force-gamemode" FORCE_GAMEMODE
|
|
||||||
setServerProp "max-tick-time" MAX_TICK_TIME
|
|
||||||
setServerProp "enable-query" ENABLE_QUERY
|
|
||||||
setServerProp "query.port" QUERY_PORT
|
|
||||||
setServerProp "enable-rcon" ENABLE_RCON
|
|
||||||
setServerProp "rcon.password" RCON_PASSWORD
|
|
||||||
setServerProp "rcon.port" RCON_PORT
|
|
||||||
setServerProp "max-players" MAX_PLAYERS
|
|
||||||
setServerProp "max-world-size" MAX_WORLD_SIZE
|
|
||||||
setServerProp "level-name" LEVEL
|
|
||||||
setServerProp "level-seed" SEED
|
|
||||||
setServerProp "pvp" PVP
|
|
||||||
setServerProp "generator-settings" GENERATOR_SETTINGS
|
|
||||||
setServerProp "online-mode" ONLINE_MODE
|
|
||||||
setServerProp "allow-flight" ALLOW_FLIGHT
|
|
||||||
setServerProp "resource-pack" RESOURCE_PACK
|
|
||||||
setServerProp "resource-pack-sha1" RESOURCE_PACK_SHA1
|
|
||||||
setServerProp "require-resource-pack" RESOURCE_PACK_ENFORCE
|
|
||||||
setServerProp "player-idle-timeout" PLAYER_IDLE_TIMEOUT
|
|
||||||
setServerProp "broadcast-console-to-ops" BROADCAST_CONSOLE_TO_OPS
|
|
||||||
setServerProp "broadcast-rcon-to-ops" BROADCAST_RCON_TO_OPS
|
|
||||||
setServerProp "enable-jmx-monitoring" ENABLE_JMX
|
|
||||||
setServerProp "sync-chunk-writes" SYNC_CHUNK_WRITES
|
|
||||||
setServerProp "enable-status" ENABLE_STATUS
|
|
||||||
setServerProp "entity-broadcast-range-percentage" ENTITY_BROADCAST_RANGE_PERCENTAGE
|
|
||||||
setServerProp "function-permission-level" FUNCTION_PERMISSION_LEVEL
|
|
||||||
setServerProp "network-compression-threshold" NETWORK_COMPRESSION_THRESHOLD
|
|
||||||
setServerProp "op-permission-level" OP_PERMISSION_LEVEL
|
|
||||||
setServerProp "prevent-proxy-connections" PREVENT_PROXY_CONNECTIONS
|
|
||||||
setServerProp "use-native-transport" USE_NATIVE_TRANSPORT
|
|
||||||
setServerProp "simulation-distance" SIMULATION_DISTANCE
|
|
||||||
setServerProp "previews-chat" PREVIEWS_CHAT
|
|
||||||
setServerProp "enforce-secure-profile" ENFORCE_SECURE_PROFILE
|
|
||||||
setServerProp "initial-enabled-packs" INITIAL_ENABLED_PACKS
|
|
||||||
setServerProp "initial-disabled-packs" INITIAL_DISABLED_PACKS
|
|
||||||
if [[ $MOTD ]]; then
|
|
||||||
setServerPropValue "motd" "$(echo "$MOTD" | mc-image-helper asciify)"
|
|
||||||
fi
|
|
||||||
[[ $LEVEL_TYPE ]] && setServerPropValue "level-type" "${LEVEL_TYPE^^}"
|
|
||||||
|
|
||||||
if [ -n "$DIFFICULTY" ]; then
|
|
||||||
case ${DIFFICULTY,,} in
|
|
||||||
peaceful|0)
|
|
||||||
if versionLessThan 1.13; then
|
|
||||||
DIFFICULTY=0
|
|
||||||
else
|
|
||||||
DIFFICULTY=peaceful
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
easy|1)
|
|
||||||
if versionLessThan 1.13; then
|
|
||||||
DIFFICULTY=1
|
|
||||||
else
|
|
||||||
DIFFICULTY=easy
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
normal|2)
|
|
||||||
if versionLessThan 1.13; then
|
|
||||||
DIFFICULTY=2
|
|
||||||
else
|
|
||||||
DIFFICULTY=normal
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
hard|3)
|
|
||||||
if versionLessThan 1.13; then
|
|
||||||
DIFFICULTY=3
|
|
||||||
else
|
|
||||||
DIFFICULTY=hard
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
log "DIFFICULTY must be peaceful, easy, normal, or hard."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
setServerPropValue "difficulty" "$DIFFICULTY"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$MODE" ]; then
|
|
||||||
log "Setting mode"
|
log "Setting mode"
|
||||||
case ${MODE,,} in
|
case ${MODE,,} in
|
||||||
su*|0)
|
su*|0)
|
||||||
@@ -189,8 +65,58 @@ function customizeServerProps {
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
setServerPropValue "gamemode" "$MODE"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -v DIFFICULTY ]]; then
|
||||||
|
case ${DIFFICULTY,,} in
|
||||||
|
peaceful|0)
|
||||||
|
if versionLessThan 1.13; then
|
||||||
|
DIFFICULTY=0
|
||||||
|
else
|
||||||
|
DIFFICULTY=peaceful
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
easy|1)
|
||||||
|
if versionLessThan 1.13; then
|
||||||
|
DIFFICULTY=1
|
||||||
|
else
|
||||||
|
DIFFICULTY=easy
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
normal|2)
|
||||||
|
if versionLessThan 1.13; then
|
||||||
|
DIFFICULTY=2
|
||||||
|
else
|
||||||
|
DIFFICULTY=normal
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
hard|3)
|
||||||
|
if versionLessThan 1.13; then
|
||||||
|
DIFFICULTY=3
|
||||||
|
else
|
||||||
|
DIFFICULTY=hard
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "DIFFICULTY must be peaceful, easy, normal, or hard."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -v LEVEL_TYPE ]]; then
|
||||||
|
LEVEL_TYPE="${LEVEL_TYPE^^}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
setPropertiesArgs=(
|
||||||
|
--definitions "/image/property-definitions.json"
|
||||||
|
)
|
||||||
|
if [[ -v CUSTOM_SERVER_PROPERTIES ]]; then
|
||||||
|
setPropertiesArgs+=(--custom-properties "$CUSTOM_SERVER_PROPERTIES")
|
||||||
|
fi
|
||||||
|
|
||||||
|
mc-image-helper set-properties "${setPropertiesArgs[@]}" "$SERVER_PROPERTIES"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Deploy server.properties file
|
# Deploy server.properties file
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
[[ $EXTENDED_TESTS ]] || exit 1
|
||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user