Skip to content

Commit

Permalink
Move idle check to common
Browse files Browse the repository at this point in the history
  • Loading branch information
lloesche committed Mar 4, 2021
1 parent 3e92261 commit 1ae04ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions common
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions valheim-updater
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 1ae04ca

Please sign in to comment.