From 19acebbda3b23525c61060b3ecbdaa30d6c06a59 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 6 Dec 2022 23:52:18 +0100 Subject: [PATCH] port detect --- G1BILLETS.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/G1BILLETS.sh b/G1BILLETS.sh index ed26673..62ee320 100755 --- a/G1BILLETS.sh +++ b/G1BILLETS.sh @@ -103,10 +103,8 @@ else ################################################################################ ## MAKE IT A NETWORK MICRO SERVICE -- PORTS : INPUT=33101 OUTPUT=33102 ############## CLEAN START DEAMON MODE ### - pidportinuse=$(ps axf --sort=+utime | grep -w "nc -l -p 33101" | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) + pidportinuse=$(ps axf --sort=+utime | grep -w "nc -l -p 33101" | grep -v -E 'color=auto|grep' | awk '{gsub(/^ +| +$/,"")} {print $0}' | tail -n 1 | cut -d " " -f 1) [[ $pidportinuse ]] && kill -9 $pidportinuse && echo "KILLING 33101 $pidportinuse" - pidportinuse=$(ps axf --sort=+utime | grep -w "nc -l -p 33102" | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) - [[ $pidportinuse ]] && kill -9 $pidportinuse && echo "KILLING NOT COLLECTED THREAD $pidportinuse" ##################################################################### myIP=$(hostname -I | awk '{print $1}' | head -n 1) isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") @@ -180,12 +178,15 @@ while true; do echo "CURL : $CURL" ZFILE=$(echo "$LOG" | tail -n 1) -( # FIND JPG or PDF FILE_NAME="$(basename "${ZFILE}")" EXT="${FILE_NAME##*.}" BSIZE=$(du -b "${ZFILE}" | awk '{print $1}' | tail -n 1) + pidportinuse=$(ps axf --sort=+utime | grep -w "nc -l -p 33102" | grep -v -E 'color=auto|grep' | awk '{gsub(/^ +| +$/,"")} {print $0}' | tail -n 1 | cut -d " " -f 1) + [[ $pidportinuse ]] && kill -9 $pidportinuse && echo "KILLING NOT COLLECTED THREAD $pidportinuse" + +( # SEND BACK TO HTTP 33102 echo 'HTTP/1.1 200 OK Access-Control-Allow-Origin: *