From 97fe6b1f14f597d6746d90d191f00acbf8b8ef5c Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 10 Apr 2022 10:58:18 -0500 Subject: [PATCH] Corrected autopause's resume to work with alpine images (#1464) --- Dockerfile | 8 +------- files/autopause/knockd-config.cfg | 6 +++--- scripts/start-autopause | 12 ++++++++++++ scripts/start-autostop | 8 ++++++++ scripts/start-configuration | 7 ++++++- scripts/start-finalExec | 1 + scripts/start-setupServerProperties | 1 + tests/setuponlytests/defaults/docker-compose.yml | 11 +++++++++++ tests/setuponlytests/defaults/verify.sh | 3 +++ 9 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 tests/setuponlytests/defaults/docker-compose.yml create mode 100644 tests/setuponlytests/defaults/verify.sh diff --git a/Dockerfile b/Dockerfile index a7c8cb99..38a8e395 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,13 +57,7 @@ WORKDIR /data STOPSIGNAL SIGTERM -ENV UID=1000 GID=1000 \ - MEMORY="1G" \ - TYPE=VANILLA VERSION=LATEST \ - ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \ - ENABLE_AUTOPAUSE=false AUTOPAUSE_TIMEOUT_EST=3600 AUTOPAUSE_TIMEOUT_KN=120 AUTOPAUSE_TIMEOUT_INIT=600 \ - AUTOPAUSE_PERIOD=10 AUTOPAUSE_KNOCK_INTERFACE=eth0 \ - ENABLE_AUTOSTOP=false AUTOSTOP_TIMEOUT_EST=3600 AUTOSTOP_TIMEOUT_INIT=1800 AUTOSTOP_PERIOD=10 +ENV TYPE=VANILLA VERSION=LATEST EULA="" COPY --chmod=755 scripts/start* / COPY --chmod=755 bin/ /usr/local/bin/ diff --git a/files/autopause/knockd-config.cfg b/files/autopause/knockd-config.cfg index 84cbe366..768e6c86 100644 --- a/files/autopause/knockd-config.cfg +++ b/files/autopause/knockd-config.cfg @@ -3,13 +3,13 @@ [unpauseMCServer-server] sequence = 25565 seq_timeout = 1 - command = /usr/sbin/gosu minecraft:minecraft /autopause/resume.sh + command = /autopause/resume.sh tcpflags = syn [unpauseMCServer-rcon] sequence = 25575 seq_timeout = 1 - command = /usr/sbin/gosu minecraft:minecraft /autopause/resume.sh + command = /autopause/resume.sh tcpflags = syn [unpauseMCServer-bedrock] sequence = 19132:udp - command = /usr/sbin/gosu minecraft:minecraft /autopause/resume.sh + command = /autopause/resume.sh diff --git a/scripts/start-autopause b/scripts/start-autopause index 02b33d0a..c2646726 100755 --- a/scripts/start-autopause +++ b/scripts/start-autopause @@ -4,7 +4,19 @@ . "${SCRIPTS:-/}start-utils" : "${SERVER_PORT:=25565}" +: "${ENABLE_AUTOPAUSE:=false}" +: "${AUTOPAUSE_TIMEOUT_EST:=3600}" +: "${AUTOPAUSE_TIMEOUT_KN:=120}" +: "${AUTOPAUSE_TIMEOUT_INIT:=600}" +: "${AUTOPAUSE_PERIOD:=10}" +: "${AUTOPAUSE_KNOCK_INTERFACE:=eth0}" export SERVER_PORT +export ENABLE_AUTOPAUSE +export AUTOPAUSE_TIMEOUT_EST +export AUTOPAUSE_TIMEOUT_KN +export AUTOPAUSE_TIMEOUT_INIT +export AUTOPAUSE_PERIOD +export AUTOPAUSE_KNOCK_INTERFACE log "Autopause functionality enabled" diff --git a/scripts/start-autostop b/scripts/start-autostop index b71bf395..1962526d 100755 --- a/scripts/start-autostop +++ b/scripts/start-autostop @@ -4,7 +4,15 @@ . "${SCRIPTS:-/}start-utils" : "${SERVER_PORT:=25565}" +: "${ENABLE_AUTOSTOP:=false}" +: "${AUTOSTOP_TIMEOUT_EST:=3600}" +: "${AUTOSTOP_TIMEOUT_INIT:=1800}" +: "${AUTOSTOP_PERIOD:=10}" export SERVER_PORT +export ENABLE_AUTOSTOP +export AUTOSTOP_TIMEOUT_EST +export AUTOSTOP_TIMEOUT_INIT +export AUTOSTOP_PERIOD log "Autostop functionality enabled" diff --git a/scripts/start-configuration b/scripts/start-configuration index a3720a52..e2626abd 100755 --- a/scripts/start-configuration +++ b/scripts/start-configuration @@ -7,13 +7,18 @@ IFS=$'\n\t' : "${EULA:=}" : "${PROXY:=}" -: "${RCON_PASSWORD_FILE:=}" +: "${ENABLE_AUTOPAUSE:=false}" +: "${ENABLE_AUTOSTOP:=false}" : "${RCON_CMDS_STARTUP:=}" : "${RCON_CMDS_ON_CONNECT:=}" : "${RCON_CMDS_ON_DISCONNECT:=}" : "${RCON_CMDS_FIRST_CONNECT:=}" : "${RCON_CMDS_LAST_DISCONNECT:=}" : "${RCON_CMDS_PERIOD:=10}" +: "${RCON_PASSWORD_FILE:=}" +: "${RCON_PASSWORD:=minecraft}" +: "${RCON_PORT:=25575}" +export RCON_PASSWORD RCON_PORT shopt -s nullglob diff --git a/scripts/start-finalExec b/scripts/start-finalExec index 8a85e017..46a0aaee 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -97,6 +97,7 @@ if [[ ${GUI,,} = false ]]; then EXTRA_ARGS+=" nogui" fi +: "${MEMORY:=1G}" : "${INIT_MEMORY:=${MEMORY}}" : "${MAX_MEMORY:=${MEMORY}}" diff --git a/scripts/start-setupServerProperties b/scripts/start-setupServerProperties index 0a70273a..087a3c69 100755 --- a/scripts/start-setupServerProperties +++ b/scripts/start-setupServerProperties @@ -4,6 +4,7 @@ . "${SCRIPTS:-/}start-utils" : "${SERVER_PROPERTIES:=/data/server.properties}" +: "${ENABLE_RCON:=true}" # FUNCTIONS function setServerPropValue { diff --git a/tests/setuponlytests/defaults/docker-compose.yml b/tests/setuponlytests/defaults/docker-compose.yml new file mode 100644 index 00000000..970502b5 --- /dev/null +++ b/tests/setuponlytests/defaults/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3" + +services: + mc: + restart: "no" + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "TRUE" + SETUP_ONLY: "TRUE" + volumes: + - ./data:/data diff --git a/tests/setuponlytests/defaults/verify.sh b/tests/setuponlytests/defaults/verify.sh new file mode 100644 index 00000000..b6d87238 --- /dev/null +++ b/tests/setuponlytests/defaults/verify.sh @@ -0,0 +1,3 @@ +mc-image-helper assert propertyEquals --file=server.properties --property=rcon.password --expect=minecraft +mc-image-helper assert propertyEquals --file=server.properties --property=rcon.port --expect=25575 +mc-image-helper assert propertyEquals --file=server.properties --property=enable-rcon --expect=true