From 1ae04ca2357c076b6d1b2b2dd65d54cc353dbe7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20L=C3=B6sche?= Date: Thu, 4 Mar 2021 17:08:26 +0100 Subject: [PATCH] Move idle check to common --- common | 9 +++++++++ valheim-updater | 9 +++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common b/common index b1d1788..e10c89a 100644 --- a/common +++ b/common @@ -92,6 +92,15 @@ ensure_permissions() { } +server_is_idle() { + if timeout 3 tcpdump udp port "$SERVER_PORT" -n -s 84 -c 1 > /dev/null 2>&1; then + return 1 + else + return 0 + fi +} + + check_lock() { local pidfile local predecessor_pid diff --git a/valheim-updater b/valheim-updater index 560d8d7..25ad6c7 100755 --- a/valheim-updater +++ b/valheim-updater @@ -117,13 +117,14 @@ is_idle() { debug "Valheim updater was just started - skipping connected players check" return 0 fi - if timeout 3 tcpdump udp port "$SERVER_PORT" -n -s 84 -c 1 > /dev/null 2>&1; then - debug "Players connected to Valheim server - skipping update check" - return 1 - else + if server_is_idle; then debug "No players connected to Valheim server" return 0 + else + debug "Players connected to Valheim server - skipping update check" + return 1 fi + fi return 0 }