diff --git a/12345.sh b/12345.sh index f36d3e29..e57c5c06 100755 --- a/12345.sh +++ b/12345.sh @@ -22,7 +22,7 @@ PORT=12345 YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); ## $USER running ipfs LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2) ## SWARM#0 ENTRANCE URL -mkdir -p ~/.zen/tmp/${IPFSNODEID}/ +mkdir -p ~/.zen/game/players/toctoc/ ## CHECK FOR ANY ALREADY RUNNING nc ncrunning=$(ps auxf --sort=+utime | grep -w 'nc -l -p 1234' | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) @@ -74,18 +74,18 @@ while true; do ############### ############### ############### ############### templates/index.http # REPLACE myIP in http response template (fixing next API meeting point) - sed "s~127.0.0.1:12345~$myIP:${PORT}~g" $HOME/.zen/Astroport.ONE/templates/index.http > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.myIP.http - sed -i "s~127.0.0.1~$myIP~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.myIP.http - sed -i "s~:12345~:${PORT}~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.myIP.http - sed -i "s~_IPFSNODEID_~${IPFSNODEID}~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.myIP.http ## NODE PUBLISH HOSTED WHAT'S JSON - sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.myIP.http ## HOSTNAME + sed "s~127.0.0.1:12345~$myIP:${PORT}~g" $HOME/.zen/Astroport.ONE/templates/index.http > ~/.zen/game/players/toctoc/${MOATS}.myIP.http + sed -i "s~127.0.0.1~$myIP~g" ~/.zen/game/players/toctoc/${MOATS}.myIP.http + sed -i "s~:12345~:${PORT}~g" ~/.zen/game/players/toctoc/${MOATS}.myIP.http + sed -i "s~_IPFSNODEID_~${IPFSNODEID}~g" ~/.zen/game/players/toctoc/${MOATS}.myIP.http ## NODE PUBLISH HOSTED WHAT'S JSON + sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/game/players/toctoc/${MOATS}.myIP.http ## HOSTNAME ############### ############### ############### ############### ############################################################################ - ## SERVE LANDING REDIRECT PAGE ~/.zen/tmp/${IPFSNODEID}/${MOATS}.myIP.http on PORT 1234 (LOOP BLOCKING POINT) + ## SERVE LANDING REDIRECT PAGE ~/.zen/game/players/toctoc/${MOATS}.myIP.http on PORT 1234 (LOOP BLOCKING POINT) ############################################################################ - URL=$(cat $HOME/.zen/tmp/${IPFSNODEID}/${MOATS}.myIP.http | nc -l -p 1234 -q 1 | grep '^GET' | cut -d ' ' -f2 | cut -d '?' -f2) + URL=$(cat $HOME/.zen/game/players/toctoc/${MOATS}.myIP.http | nc -l -p 1234 -q 1 | grep '^GET' | cut -d ' ' -f2 | cut -d '?' -f2) ############################################################################ - echo "URL" > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.url ## LOGGING URL + echo "URL" > ~/.zen/game/players/toctoc/${MOATS}.url ## LOGGING URL ############################################################################ start=`date +%s` @@ -97,12 +97,12 @@ while true; do echo "HTTP/1.1 200 OK Server: Astroport Content-Type: text/html; charset=UTF-8 -" > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect ## HTTP 1.1 HEADER + HTML BODY -sed "s~127.0.0.1~$myIP~g" $HOME/.zen/Astroport.ONE/templates/register.html >> ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect -sed -i "s~_IPFSNODEID_~${IPFSNODEID}~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect -sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect +" > ~/.zen/game/players/toctoc/${MOATS}.index.redirect ## HTTP 1.1 HEADER + HTML BODY +sed "s~127.0.0.1~$myIP~g" $HOME/.zen/Astroport.ONE/templates/register.html >> ~/.zen/game/players/toctoc/${MOATS}.index.redirect +sed -i "s~_IPFSNODEID_~${IPFSNODEID}~g" ~/.zen/game/players/toctoc/${MOATS}.index.redirect +sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/game/players/toctoc/${MOATS}.index.redirect - cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & + cat ~/.zen/game/players/toctoc/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & end=`date +%s` echo Execution time was `expr $end - $start` seconds. continue @@ -139,23 +139,24 @@ sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redi ## SAVE "salt" "pepper" DEBUG REMOVE OR PASS ENCRYPT FOR SECURITY REASON echo "PLAYER CREDENTIALS : \"$SALT\" \"$PEPPER\"" - echo "\"$SALT\" \"$PEPPER\"" > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.secret.june + echo "\"$SALT\" \"$PEPPER\"" > ~/.zen/game/players/toctoc/${MOATS}.secret.june # CALCULATING ${MOATS}.secret.key + G1PUB - ${MY_PATH}/tools/keygen -t duniter -o ~/.zen/tmp/${IPFSNODEID}/${MOATS}.secret.key "$SALT" "$PEPPER" - G1PUB=$(cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.secret.key | grep 'pub:' | cut -d ' ' -f 2) + ${MY_PATH}/tools/keygen -t duniter -o ~/.zen/game/players/toctoc/${MOATS}.secret.key "$SALT" "$PEPPER" + G1PUB=$(cat ~/.zen/game/players/toctoc/${MOATS}.secret.key | grep 'pub:' | cut -d ' ' -f 2) [[ ! ${G1PUB} ]] && (echo "ERROR - KEYGEN COMPUTATION DISFUNCTON" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue echo "G1PUB : ${G1PUB}" ## CALCULATING IPNS ADDRESS ipfs key rm ${G1PUB} > /dev/null 2>&1 - rm -f ~/.zen/tmp/${IPFSNODEID}/${MOATS}.${G1PUB}.ipns.key - ${MY_PATH}/tools/keygen -t ipfs -o ~/.zen/tmp/${IPFSNODEID}/${MOATS}.${G1PUB}.ipns.key "$SALT" "$PEPPER" - ASTRONAUTENS=$(ipfs key import ${G1PUB} -f pem-pkcs8-cleartext ~/.zen/tmp/${IPFSNODEID}/${MOATS}.${G1PUB}.ipns.key ) + rm -f ~/.zen/game/players/toctoc/${MOATS}.${G1PUB}.ipns.key + ${MY_PATH}/tools/keygen -t ipfs -o ~/.zen/game/players/toctoc/${MOATS}.${G1PUB}.ipns.key "$SALT" "$PEPPER" + ASTRONAUTENS=$(ipfs key import ${G1PUB} -f pem-pkcs8-cleartext ~/.zen/game/players/toctoc/${MOATS}.${G1PUB}.ipns.key ) echo "ASTRONAUTE TW : http://$myIP:8080/ipns/${ASTRONAUTENS}" echo ################### KEY GEN ################################### + ######################################## ## ARCHIVE TOCTOC WHATS & KEEPS LOGS CLEAN mkdir -p ~/.zen/tmp/toctoc/ @@ -163,11 +164,11 @@ sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redi TTIME=$(echo $ISTHERE | rev | cut -d '.' -f 4 | cut -d '/' -f 1 | rev) if [[ ! $ISTHERE ]]; then echo "WHAT 1ST TOCTOC : $MOATS" - cp ~/.zen/tmp/${IPFSNODEID}/${MOATS}.* ~/.zen/tmp/toctoc/ + cp ~/.zen/game/players/toctoc/${MOATS}.* ~/.zen/tmp/toctoc/ else ## KEEP 1ST CONTACT ONLY - OLDONE=$(ls -t ~/.zen/tmp/${IPFSNODEID}/*.${G1PUB}.ipns.key | tail -n 1) + OLDONE=$(ls -t ~/.zen/game/players/toctoc/*.${G1PUB}.ipns.key | tail -n 1) DTIME=$(echo $OLDONE | rev | cut -d '.' -f 4 | cut -d '/' -f 1 | rev) - [[ $DTIME != $MOATS ]] && rm ~/.zen/tmp/${IPFSNODEID}/$DTIME.* + [[ $DTIME != $MOATS ]] && rm ~/.zen/game/players/toctoc/$DTIME.* fi ## TYPE SLECTION ######################## @@ -176,32 +177,32 @@ sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redi echo "Extracting ${G1PUB} messages..." ~/.zen/Astroport.ONE/tools/timeout.sh -t 3 \ - ${MY_PATH}/tools/jaklis/jaklis.py -k ~/.zen/tmp/${IPFSNODEID}/${MOATS}.secret.key read -n 10 -j > ~/.zen/tmp/${IPFSNODEID}/messin.${G1PUB}.json - [[ ! -s ~/.zen/tmp/${IPFSNODEID}/messin.${G1PUB}.json || $(grep -v -E 'Aucun message à afficher' ~/.zen/tmp/${IPFSNODEID}/messin.${G1PUB}.json) == "True" ]] && echo "[]" > ~/.zen/tmp/${IPFSNODEID}/messin.${G1PUB}.json + ${MY_PATH}/tools/jaklis/jaklis.py -k ~/.zen/game/players/toctoc/${MOATS}.secret.key read -n 10 -j > ~/.zen/game/players/toctoc/messin.${G1PUB}.json + [[ ! -s ~/.zen/game/players/toctoc/messin.${G1PUB}.json || $(grep -v -E 'Aucun message à afficher' ~/.zen/game/players/toctoc/messin.${G1PUB}.json) == "True" ]] && echo "[]" > ~/.zen/game/players/toctoc/messin.${G1PUB}.json ~/.zen/Astroport.ONE/tools/timeout.sh -t 3 \ - ${MY_PATH}/tools/jaklis/jaklis.py -k ~/.zen/tmp/${IPFSNODEID}/${MOATS}.secret.key read -n 10 -j -o > ~/.zen/tmp/${IPFSNODEID}/messout.${G1PUB}.json - [[ ! -s ~/.zen/tmp/${IPFSNODEID}/messout.${G1PUB}.json || $(grep -v -E 'Aucun message à afficher' ~/.zen/tmp/${IPFSNODEID}/messout.${G1PUB}.json) == "True" ]] && echo "[]" > ~/.zen/tmp/${IPFSNODEID}/messout.${G1PUB}.json + ${MY_PATH}/tools/jaklis/jaklis.py -k ~/.zen/game/players/toctoc/${MOATS}.secret.key read -n 10 -j -o > ~/.zen/game/players/toctoc/messout.${G1PUB}.json + [[ ! -s ~/.zen/game/players/toctoc/messout.${G1PUB}.json || $(grep -v -E 'Aucun message à afficher' ~/.zen/game/players/toctoc/messout.${G1PUB}.json) == "True" ]] && echo "[]" > ~/.zen/game/players/toctoc/messout.${G1PUB}.json - echo "Creating messages In/Out JSON ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json" - echo '[' > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json - cat ~/.zen/tmp/${IPFSNODEID}/messin.${G1PUB}.json >> ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json - echo "," >> ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json - cat ~/.zen/tmp/${IPFSNODEID}/messout.${G1PUB}.json >> ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json - echo ']' >> ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json + echo "Creating messages In/Out JSON ~/.zen/game/players/toctoc/${MOATS}.messaging.json" + echo '[' > ~/.zen/game/players/toctoc/${MOATS}.messaging.json + cat ~/.zen/game/players/toctoc/messin.${G1PUB}.json >> ~/.zen/game/players/toctoc/${MOATS}.messaging.json + echo "," >> ~/.zen/game/players/toctoc/${MOATS}.messaging.json + cat ~/.zen/game/players/toctoc/messout.${G1PUB}.json >> ~/.zen/game/players/toctoc/${MOATS}.messaging.json + echo ']' >> ~/.zen/game/players/toctoc/${MOATS}.messaging.json ## ADDING HTTP/1.1 PROTOCOL HEADER echo "HTTP/1.1 200 OK Server: Astroport Content-Type: text/html; charset=UTF-8 -" > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect -cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json >> ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect +" > ~/.zen/game/players/toctoc/${MOATS}.index.redirect +cat ~/.zen/game/players/toctoc/${MOATS}.messaging.json >> ~/.zen/game/players/toctoc/${MOATS}.index.redirect - ### REPONSE=$(cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json | ipfs add -q) + ### REPONSE=$(cat ~/.zen/game/players/toctoc/${MOATS}.messaging.json | ipfs add -q) ### ipfs name publish --allow-offline --key=${PORT} /ipfs/$REPONSE ### echo "SESSION http://$myIP:8080/ipns/$SESSIONNS " - cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & + cat ~/.zen/game/players/toctoc/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & end=`date +%s` echo Execution time was `expr $end - $start` seconds. continue @@ -213,13 +214,13 @@ cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json >> ~/.zen/tmp/${IPFSNODEID} ######################################## if [[ "$TYPE" == "g1pub" && ${arr[7]} == "" ]]; then ## NO EMAIL = REDIRECT TO GCHANGE PROFILE - sed "s~_TWLINK_~https://www.gchange.fr/#/app/user/${G1PUB}/~g" ~/.zen/Astroport.ONE/templates/index.redirect > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect + sed "s~_TWLINK_~https://www.gchange.fr/#/app/user/${G1PUB}/~g" ~/.zen/Astroport.ONE/templates/index.redirect > ~/.zen/game/players/toctoc/${MOATS}.index.redirect ### REPONSE=$(echo https://www.gchange.fr/#/app/user/${G1PUB}/ | ipfs add -q) ### ipfs name publish --allow-offline --key=${PORT} /ipfs/$REPONSE ### echo "SESSION http://$myIP:8080/ipns/$SESSIONNS " - cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & + cat ~/.zen/game/players/toctoc/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & end=`date +%s` echo Execution time was `expr $end - $start` seconds. continue @@ -272,47 +273,51 @@ cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.messaging.json >> ~/.zen/tmp/${IPFSNODEID} echo "OFFICIAL latest online TW... $LIBRA ($YOU)" - [[ $YOU ]] && echo "http://$myIP:8080/ipns/${ASTRONAUTENS} ($YOU)" && ipfs --timeout 12s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.astroindex.html - [[ ! -s ~/.zen/tmp/${IPFSNODEID}/${MOATS}.astroindex.html ]] && echo "$LIBRA/ipns/${ASTRONAUTENS}" && curl -m 12 -so ~/.zen/tmp/${IPFSNODEID}/${MOATS}.astroindex.html "$LIBRA/ipns/${ASTRONAUTENS}" + [[ $YOU ]] && echo "http://$myIP:8080/ipns/${ASTRONAUTENS} ($YOU)" && ipfs --timeout 12s cat /ipns/${ASTRONAUTENS} > ~/.zen/game/players/toctoc/${MOATS}.astroindex.html + [[ ! -s ~/.zen/game/players/toctoc/${MOATS}.astroindex.html ]] && echo "$LIBRA/ipns/${ASTRONAUTENS}" && curl -m 12 -so ~/.zen/game/players/toctoc/${MOATS}.astroindex.html "$LIBRA/ipns/${ASTRONAUTENS}" # DEBUG - # echo "tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'" + # echo "tiddlywiki --load ~/.zen/game/players/toctoc/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'" # echo "cat ~/.zen/tmp/miz.json | jq -r .[].secret" - if [[ -s ~/.zen/tmp/${IPFSNODEID}/${MOATS}.astroindex.html ]]; then - tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion' + if [[ -s ~/.zen/game/players/toctoc/${MOATS}.astroindex.html ]]; then + tiddlywiki --load ~/.zen/game/players/toctoc/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion' OLDIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret) [[ ! $OLDIP ]] && (echo "501 ERROR - SORRY - YOUR TW IS OUT OF SWARM#0 - CONTINUE " | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue # LOCKED TW BECOMING ACTIVE GATEWAY if [[ $OLDIP == "_SECRET_" ]]; then echo "_SECRET_ TW PUSHING TW" ## BECOMING OFFICIAL BECOME R/W TW - sed -i "s~_SECRET_~${myIP}~g" ~/.zen/tmp/${IPFSNODEID}/${MOATS}.astroindex.html + sed -i "s~_SECRET_~${myIP}~g" ~/.zen/game/players/toctoc/${MOATS}.astroindex.html echo "HTTP/1.1 200 OK Server: Astroport Content-Type: text/html; charset=UTF-8 -" > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect - cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.astroindex.html >> ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect - cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & +" > ~/.zen/game/players/toctoc/${MOATS}.index.redirect + cat ~/.zen/game/players/toctoc/${MOATS}.astroindex.html >> ~/.zen/game/players/toctoc/${MOATS}.index.redirect + cat ~/.zen/game/players/toctoc/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & + + ## CREATE $PLAYER IPNS KEY (for next 20h12) + ipfs key import ${PLAYER} -f pem-pkcs8-cleartext ~/.zen/game/players/toctoc/${MOATS}.${G1PUB}.ipns.key + mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa + cp ~/.zen/game/players/toctoc/${MOATS}.astroindex.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html continue fi # ACTIVE GATEWAY [[ $OLDIP != $myIP ]] && TWIP=$OLDIP echo "*********** OFFICIAL LOGIN GOES TO $TWIP" else - (echo "ERROR - NO TW FOUND - ASK FOR VISA" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue + (echo "ERROR - NO TW FOUND - ERROR" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue fi else - echo "***** READER MODE - R/W USE OFFICIAL ***** http://$myIP:1234/?salt=$SALT&pepper=$PEPPER&official=on" + echo "***** READER MODE *****" fi - sed "s~_TWLINK_~http://$TWIP:8080/ipns/${ASTRONAUTENS}~g" ~/.zen/Astroport.ONE/templates/index.redirect > ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect - - ## TODO PATCH _SECRET_ myIP STUFF + sed "s~_TWLINK_~http://$TWIP:8080/ipns/${ASTRONAUTENS}~g" ~/.zen/Astroport.ONE/templates/index.redirect > ~/.zen/game/players/toctoc/${MOATS}.index.redirect ## RESPONDING - cat ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & - echo "HTTP 1.1 PROTOCOL DOCUMENT READY ~/.zen/tmp/${IPFSNODEID}/${MOATS}.index.redirect" + cat ~/.zen/game/players/toctoc/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & + echo "HTTP 1.1 PROTOCOL DOCUMENT READY ~/.zen/game/players/toctoc/${MOATS}.index.redirect" echo "$MOATS -----> PAGE AVAILABLE -----> http://$myIP:${PORT}" + #echo "${ASTRONAUTENS}" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & ## CHECK IF ALREADY EXISTING WHAT diff --git a/ASTROBOT/PLAYER.refresh.sh b/ASTROBOT/PLAYER.refresh.sh index 8805cc25..e7f6fd04 100755 --- a/ASTROBOT/PLAYER.refresh.sh +++ b/ASTROBOT/PLAYER.refresh.sh @@ -14,14 +14,15 @@ ME="${0##*/}" echo "## RUNNING PLAYER.refresh" ## RUNING FOR ALL LOCAL PLAYERS -for PLAYER in $(ls ~/.zen/game/players/); do - [[ $PLAYER == '.current' ]] && continue +for PLAYER in $(ls -t ~/.zen/game/players/); do + [[ $PLAYER == 'toctoc' ]] && echo "toctoc" && continue echo "##################################################################" - echo ">>>>> PLAYER : $PLAYER" + echo ">>>>> PLAYER : $PLAYER >>>>>>>>>>>>> REFRESHING TW STATION" echo "##################################################################" # Get PLAYER wallet amount COINS=$($MY_PATH/../tools/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey balance) echo "+++ WALLET BALANCE _ $COINS (G1) _" + ## DROP IF WALLET IS EMPTY : TODO echo "##################################################################" echo "## GCHANGE+ & Ŋ1 EXPLORATION: Connect_PLAYER_To_Gchange.sh" ${MY_PATH}/../tools/Connect_PLAYER_To_Gchange.sh "$PLAYER" @@ -31,12 +32,13 @@ for PLAYER in $(ls ~/.zen/game/players/); do echo "##################################################################" PSEUDO=$(cat ~/.zen/game/players/$PLAYER/.pseudo 2>/dev/null) + ## REFRESH ASTRONAUTE TW ASTRONAUTENS=$(ipfs key list -l | grep $PLAYER | cut -d ' ' -f1) [[ ! $ASTRONAUTENS ]] && echo "Missing $PLAYER IPNS KEY -- CONTINUE --" && continue - rm -Rf ~/.zen/tmp/astro - mkdir -p ~/.zen/tmp/astro + rm -Rf ~/.zen/tmp/${PLAYER} + mkdir -p ~/.zen/tmp/${PLAYER} myIP=$(hostname -I | awk '{print $1}' | head -n 1) @@ -45,11 +47,11 @@ for PLAYER in $(ls ~/.zen/game/players/); do LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2) echo "$LIBRA/ipns/$ASTRONAUTENS" echo "http://$myIP:8080/ipns/$ASTRONAUTENS ($YOU)" - [[ $YOU ]] && ipfs --timeout 12s cat /ipns/$ASTRONAUTENS > ~/.zen/tmp/astro/index.html \ - || curl -m 12 -so ~/.zen/tmp/astro/index.html "$LIBRA/ipns/$ASTRONAUTENS" + [[ $YOU ]] && ipfs --timeout 12s cat /ipns/$ASTRONAUTENS > ~/.zen/tmp/${PLAYER}/index.html \ + || curl -m 12 -so ~/.zen/tmp/${PLAYER}/index.html "$LIBRA/ipns/$ASTRONAUTENS" ## PLAYER TW IS ONLINE ? - if [ ! -s ~/.zen/tmp/astro/index.html ]; then + if [ ! -s ~/.zen/tmp/${PLAYER}/index.html ]; then echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" echo "ERROR_PLAYERTW_TIMEOUT : /ipns/$ASTRONAUTENS" @@ -65,39 +67,38 @@ for PLAYER in $(ls ~/.zen/game/players/); do ############################################################# ## CHECK IF myIP IS ACTUAL OFFICIAL GATEWAY - tiddlywiki --load ~/.zen/tmp/astro/index.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion' + tiddlywiki --load ~/.zen/tmp/${PLAYER}/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) - # FIRST TIME PLAYER TW USING GATEWAY - [[ $OLDIP == "_SECRET_" ]] && echo "_SECRET_ TW" && sed -i "s~_SECRET_~${myIP}~g" ~/.zen/tmp/astro/index.html && OLDIP=$myIP - # AM I MANAGING TW - [[ $OLDIP != $myIP ]] && echo "ASTRONAUTE GATEWAY IS http://$OLDIP:8080/ipns/$ASTRONAUTENS - BYPASSING -" && continue + [[ ! $OLDIP ]] && (echo "501 ERROR - SORRY - TW IS BROKEN - CONTINUE " + # WHO IS OFFICIAL TW GATEWAY + [[ $OLDIP != $myIP ]] && ipfs key rm ${PLAYER} && echo "*** OFFICIAL GATEWAY : http://$OLDIP:8080/ipns/$ASTRONAUTENS - BYPASSING - ***" && continue ############################################################# # VOEUX.create.sh ############################################################## ## SPECIAL TAG "voeu" => Creation G1Voeu (G1Titre) makes AstroBot TW G1Processing ############################################################## - $MY_PATH/VOEUX.create.sh ~/.zen/tmp/astro/index.html $PLAYER + $MY_PATH/VOEUX.create.sh ~/.zen/tmp/${PLAYER}/index.html $PLAYER # VOEUX.refresh.sh ############################################################## ## RUN ASTROBOT G1Voeux SUBPROCESS (SPECIFIC AND STANDARD Ŋ1 SYNC) ############################################################## - $MY_PATH/VOEUX.refresh.sh ~/.zen/tmp/astro/index.html $PLAYER + $MY_PATH/VOEUX.refresh.sh ~/.zen/tmp/${PLAYER}/index.html $PLAYER ############################################################## #################### # LOCKING TW : myIP becomes _SECRET_ - sed -i "s~${myIP}~_SECRET_~g" ~/.zen/tmp/astro/index.html + sed -i "s~${myIP}~_SECRET_~g" ~/.zen/tmp/${PLAYER}/index.html #################### ## ANY CHANGES ? ############################################################## - DIFF=$(diff ~/.zen/tmp/astro/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html) + DIFF=$(diff ~/.zen/tmp/${PLAYER}/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html) if [[ $DIFF ]]; then echo "DIFFERENCE DETECTED !! " echo "Backup & Upgrade TW local copy..." - cp ~/.zen/tmp/astro/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html + cp ~/.zen/tmp/${PLAYER}/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html else echo "No change since last Refresh..." fi