2020-05-20 13:17:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
current_uptime() {
|
2021-11-16 02:50:47 +00:00
|
|
|
awk '{print $1}' /proc/uptime | cut -d . -f 1
|
2020-05-20 13:17:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
java_running() {
|
2020-12-31 19:15:44 +00:00
|
|
|
[[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]]
|
2020-05-20 13:17:58 +00:00
|
|
|
}
|
|
|
|
|
2021-01-02 17:27:03 +00:00
|
|
|
java_process_exists() {
|
2021-01-12 22:05:12 +00:00
|
|
|
[[ -n "$(ps -ax -o comm | grep 'java')" ]]
|
2021-01-02 17:27:03 +00:00
|
|
|
}
|
|
|
|
|
2020-05-20 13:17:58 +00:00
|
|
|
rcon_client_exists() {
|
2020-12-31 19:15:44 +00:00
|
|
|
[[ -n "$(ps -ax -o comm | grep 'rcon-cli')" ]]
|
2020-05-20 13:17:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mc_server_listening() {
|
2021-11-16 02:50:47 +00:00
|
|
|
mc-monitor status --host localhost --port "$SERVER_PORT" --timeout 10s >& /dev/null
|
2020-05-20 13:17:58 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 17:29:12 +00:00
|
|
|
java_clients_connections() {
|
2020-05-20 13:17:58 +00:00
|
|
|
local connections
|
2021-09-30 21:51:51 +00:00
|
|
|
if java_running ; then
|
2021-11-16 02:50:47 +00:00
|
|
|
connections=$(mc-monitor status --host localhost --port "$SERVER_PORT" --show-player-count)
|
2021-09-30 21:51:51 +00:00
|
|
|
else
|
|
|
|
connections=0
|
2020-05-20 13:17:58 +00:00
|
|
|
fi
|
2022-03-02 17:29:12 +00:00
|
|
|
echo $connections
|
|
|
|
}
|
|
|
|
|
|
|
|
java_clients_connected() {
|
|
|
|
(( $(java_clients_connections) > 0 ))
|
2020-05-20 13:17:58 +00:00
|
|
|
}
|