瀏覽代碼

adapted listener matching for components to be more reliable

Michael Honkoop 1 周之前
父節點
當前提交
630745c205
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      localchecks/groupwise.sh

+ 6 - 6
localchecks/groupwise.sh

@@ -11,7 +11,7 @@
 # v1.2:
 # - started refining the script to a more modern bash-style
 # v1.3:
-# - adapted debug-output
+# - adapted debug-output to go to stderr
 #
 # Current active version of the script
 SCRIPT_VERSION=1.3
@@ -43,7 +43,7 @@ if [[ "$gwMTA" -eq 1 ]]
 then
     if [[ "$debug" -eq 1 ]]
     then
-        echo "DEBUG: $SERVICE gwMTA is enabled in config, checking for the process."
+        echo "DEBUG: $SERVICE gwMTA is enabled in config, checking for the process." >&2
     fi
     gwMTAProcess=$(pgrep -x gwmta)
     if [[ -n "$gwMTAProcess" ]]
@@ -52,7 +52,7 @@ then
         then
             echo "DEBUG:We found a $SERVICE gwMTA process ID: $gwMTAProcess" >&2
         fi
-        gwMTAListener=$(ss -lpn | grep "$gwMTAProcess" |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'| sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g') 
+        gwMTAListener=$(ss -lpn | grep -F "pid=$gwMTAProcess," |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'| sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g') 
         if [[ -n "$gwMTAListener" ]]
         then
             if [[ "$debug" -eq 1 ]]
@@ -91,7 +91,7 @@ then
         then
             echo "DEBUG:We found a $SERVICE gwPOA process ID: $gwPOAProcess" >&2
         fi
-        gwPOAListener=$(ss -lpn | grep "$gwPOAProcess" |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' )
+        gwPOAListener=$(ss -lpn | grep -F "pid=$gwPOAProcess" |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' )
         if [[ -n "$gwPOAListener" ]]
         then
             if [[ "$debug" -eq 1 ]]
@@ -124,7 +124,7 @@ then
     gwIAProcess=$(pgrep -x gwia)
     if [[ -n "$gwIAProcess" ]]
     then
-        gwIAListener=$(ss -lpn | grep "$gwIAProcess" |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
+        gwIAListener=$(ss -lpn | grep -F "pid=$gwIAProcess" |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
         if [[ -n "$gwIAListener" ]]
         then
             if [[ "$debug" -eq 1 ]]
@@ -155,7 +155,7 @@ then
     then
         echo "DEBUG:We found a $SERVICE gwAdmin process ID: $gwAdminProcess"
     fi
-    gwAdminListener=$(ss -lpn| grep "$gwAdminProcess" | awk '{print $5}' | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed 's/^::ffff://' | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
+    gwAdminListener=$(ss -lpn| grep -F "pid=$gwAdminProcess" | awk '{print $5}' | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed 's/^::ffff://' | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
     if [[ -n "$gwAdminListener" ]]
     then
         if [[ "$debug" -eq 1 ]]