port detect

This commit is contained in:
fred 2022-12-06 23:52:18 +01:00
parent 3ac3ef7f36
commit 19acebbda3
1 changed files with 5 additions and 4 deletions

View File

@ -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: *