From f4ba59aa9b0d5a38c72a652158a12db32eb7a107 Mon Sep 17 00:00:00 2001 From: CeciliaKelley33Mm Date: Tue, 8 Oct 2024 14:52:35 +0700 Subject: [PATCH] make the server stop countdown show the message every 10 seconds --- loop.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/loop.sh b/loop.sh index 59d5620..b0bb567 100755 --- a/loop.sh +++ b/loop.sh @@ -107,9 +107,17 @@ check() { cd /mnt/globalData/minecraft - docker compose exec minecraft rcon-cli broadcast The server is stopping in 30 seconds. Please leave the server. + timeLeft=30 - sleep 30 + while [ $timeLeft -gt 0 ]; do + if [ $(($timeLeft % 10)) -eq 0 ]; then + docker compose exec minecraft rcon-cli broadcast The server is stopping in $timeLeft seconds. Please leave the server. + fi + + sleep 1 + + timeLeft=$((timeLeft - 1)) + done # not stopping the server would cause problems # like world files aren't latest or even file corruptions