mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-07-10 10:35:10 +00:00
Show IP address that caused auto-pause to resume (#1709)
Also * Refactored auto files, server.properties, and rcon-cmds
This commit is contained in:
+3
-6
@@ -64,13 +64,10 @@ ENV TYPE=VANILLA VERSION=LATEST EULA="" UID=1000 GID=1000 RCON_PASSWORD=minecraf
|
|||||||
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/server.properties /tmp/server.properties
|
COPY --chmod=644 files/log4j2.xml /image/log4j2.xml
|
||||||
COPY --chmod=644 files/log4j2.xml /tmp/log4j2.xml
|
COPY --chmod=755 files/auto /auto
|
||||||
COPY --chmod=755 files/autopause /autopause
|
|
||||||
COPY --chmod=755 files/autostop /autostop
|
|
||||||
COPY --chmod=755 files/rconcmds /rconcmds
|
|
||||||
|
|
||||||
RUN dos2unix /start* /autopause/* /autostop/* /rconcmds/*
|
RUN dos2unix /start* /auto/*
|
||||||
|
|
||||||
ENTRYPOINT [ "/start" ]
|
ENTRYPOINT [ "/start" ]
|
||||||
HEALTHCHECK --start-period=1m --interval=5s --retries=24 CMD mc-health
|
HEALTHCHECK --start-period=1m --interval=5s --retries=24 CMD mc-health
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
: "${RCON_CMDS_PERIOD:=10}"
|
: "${RCON_CMDS_PERIOD:=10}"
|
||||||
|
|
||||||
# needed for the clients connected function residing in autopause
|
# needed for the clients connected function residing in autopause
|
||||||
# shellcheck source=/autopause/autopause-fcns.sh
|
# shellcheck source=../auto/autopause-fcns.sh
|
||||||
. /autopause/autopause-fcns.sh
|
. /auto/autopause-fcns.sh
|
||||||
|
|
||||||
# shellcheck source=start-utils
|
# shellcheck source=start-utils
|
||||||
. ${SCRIPTS:-/}start-utils
|
. ${SCRIPTS:-/}start-utils
|
||||||
Executable → Regular
+9
-5
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
. /autopause/autopause-fcns.sh
|
. /auto/autopause-fcns.sh
|
||||||
|
|
||||||
# shellcheck source=../../scripts/start-utils
|
# shellcheck source=../../scripts/start-utils
|
||||||
. "${SCRIPTS:-/}start-utils"
|
. "${SCRIPTS:-/}start-utils"
|
||||||
@@ -76,7 +76,7 @@ do
|
|||||||
else
|
else
|
||||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||||
logAutopause "No client connected since startup / knocked - pausing"
|
logAutopause "No client connected since startup / knocked - pausing"
|
||||||
/autopause/pause.sh
|
/auto/pause.sh
|
||||||
STATE=S
|
STATE=S
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -97,7 +97,7 @@ do
|
|||||||
else
|
else
|
||||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||||
logAutopause "No client reconnected - pausing"
|
logAutopause "No client reconnected - pausing"
|
||||||
/autopause/pause.sh
|
/auto/pause.sh
|
||||||
STATE=S
|
STATE=S
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -105,7 +105,7 @@ do
|
|||||||
XS)
|
XS)
|
||||||
# Stopped
|
# Stopped
|
||||||
if rcon_client_exists ; then
|
if rcon_client_exists ; then
|
||||||
/autopause/resume.sh
|
/auto/resume.sh
|
||||||
fi
|
fi
|
||||||
if java_running ; then
|
if java_running ; then
|
||||||
if java_clients_connected ; then
|
if java_clients_connected ; then
|
||||||
@@ -113,7 +113,11 @@ do
|
|||||||
STATE=E
|
STATE=E
|
||||||
else
|
else
|
||||||
TIME_THRESH=$(($(current_uptime)+$AUTOPAUSE_TIMEOUT_KN))
|
TIME_THRESH=$(($(current_uptime)+$AUTOPAUSE_TIMEOUT_KN))
|
||||||
logAutopause "Server was knocked - waiting for clients or timeout"
|
from=unknown
|
||||||
|
if [ -e /var/log/knocked-source ]; then
|
||||||
|
from=$(cat /var/log/knocked-source)
|
||||||
|
fi
|
||||||
|
logAutopause "Server was knocked from $from - waiting for clients or timeout"
|
||||||
STATE=K
|
STATE=K
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
Executable → Regular
Executable → Regular
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# needed for the clients connected function residing in autopause
|
# needed for the clients connected function residing in autopause
|
||||||
. /autopause/autopause-fcns.sh
|
. /auto/autopause-fcns.sh
|
||||||
|
|
||||||
# shellcheck source=../../scripts/start-utils
|
# shellcheck source=../../scripts/start-utils
|
||||||
. "${SCRIPTS:-/}start-utils"
|
. "${SCRIPTS:-/}start-utils"
|
||||||
@@ -40,7 +40,7 @@ do
|
|||||||
else
|
else
|
||||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||||
logAutostop "No client connected since startup - stopping server"
|
logAutostop "No client connected since startup - stopping server"
|
||||||
/autostop/stop.sh
|
/auto/stop.sh
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -61,7 +61,7 @@ do
|
|||||||
else
|
else
|
||||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||||
logAutostop "No client reconnected - stopping"
|
logAutostop "No client reconnected - stopping"
|
||||||
/autostop/stop.sh
|
/auto/stop.sh
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -3,13 +3,13 @@
|
|||||||
[unpauseMCServer-server]
|
[unpauseMCServer-server]
|
||||||
sequence = 25565
|
sequence = 25565
|
||||||
seq_timeout = 1
|
seq_timeout = 1
|
||||||
command = /autopause/resume.sh
|
command = /auto/resume.sh %IP%
|
||||||
tcpflags = syn
|
tcpflags = syn
|
||||||
[unpauseMCServer-rcon]
|
[unpauseMCServer-rcon]
|
||||||
sequence = 25575
|
sequence = 25575
|
||||||
seq_timeout = 1
|
seq_timeout = 1
|
||||||
command = /autopause/resume.sh
|
command = /auto/resume.sh %IP%
|
||||||
tcpflags = syn
|
tcpflags = syn
|
||||||
[unpauseMCServer-bedrock]
|
[unpauseMCServer-bedrock]
|
||||||
sequence = 19132:udp
|
sequence = 19132:udp
|
||||||
command = /autopause/resume.sh
|
command = /auto/resume.sh %IP%
|
||||||
Executable → Regular
Executable → Regular
+2
-1
@@ -6,6 +6,7 @@ if isTrue "${DEBUG_AUTOPAUSE}"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^T.*$ ]] ; then
|
if [[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^T.*$ ]] ; then
|
||||||
logAutopauseAction "Knocked, resuming Java process"
|
logAutopauseAction "Knocked from $1, resuming Java process"
|
||||||
|
echo "$1" > /var/log/knocked-source
|
||||||
pkill -CONT java
|
pkill -CONT java
|
||||||
fi
|
fi
|
||||||
Executable → Regular
@@ -24,7 +24,7 @@ log "Autopause functionality enabled"
|
|||||||
|
|
||||||
isDebugging && set -x
|
isDebugging && set -x
|
||||||
|
|
||||||
cp /autopause/knockd-config.cfg /tmp/knockd-config.cfg
|
cp /auto/knockd-config.cfg /tmp/knockd-config.cfg
|
||||||
|
|
||||||
# update server port to listen to
|
# update server port to listen to
|
||||||
regseq="^\s*sequence\s*=\s*$SERVER_PORT\s*$"
|
regseq="^\s*sequence\s*=\s*$SERVER_PORT\s*$"
|
||||||
@@ -84,4 +84,4 @@ elif [[ -z "$MAX_TICK_TIME" ]] ; then
|
|||||||
export MAX_TICK_TIME
|
export MAX_TICK_TIME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/autopause/autopause-daemon.sh &
|
/auto/autopause-daemon.sh &
|
||||||
|
|||||||
@@ -41,4 +41,4 @@ if ! [[ $AUTOSTOP_TIMEOUT_INIT =~ ^[0-9]+$ ]] ; then
|
|||||||
log "Warning: AUTOSTOP_TIMEOUT_INIT is not numeric, set to 1800 (seconds)"
|
log "Warning: AUTOSTOP_TIMEOUT_INIT is not numeric, set to 1800 (seconds)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/autostop/autostop-daemon.sh &
|
/auto/autostop-daemon.sh &
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ if isTrue ${ENABLE_ROLLING_LOGS:-false}; then
|
|||||||
LOGFILE="/data/log4j2.xml"
|
LOGFILE="/data/log4j2.xml"
|
||||||
if [ ! -e "$LOGFILE" ]; then
|
if [ ! -e "$LOGFILE" ]; then
|
||||||
log "Creating log4j2.xml in ${LOGFILE}"
|
log "Creating log4j2.xml in ${LOGFILE}"
|
||||||
cp /tmp/log4j2.xml "$LOGFILE"
|
cp /image/log4j2.xml "$LOGFILE"
|
||||||
else
|
else
|
||||||
log "log4j2.xml already created, skipping"
|
log "log4j2.xml already created, skipping"
|
||||||
fi
|
fi
|
||||||
@@ -214,7 +214,7 @@ function copyFilesForCurseForge() {
|
|||||||
[ -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" ] && [ -e /data/server-icon.png ]; then
|
||||||
cp -f /data/server-icon.png "${FTB_DIR}/"
|
cp -f /data/server-icon.png "${FTB_DIR}/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ if [[ ${TYPE} == "CURSEFORGE" && "${SERVER}" ]]; then
|
|||||||
if isTrue ${DEBUG_EXEC}; then
|
if isTrue ${DEBUG_EXEC}; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
exec mc-server-runner ${bootstrapArgs} "${mcServerRunnerArgs[@]}" java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar $(basename "${SERVER}") "$@" $EXTRA_ARGS
|
exec mc-server-runner ${bootstrapArgs} "${mcServerRunnerArgs[@]}" java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar "$(basename "${SERVER}")" "$@" $EXTRA_ARGS
|
||||||
elif [[ ${TYPE} == "CURSEFORGE" ]]; then
|
elif [[ ${TYPE} == "CURSEFORGE" ]]; then
|
||||||
mcServerRunnerArgs+=(--shell bash)
|
mcServerRunnerArgs+=(--shell bash)
|
||||||
|
|
||||||
|
|||||||
@@ -33,4 +33,4 @@ if [ "$RCON_CMDS_PERIOD" -eq "0" ] ; then
|
|||||||
log "Warning: RCON_CMDS_PERIOD must not be 0, set to 10 (seconds)"
|
log "Warning: RCON_CMDS_PERIOD must not be 0, set to 10 (seconds)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/rconcmds/rcon-cmds-daemon.sh &
|
/usr/local/bin/rcon-cmds-daemon.sh &
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function setServerPropValue {
|
|||||||
else
|
else
|
||||||
showValue="$value"
|
showValue="$value"
|
||||||
fi
|
fi
|
||||||
if grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then
|
if [ -f "$SERVER_PROPERTIES" ] && grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then
|
||||||
debug "Setting ${prop} to '${showValue}' in ${SERVER_PROPERTIES}"
|
debug "Setting ${prop} to '${showValue}' in ${SERVER_PROPERTIES}"
|
||||||
sed -i "/^${prop}\s*=/ c ${prop}=${value//\\/\\\\}" "$SERVER_PROPERTIES"
|
sed -i "/^${prop}\s*=/ c ${prop}=${value//\\/\\\\}" "$SERVER_PROPERTIES"
|
||||||
else
|
else
|
||||||
@@ -43,13 +43,11 @@ function customizeServerProps {
|
|||||||
if [ -n "$WHITELIST" ] || [ -n "$WHITELIST_FILE" ] || isTrue "${ENABLE_WHITELIST:-false}"; then
|
if [ -n "$WHITELIST" ] || [ -n "$WHITELIST_FILE" ] || isTrue "${ENABLE_WHITELIST:-false}"; then
|
||||||
log "Enabling whitelist functionality"
|
log "Enabling whitelist functionality"
|
||||||
setServerPropValue "white-list" "true"
|
setServerPropValue "white-list" "true"
|
||||||
|
setServerPropValue "enforce-whitelist" "true"
|
||||||
else
|
else
|
||||||
log "Disabling whitelist functionality"
|
log "Disabling whitelist functionality"
|
||||||
setServerPropValue "white-list" "false"
|
setServerPropValue "white-list" "false"
|
||||||
fi
|
setServerProp "enforce-whitelist" ENFORCE_WHITELIST
|
||||||
setServerProp "enforce-whitelist" ENFORCE_WHITELIST
|
|
||||||
if [[ $(grep "enforce-whitelist" $SERVER_PROPERTIES) != *true ]]; then
|
|
||||||
log "WARNING: whitelist enabled but not enforced. Set ENFORCE_WHITELIST=TRUE or update 'enforce-whitelist' in server.properties to enforce the whitelist."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If not provided, generate a reasonable default message-of-the-day,
|
# If not provided, generate a reasonable default message-of-the-day,
|
||||||
@@ -213,7 +211,6 @@ fi
|
|||||||
if ! isTrue "${SKIP_SERVER_PROPERTIES:-false}"; then
|
if ! isTrue "${SKIP_SERVER_PROPERTIES:-false}"; then
|
||||||
if [ ! -e "$SERVER_PROPERTIES" ]; then
|
if [ ! -e "$SERVER_PROPERTIES" ]; then
|
||||||
log "Creating server properties in ${SERVER_PROPERTIES}"
|
log "Creating server properties in ${SERVER_PROPERTIES}"
|
||||||
cp /tmp/server.properties "$SERVER_PROPERTIES"
|
|
||||||
customizeServerProps
|
customizeServerProps
|
||||||
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
|
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
|
||||||
case ${OVERRIDE_SERVER_PROPERTIES^^} in
|
case ${OVERRIDE_SERVER_PROPERTIES^^} in
|
||||||
@@ -233,11 +230,13 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if isTrue "${ENABLE_AUTOPAUSE}"; then
|
if isTrue "${ENABLE_AUTOPAUSE}"; then
|
||||||
current_max_tick=$( grep 'max-tick-time' "$SERVER_PROPERTIES" | sed -r 's/( )+//g' | awk -F= '{print $2}' )
|
if [ -f "$SERVER_PROPERTIES" ]; then
|
||||||
if (( current_max_tick > 0 && current_max_tick < 86400000 )); then
|
current_max_tick=$( grep 'max-tick-time' "$SERVER_PROPERTIES" | sed -r 's/( )+//g' | awk -F= '{print $2}' )
|
||||||
log "Warning: The server.properties for the server doesn't have the Server Watchdog (effectively) disabled."
|
if (( current_max_tick > 0 && current_max_tick < 86400000 )); then
|
||||||
log "Warning (cont): Autopause functionality resuming the process might trigger the Watchdog and restart the server completely."
|
log "Warning: The server.properties for the server doesn't have the Server Watchdog (effectively) disabled."
|
||||||
log "Warning (cont): Set the max-tick-time property to a high value (or disable the Watchdog with value -1 for versions 1.8.1+)."
|
log " Autopause functionality resuming the process might trigger the Watchdog and restart the server completely."
|
||||||
|
log " Set the MAX_TICK_TIME env variable (or max-tick-time property) to a high value (or disable the Watchdog with value -1 for versions 1.8.1+)."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user