docker-minecraft-server/files/auto/autopause-fcns.sh
Geoff Bourne 0e0bb09533
Show IP address that caused auto-pause to resume (#1709)
Also
* Refactored auto files, server.properties, and rcon-cmds
2022-09-03 16:48:14 -05:00

35 lines
731 B
Bash

#!/bin/bash
current_uptime() {
awk '{print $1}' /proc/uptime | cut -d . -f 1
}
java_running() {
[[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]]
}
java_process_exists() {
[[ -n "$(ps -ax -o comm | grep 'java')" ]]
}
rcon_client_exists() {
[[ -n "$(ps -ax -o comm | grep 'rcon-cli')" ]]
}
mc_server_listening() {
mc-monitor status --host localhost --port "$SERVER_PORT" --timeout 10s >& /dev/null
}
java_clients_connections() {
local connections
if java_running ; then
connections=$(mc-monitor status --host localhost --port "$SERVER_PORT" --show-player-count)
else
connections=0
fi
echo $connections
}
java_clients_connected() {
(( $(java_clients_connections) > 0 ))
}