RCON commands feature (#1391)

Co-authored-by: christopher blodgett <christopher.blodgett@gmail.com>
This commit is contained in:
chblodg
2022-03-02 09:29:12 -08:00
committed by GitHub
parent 15869fd774
commit 4587b32480
8 changed files with 197 additions and 3 deletions

View File

@@ -8,6 +8,10 @@ IFS=$'\n\t'
: "${EULA:=}"
: "${PROXY:=}"
: "${RCON_PASSWORD_FILE:=}"
: "${RCON_CMDS_STARTUP:=}"
: "${RCON_CMDS_ON_CONNECT:=}"
: "${RCON_CMDS_ON_DISCONNECT:=}"
: "${RCON_CMDS_PERIOD:=10}"
shopt -s nullglob
@@ -124,6 +128,12 @@ if isTrue "${ENABLE_AUTOSTOP}"; then
${SCRIPTS:-/}start-autostop
fi
if [[ "$RCON_CMDS_STARTUP" ]] || [[ "$RCON_CMDS_ON_CONNECT" ]] || [[ "$RCON_CMDS_ON_DISCONNECT" ]]; then
log "Starting RCON commands"
# shellcheck source=start-rconcmds
${SCRIPTS:-/}start-rconcmds
fi
if versionLessThan 1.7; then
echo "
MC_HEALTH_EXTRA_ARGS=(

32
scripts/start-rconcmds Normal file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils"
: "${RCON_CMDS_STARTUP:=}"
: "${RCON_CMDS_ON_CONNECT:=}"
: "${RCON_CMDS_ON_DISCONNECT:=}"
: "${RCON_CMDS_PERIOD:=10}"
: "${SERVER_PORT:=25565}"
export RCON_CMDS_STARTUP
export RCON_CMDS_ON_CONNECT
export RCON_CMDS_ON_DISCONNECT
export RCON_CMDS_PERIOD
export SERVER_PORT
log "Rcon cmds functionality enabled"
isDebugging && set -x
if ! [[ $RCON_CMDS_PERIOD =~ ^[0-9]+$ ]]; then
RCON_CMDS_PERIOD=10
export RCON_CMDS_PERIOD
log "Warning: RCON_CMDS_PERIOD is not numeric, set to 10 (seconds)"
fi
if [ "$RCON_CMDS_PERIOD" -eq "0" ] ; then
RCON_CMDS_PERIOD=10
export RCON_CMDS_PERIOD
log "Warning: RCON_CMDS_PERIOD must not be 0, set to 10 (seconds)"
fi
/rconcmds/rcon-cmds-daemon.sh &

View File

@@ -117,6 +117,10 @@ function logAutostopAction() {
echo "[$(date -Iseconds)] [Autostop] $*"
}
function logRcon() {
echo "[Rcon loop] $*"
}
function normalizeMemSize() {
local scale=1
case ${1,,} in