From ac9aefd33162441ce9a33760da6492da81f3552c Mon Sep 17 00:00:00 2001 From: Jakub Fojt Date: Sat, 4 Jul 2020 23:36:23 +0200 Subject: [PATCH] Always keep alive when SSH sessions active --- autoshutdown.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/autoshutdown.sh b/autoshutdown.sh index c62ab99..184e571 100755 --- a/autoshutdown.sh +++ b/autoshutdown.sh @@ -54,6 +54,12 @@ server_responsive() { n_logins="$(w -h | wc -l)" echo "$(date) [$n_logins logins]" +if [ "$n_logins" -gt 0 ]; then + echo "Keep alive as there are active ssh sessions" + empty_reset + exit 0 +fi + if tmux_running; then : #echo "Tmux running" else @@ -65,9 +71,10 @@ fi if server_responsive; then n_players=$(mcstatus localhost json | json_parse player_count) echo "Server responsive. $n_players players online" - if [ "$n_players" -gt 0 ] || [ "$n_logins" -gt 0 ]; then - # Keep alive if players or ssh sessions active + if [ "$n_players" -gt 0 ]; then + # Keep alive as players are online empty_reset + exit 0 else empty_incr exit 1