From c10983f2de9f50c6f4710945d25a00f96f012863 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Mon, 2 Sep 2024 09:44:13 +0200 Subject: [PATCH] Fix ping error in OMR-Tracker-server --- omr-tracker/files/bin/omr-tracker-server | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/omr-tracker/files/bin/omr-tracker-server b/omr-tracker/files/bin/omr-tracker-server index efdcf26181..a5aefb65ea 100755 --- a/omr-tracker/files/bin/omr-tracker-server +++ b/omr-tracker/files/bin/omr-tracker-server @@ -32,9 +32,11 @@ _ping_server() { -c 1 \ -q \ "${host}" 2>&1 - ) && echo "$ret" | grep -sq " 0% packet loss" && { + ) + loss=$(echo "$ret" | awk '/packet loss/ {gsub("%","");print $6}' | tr -d '\n') + if [ -n "$loss" ] && [ "$loss" != "100" ]; then server_ping=true - } + fi } _ping_server_intf() { @@ -49,9 +51,10 @@ _ping_server_intf() { -I "$intf" \ "${host}" 2>&1 ) - [ -n "$ret" ] && echo "$ret" | grep -sq " 0% packet loss" && { + loss=$(echo "$ret" | awk '/packet loss/ {gsub("%","");print $6}' | tr -d '\n') + if [ -n "$loss" ] && [ "$loss" != "100" ]; then server_ping=true - } + fi k=$((k+1)) sleep "${intervaltries}" done