From 366031f26e795dbf8ea56c7c86da8720cccb4dec Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 27 Sep 2022 00:09:24 +0200 Subject: [PATCH] ## LAN TO WAN MIGRATION --- ASTROBOT/PLAYER.refresh.sh | 8 +++- ASTROBOT/VOEUX.refresh.sh | 6 +++ tools/Connect_PLAYER_To_Gchange.sh | 65 ++++++++++++++++++++++-------- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/ASTROBOT/PLAYER.refresh.sh b/ASTROBOT/PLAYER.refresh.sh index e2829287..817c9e91 100755 --- a/ASTROBOT/PLAYER.refresh.sh +++ b/ASTROBOT/PLAYER.refresh.sh @@ -39,7 +39,7 @@ for PLAYER in $(ls ~/.zen/game/players/); do DIFF=$(diff ~/.zen/tmp/astro/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html) if [[ $DIFF ]]; then echo "Backup & Upgrade TW local copy..." - cp -f ~/.zen/game/players/$PLAYER/ipfs/moa/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.backup.html + cp -f ~/.zen/game/players/$PLAYER/ipfs/moa/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.backup.html # UNNECESSARY .chain cp ~/.zen/tmp/astro/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html else echo "No change since last Refresh" @@ -83,6 +83,12 @@ for g1wish in $(ls ~/.zen/game/players/$PLAYER/voeux/); do echo $IG1BAR > ~/.zen/game/world/$g1wish/.ig1barre echo "Update new g1barre: /ipfs/$IG1BAR" + ## LAN TO WAN MIGRATION + myIP=$(hostname -I | awk '{print $1}' | head -n 1) + sed -i "s~192.168.199.191~${myIP}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html + echo $myIP > ~/.zen/game/world/$g1wish/.ip + echo "Setting new IP : $myIP" + MOATS=$(date -u +"%Y%m%d%H%M%S%4N") echo "Avancement blockchain TW $PLAYER : $MOATS" cp ~/.zen/game/players/$PLAYER/ipfs/moa/.chain ~/.zen/game/players/$PLAYER/ipfs/moa/.chain.$MOATS diff --git a/ASTROBOT/VOEUX.refresh.sh b/ASTROBOT/VOEUX.refresh.sh index 3d531be0..6460f2a0 100755 --- a/ASTROBOT/VOEUX.refresh.sh +++ b/ASTROBOT/VOEUX.refresh.sh @@ -44,6 +44,12 @@ do ## Replace tube links with downloaded video $MY_PATH/../tools/TUBE.copy.sh ~/.zen/tmp/work/index.html $voeu + ## LAN TO WAN MIGRATION + myIP=$(hostname -I | awk '{print $1}' | head -n 1) + sed -i "s~192.168.199.191~${myIP}~g" ~/.zen/tmp/work/index.html + echo $myIP > ~/.zen/game/world/$voeu/.ip + echo "Setting new IP : $myIP" + echo "DIFFERENCE ?" DIFF=$(diff ~/.zen/tmp/work/index.html ~/.zen/game/world/$voeu/index.html) diff --git a/tools/Connect_PLAYER_To_Gchange.sh b/tools/Connect_PLAYER_To_Gchange.sh index 8547f6c5..7c91c523 100755 --- a/tools/Connect_PLAYER_To_Gchange.sh +++ b/tools/Connect_PLAYER_To_Gchange.sh @@ -27,24 +27,55 @@ $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "http ######################################################################## ######################################################################## -echo "BECOME FRIEND with A_boostrap_nodes.txt" +echo "SCANNING MY GCHANGE FRIENDS" ######################################################################## -#for bootnode in $(cat ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | grep -Ev "#") # remove comments -#do -#if [[ $bootnode != "" ]]; then -# ipfsnodeid=${bootnode##*/} -# g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) -# echo "SENDING STAR TO BOOTSTRAP NODE : $g1node" -# $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" stars -p $g1node -n 1 -# ### DELETE -# # jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" unstars -p $g1node -#fi -#done +################## CHECKING WHO GAVE ME STARS +################## BOOTSTRAP LIKES THEM BACK +################## SEND ipfstryme MESSAGES to FRIENDS +rm -f ~/.zen/tmp/friend_of_mine +## Getting Gchange liking_me list +~/.zen/Astroport.ONE/tools/timeout.sh -t 20 ~/.zen/Astroport.ONE/tools/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' | uniq > ~/.zen/tmp/liking_me + +## Adding RANDOM bootstrap to liking_me list +~/.zen/Astroport.ONE/tools/ipfs_to_g1.py $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#" | rev | cut -d '/' -f 1 | rev | shuf | head -n 1) >> ~/.zen/tmp/liking_me + +for liking_me in $(cat ~/.zen/tmp/liking_me | sort | uniq); +do + [[ "$liking_me" == "" ]] && continue ## Protect from empty line !! + + ipfsnodeid=$(~/.zen/Astroport.ONE/tools/g1_to_ipfs.py $liking_me) + echo "Reading stars.level from Stations IPNS Capsules." + +##### CHECKING IF WE LIKE EACH OTHER (AVOID LIKING MYSELF) + ~/.zen/Astroport.ONE/tools/timeout.sh -t 20 ~/.zen/Astroport.ONE/tools/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me > ~/.zen/tmp/Gstars.json + ## ZOMBIE PROTECTION + [[ "$?" == "0" && ! -s ~/.zen/tmp/Gstars.json ]] && rm -Rf ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me && echo "$liking_me is a ZOMBIE..." && continue + + friend_of_mine=$(cat ~/.zen/tmp/Gstars.json | jq -r '.yours'); + if [[ "$friend_of_mine" != "null" && "$liking_me" != "$G1PUB" ]] + then + # ADD $liking_me TO MY ipfs FRIENDS list + echo "$liking_me is my FRIEND" + mkdir -p ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me + + # REFRESH & PUBLISH stars friends map + stars="$(cat ~/.zen/tmp/Gstars.json | jq -r '.yours.level')" + if [[ "$stars" == "null" || "$stars" == "" ]]; then + rm -Rf ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me + echo "$friend_of_mine NO STAR !! Removing $liking_me" + ## TODO : remove "ipfs pin" in "~/.zen/PIN/" + continue ## REMOVE NO GOOD FRIENDS (no star) + fi + cp ~/.zen/tmp/Gstars.json ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/ && rm -f ~/.zen/tmp/Gstars.json + echo "$stars" > ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/stars.level && echo "***** $stars STARS *****" + + echo "***** Convert $liking_me to ipfsnodeid *****" + ipfsnodeid=$(~/.zen/Astroport.ONE/tools/g1_to_ipfs.py $liking_me) + echo ${ipfsnodeid} > ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/ipfsnodeid + fi + + sleep $((1 + RANDOM % 2)) # SLOW DOWN +done -######################################################################## -# echo 'Creating "ipfstryme" message' -######################################################################## -# ~/.zen/astrXbian/zen/tools/add_externIP_to_ipfstryme.sh -# [[ $(cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr) == "" ]] && echo "IPFS Friendly Swarm Layer rewriting" exit 0