## LAN TO WAN MIGRATION

This commit is contained in:
fred 2022-09-27 00:09:24 +02:00
parent b8181ae260
commit 366031f26e
3 changed files with 61 additions and 18 deletions

View File

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

View File

@ -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)

View File

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