BEtter Network balance

This commit is contained in:
fred 2022-12-06 23:11:06 +01:00
parent e5c5afbbaa
commit 5ec75b6c89
1 changed files with 11 additions and 8 deletions

View File

@ -108,6 +108,9 @@ 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])/")
[[ $isLAN ]] && HNAME="http://g1billet.localhost" || HNAME="http://$(hostname)"
pidportinuse=$(ps axf --sort=+utime | grep -w "nc -l -p 33102" | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 2)
[[ $pidportinuse ]] && kill -9 $pidportinuse && echo "KILLING NOT COLLECTED THREAD $pidportinuse"
HTTPWELLCOME='HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
@ -117,7 +120,7 @@ Content-Type: text/html; charset=UTF-8
<!DOCTYPE html><html>
<head>
<title>[Astroport] G1BILLET MICRO SERVICE - 33101 - 33102 -</title>
<title>[G1BILLET] HTTP MICRO SERVICE - 33101 - 33102 -</title>
<meta http-equiv="refresh" content="30; url='$HNAME':33102" />
<style>
#countdown { display: flex; justify-content: center; align-items: center; color: #0e2c4c; font-size: 20px; width: 60px; height: 60px; background-color: #e7d9fc; border-radius: 50%;}
@ -174,6 +177,7 @@ while true; do
echo "CURL : $CURL"
ZFILE=$(echo "$LOG" | tail -n 1)
(
# FIND JPG or PDF
FILE_NAME="$(basename "${ZFILE}")"
EXT="${FILE_NAME##*.}"
@ -189,16 +193,15 @@ Cache-Control: public
Content-Transfer-Encoding: Binary
Content-Length:'${BSIZE}'
Content-Disposition: attachment; filename='${FILE_NAME}'
' > ${MY_PATH}/tmp/http.33102
' > ${MY_PATH}/tmp/http.${UNIQID}
cat ${ZFILE} >> ${MY_PATH}/tmp/http.33102
echo "GET IT : http://g1billet.localhost:33102"
cat ${MY_PATH}/tmp/http.33102 | nc -l -p 33102 -q 1 > /dev/null 2>&1
echo "SERVED"
cat ${ZFILE} >> ${MY_PATH}/tmp/http.${UNIQID}
cat ${MY_PATH}/tmp/http.${UNIQID} | nc -l -p 33102 -q 1 > /dev/null 2>&1
echo "GOT ${UNIQID} : http://g1billet.localhost:33102"
rm -f "${ZFILE}"
rm -f "${MY_PATH}/tmp/http.33102"
rm -f "${MY_PATH}/tmp/http.${UNIQID}"
) &
done