aboutsummarylogtreecommitdiffstats
path: root/minecraftd.sh
diff options
context:
space:
mode:
Diffstat (limited to 'minecraftd.sh')
-rwxr-xr-xminecraftd.sh9
1 files changed, 5 insertions, 4 deletions
diff --git a/minecraftd.sh b/minecraftd.sh
index 873a708cfb65..415ca6f8e83d 100755
--- a/minecraftd.sh
+++ b/minecraftd.sh
@@ -68,6 +68,7 @@ fi
# Pipe any given argument to the game server console,
# sleep for $sleep_time and return its output if $return_stdout is set
game_command() {
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" wait-for -L "command_lock"
if [[ -z "${return_stdout:-}" ]]; then
${SUDO_CMD} tmux -L "${SESSION_NAME}" send-keys -t "${SESSION_NAME}":0.0 "$*" Enter
else
@@ -77,6 +78,7 @@ game_command() {
${SUDO_CMD} tmux -L "${SESSION_NAME}" pipe-pane -t "${SESSION_NAME}":0.0
${SUDO_CMD} cat "${GAME_COMMAND_DUMP}"
fi
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" wait-for -U "command_lock"
}
# Check whether there are player on the server through list
@@ -119,11 +121,8 @@ idle_server_daemon() {
if socket_has_session "${SESSION_NAME}"; then
# Game server is up and running
- if [[ -n "$(tmux -L "${SESSION_NAME}" list-clients -t "${SESSION_NAME}":0.0 2> /dev/null)" ]]; then
- # An administrator is connected to the console, pause player checking
- echo "An admin is connected to the console. Pause player checking."
# Check for active player
- elif SUDO_CMD="" is_player_online; then
+ if SUDO_CMD="" is_player_online; then
# No player was seen on the server through list
no_player=$(( no_player + CHECK_PLAYER_TIME ))
# Stop the game server if no player was active for at least ${IDLE_IF_TIME}
@@ -418,7 +417,9 @@ server_command() {
# Enter the tmux game session
server_console() {
if socket_has_session "${SESSION_NAME}"; then
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" wait-for -L "command_lock"
${SUDO_CMD} tmux -L "${SESSION_NAME}" attach -t "${SESSION_NAME}":0.0
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" wait-for -U "command_lock"
else
echo "There is no ${SESSION_NAME} session to connect to."
fi