From bc4c734e7a8ddf958ef87f9418fb0b848cd9e0ae Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 7 Oct 2022 02:16:53 +0200 Subject: [PATCH] WAITING WITH SELF REDIRECT 12345 --- 12345.sh | 28 +++++++++++++++++++++++----- templates/index.http | 4 ++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/12345.sh b/12345.sh index 46ce7293..9ccc7667 100755 --- a/12345.sh +++ b/12345.sh @@ -17,7 +17,7 @@ MOATS=$(date -u +"%Y%m%d%H%M%S%4N") IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) ## CHECK FOR ANY ALREADY RUNNING nc -ncrunning=$(ps auxf --sort=+utime | grep -w nc | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) +ncrunning=$(ps auxf --sort=+utime | grep -w 'nc -l -p 1234' | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) [[ $ncrunning ]] && echo "already running" && exit 1 myIP=$(hostname -I | awk '{print $1}' | head -n 1) @@ -40,7 +40,11 @@ while true; do arr=(${URL//[=&]/ }) echo "PARAM : ${arr[0]} = ${arr[1]} & ${arr[2]} = ${arr[3]} & ${arr[4]} = ${arr[5]}" +####################################### +### WAITING WITH SELF REDIRECT +rm ~/.zen/tmp/index.redirect ################################################################################################### +while [[ ! -f ~/.zen/tmp/index.redirect && ! $(ps auxf --sort=+utime | grep -w 'nc -l -p 12345' | grep -v -E 'color=auto|grep') ]]; do cat $HOME/.zen/tmp/myIP.http | nc -l -p 12345 -q 1; done & ################################################################################################### if [[ ${arr[0]} == "email" ]]; then @@ -225,9 +229,17 @@ while true; do tiddlywiki --load ~/.zen/tmp/TW/index.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion' OLDIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret) - # myIP replacement - sed -i "s~_SECRET_~$myIP~g" ~/.zen/tmp/TW/index.html - sed -i "s~$OLDIP~$myIP~g" ~/.zen/tmp/TW/index.html + ## + if [[ ! d ~/.zen/game/players/$PLAYER/ipfs/moa ]]; then + echo "MISSING ASTRONAUT VISA" + echo "ASKING TO $OLDIP" + + mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa + fi + + # myIP replacement + sed -i "s~_SECRET_~$myIP~g" ~/.zen/tmp/TW/index.html + sed -i "s~$OLDIP~$myIP~g" ~/.zen/tmp/TW/index.html cp ~/.zen/tmp/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html @@ -257,7 +269,9 @@ while true; do # Injection TWLINK dans template de redirection. sed "s~_TWLINK_~$TWLINK~g" ~/.zen/Astroport.ONE/templates/index.redirect > ~/.zen/tmp/index.redirect - ## Lancement one shot http server + + ## Attente cloture WAITING 12345. Puis Lancement one shot http server + while [[ $(ps auxf --sort=+utime | grep -w 'nc -l -p 12345' | grep -v -E 'color=auto|grep') ]]; do sleep 0.5; done cat ~/.zen/tmp/index.redirect | nc -l -p 12345 -q 1 & ################################################################################################### @@ -281,6 +295,10 @@ while true; do [[ ${arr[2]} == "" ]] && continue + if [[ ${arr[2]} == "TX" ]]; then + echo "ASK FOR VISA TRANSFER FROM " + fi + fi ################################################################################################### diff --git a/templates/index.http b/templates/index.http index d778c22f..0f8f5c7e 100644 --- a/templates/index.http +++ b/templates/index.http @@ -5,13 +5,13 @@ Content-Type: text/html; charset=UTF-8 - +

ASTROPORT

Astronaute

- +