Show IP address that caused auto-pause to resume (#1709)
Also * Refactored auto files, server.properties, and rcon-cmds
This commit is contained in:
parent
417a65a3af
commit
0e0bb09533
|
@ -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 bin/ /usr/local/bin/
|
||||
COPY --chmod=755 bin/mc-health /health.sh
|
||||
COPY --chmod=644 files/server.properties /tmp/server.properties
|
||||
COPY --chmod=644 files/log4j2.xml /tmp/log4j2.xml
|
||||
COPY --chmod=755 files/autopause /autopause
|
||||
COPY --chmod=755 files/autostop /autostop
|
||||
COPY --chmod=755 files/rconcmds /rconcmds
|
||||
COPY --chmod=644 files/log4j2.xml /image/log4j2.xml
|
||||
COPY --chmod=755 files/auto /auto
|
||||
|
||||
RUN dos2unix /start* /autopause/* /autostop/* /rconcmds/*
|
||||
RUN dos2unix /start* /auto/*
|
||||
|
||||
ENTRYPOINT [ "/start" ]
|
||||
HEALTHCHECK --start-period=1m --interval=5s --retries=24 CMD mc-health
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
: "${RCON_CMDS_PERIOD:=10}"
|
||||
|
||||
# needed for the clients connected function residing in autopause
|
||||
# shellcheck source=/autopause/autopause-fcns.sh
|
||||
. /autopause/autopause-fcns.sh
|
||||
# shellcheck source=../auto/autopause-fcns.sh
|
||||
. /auto/autopause-fcns.sh
|
||||
|
||||
# shellcheck source=start-utils
|
||||
. ${SCRIPTS:-/}start-utils
|
14
files/autopause/autopause-daemon.sh → files/auto/autopause-daemon.sh
Executable file → Normal file
14
files/autopause/autopause-daemon.sh → files/auto/autopause-daemon.sh
Executable file → Normal file
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
. /autopause/autopause-fcns.sh
|
||||
. /auto/autopause-fcns.sh
|
||||
|
||||
# shellcheck source=../../scripts/start-utils
|
||||
. "${SCRIPTS:-/}start-utils"
|
||||
|
@ -76,7 +76,7 @@ do
|
|||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutopause "No client connected since startup / knocked - pausing"
|
||||
/autopause/pause.sh
|
||||
/auto/pause.sh
|
||||
STATE=S
|
||||
fi
|
||||
fi
|
||||
|
@ -97,7 +97,7 @@ do
|
|||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutopause "No client reconnected - pausing"
|
||||
/autopause/pause.sh
|
||||
/auto/pause.sh
|
||||
STATE=S
|
||||
fi
|
||||
fi
|
||||
|
@ -105,7 +105,7 @@ do
|
|||
XS)
|
||||
# Stopped
|
||||
if rcon_client_exists ; then
|
||||
/autopause/resume.sh
|
||||
/auto/resume.sh
|
||||
fi
|
||||
if java_running ; then
|
||||
if java_clients_connected ; then
|
||||
|
@ -113,7 +113,11 @@ do
|
|||
STATE=E
|
||||
else
|
||||
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
|
||||
fi
|
||||
fi
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# needed for the clients connected function residing in autopause
|
||||
. /autopause/autopause-fcns.sh
|
||||
. /auto/autopause-fcns.sh
|
||||
|
||||
# shellcheck source=../../scripts/start-utils
|
||||
. "${SCRIPTS:-/}start-utils"
|
||||
|
@ -40,7 +40,7 @@ do
|
|||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutostop "No client connected since startup - stopping server"
|
||||
/autostop/stop.sh
|
||||
/auto/stop.sh
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
@ -61,7 +61,7 @@ do
|
|||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutostop "No client reconnected - stopping"
|
||||
/autostop/stop.sh
|
||||
/auto/stop.sh
|
||||
exit 0
|
||||
fi
|
||||
fi
|
|
@ -3,13 +3,13 @@
|
|||
[unpauseMCServer-server]
|
||||
sequence = 25565
|
||||
seq_timeout = 1
|
||||
command = /autopause/resume.sh
|
||||
command = /auto/resume.sh %IP%
|
||||
tcpflags = syn
|
||||
[unpauseMCServer-rcon]
|
||||
sequence = 25575
|
||||
seq_timeout = 1
|
||||
command = /autopause/resume.sh
|
||||
command = /auto/resume.sh %IP%
|
||||
tcpflags = syn
|
||||
[unpauseMCServer-bedrock]
|
||||
sequence = 19132:udp
|
||||
command = /autopause/resume.sh
|
||||
command = /auto/resume.sh %IP%
|
|
@ -6,6 +6,7 @@ if isTrue "${DEBUG_AUTOPAUSE}"; then
|
|||
fi
|
||||
|
||||
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
|
||||
fi
|
|
@ -24,7 +24,7 @@ log "Autopause functionality enabled"
|
|||
|
||||
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
|
||||
regseq="^\s*sequence\s*=\s*$SERVER_PORT\s*$"
|
||||
|
@ -84,4 +84,4 @@ elif [[ -z "$MAX_TICK_TIME" ]] ; then
|
|||
export MAX_TICK_TIME
|
||||
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)"
|
||||
fi
|
||||
|
||||
/autostop/autostop-daemon.sh &
|
||||
/auto/autostop-daemon.sh &
|
||||
|
|
|
@ -83,7 +83,7 @@ if isTrue ${ENABLE_ROLLING_LOGS:-false}; then
|
|||
LOGFILE="/data/log4j2.xml"
|
||||
if [ ! -e "$LOGFILE" ]; then
|
||||
log "Creating log4j2.xml in ${LOGFILE}"
|
||||
cp /tmp/log4j2.xml "$LOGFILE"
|
||||
cp /image/log4j2.xml "$LOGFILE"
|
||||
else
|
||||
log "log4j2.xml already created, skipping"
|
||||
fi
|
||||
|
@ -214,7 +214,7 @@ function copyFilesForCurseForge() {
|
|||
[ -f /data/ops.txt ] && cp -f /data/ops.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}/"
|
||||
fi
|
||||
|
||||
|
@ -237,7 +237,7 @@ if [[ ${TYPE} == "CURSEFORGE" && "${SERVER}" ]]; then
|
|||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
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
|
||||
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)"
|
||||
fi
|
||||
|
||||
/rconcmds/rcon-cmds-daemon.sh &
|
||||
/usr/local/bin/rcon-cmds-daemon.sh &
|
||||
|
|
|
@ -20,7 +20,7 @@ function setServerPropValue {
|
|||
else
|
||||
showValue="$value"
|
||||
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}"
|
||||
sed -i "/^${prop}\s*=/ c ${prop}=${value//\\/\\\\}" "$SERVER_PROPERTIES"
|
||||
else
|
||||
|
@ -43,13 +43,11 @@ function customizeServerProps {
|
|||
if [ -n "$WHITELIST" ] || [ -n "$WHITELIST_FILE" ] || isTrue "${ENABLE_WHITELIST:-false}"; then
|
||||
log "Enabling whitelist functionality"
|
||||
setServerPropValue "white-list" "true"
|
||||
setServerPropValue "enforce-whitelist" "true"
|
||||
else
|
||||
log "Disabling whitelist functionality"
|
||||
setServerPropValue "white-list" "false"
|
||||
fi
|
||||
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."
|
||||
setServerProp "enforce-whitelist" ENFORCE_WHITELIST
|
||||
fi
|
||||
|
||||
# If not provided, generate a reasonable default message-of-the-day,
|
||||
|
@ -213,7 +211,6 @@ fi
|
|||
if ! isTrue "${SKIP_SERVER_PROPERTIES:-false}"; then
|
||||
if [ ! -e "$SERVER_PROPERTIES" ]; then
|
||||
log "Creating server properties in ${SERVER_PROPERTIES}"
|
||||
cp /tmp/server.properties "$SERVER_PROPERTIES"
|
||||
customizeServerProps
|
||||
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
|
||||
case ${OVERRIDE_SERVER_PROPERTIES^^} in
|
||||
|
@ -233,11 +230,13 @@ else
|
|||
fi
|
||||
|
||||
if isTrue "${ENABLE_AUTOPAUSE}"; then
|
||||
current_max_tick=$( grep 'max-tick-time' "$SERVER_PROPERTIES" | sed -r 's/( )+//g' | awk -F= '{print $2}' )
|
||||
if (( current_max_tick > 0 && current_max_tick < 86400000 )); then
|
||||
log "Warning: The server.properties for the server doesn't have the Server Watchdog (effectively) disabled."
|
||||
log "Warning (cont): Autopause functionality resuming the process might trigger the Watchdog and restart the server completely."
|
||||
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+)."
|
||||
if [ -f "$SERVER_PROPERTIES" ]; then
|
||||
current_max_tick=$( grep 'max-tick-time' "$SERVER_PROPERTIES" | sed -r 's/( )+//g' | awk -F= '{print $2}' )
|
||||
if (( current_max_tick > 0 && current_max_tick < 86400000 )); then
|
||||
log "Warning: The server.properties for the server doesn't have the Server Watchdog (effectively) disabled."
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue