getting Peering.Peers from "ipfs_swarm" and restart ipfs every 6h
This commit is contained in:
parent
4607e7ba3d
commit
85e241fd12
|
@ -229,7 +229,7 @@ fi
|
|||
# REFRESHing MEDIAKEY / ZenTAG nano DHTs => Zen File ECONOMY wallet cycle
|
||||
if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || "$timebar" == "03:03" || $(($runtime % 720)) == 0 || $runtime == 12 ]]; then
|
||||
# At 03:03 and every 12h runtime restarting IPFS daemon
|
||||
[[ "$timebar" == "03:03" || $(($runtime % 720)) == 0 ]] && [[ -f /etc/sudoers.d/systemctl ]] && sudo systemctl restart ipfs && exit 0
|
||||
[[ "$timebar" == "03:03" || $(($runtime % 360)) == 0 ]] && [[ -f /etc/sudoers.d/systemctl ]] && sudo systemctl restart ipfs && exit 0
|
||||
[[ "$timebar" == "03:03" || $(($runtime % 720)) == 0 ]] && [[ ${YOU} == "xbian" ]] && sudo service ipfs restart && exit 0
|
||||
|
||||
#### Refresh & publish MEDIAKEYs
|
||||
|
|
|
@ -32,17 +32,22 @@ echo $(date)
|
|||
########################################################################
|
||||
# Let's look for Friends and "IPFS swarm connect" with them
|
||||
########################################################################
|
||||
# 1. Get Gchange "liking_me" people list (made by gchange_INIT.sh)
|
||||
[[ ! -f /tmp/liking_me ]] && ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me.try && [ ! -s /tmp/liking_me.try ] && cp /tmp/liking_me.try /tmp/liking_me && rm /tmp/liking_me.try
|
||||
|
||||
for liking_me in $(cat /tmp/liking_me | sort | uniq);
|
||||
# Check liking_me station in my swarm FRIENDS
|
||||
for swarm_frof in $(ls ~/.zen/ipfs_swarm/.*/FRIENDS/$G1PUB/stars.level | cut -d '/' -f 6 | cut -d '.' -f 2); ## FROM IPFS
|
||||
do
|
||||
liking_me=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $swarm_frof)
|
||||
do_I_like=$(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$liking_me)
|
||||
# Get Gchange "liking_me" people list (made by gchange_INIT.sh)
|
||||
# [[ ! -f /tmp/liking_me ]] && ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me.try && [ ! -s /tmp/liking_me.try ] && cp /tmp/liking_me.try /tmp/liking_me && rm /tmp/liking_me.try
|
||||
#for liking_me in $(cat /tmp/liking_me | sort | uniq); ## FROM GCHANGE
|
||||
#do
|
||||
[[ "$liking_me" == "" || "$liking_me" == "$G1PUB" ]] && continue
|
||||
# DE TOUS CEUX QUI M'AIMENT JE VAIS LIRE LES MESSAGES pour collecter leurs ipfstryme vers ~/.zen/A_swarm_map.txt
|
||||
# SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt
|
||||
# Check if my like is reverse
|
||||
liking_me_count=$((liking_me_count+1))
|
||||
|
||||
echo ">>>>>> CHECKING liking_me n° $liking_me_count "
|
||||
## IPFS WAY TO DO IT (LESS STRESS ON GCHANGE)
|
||||
rm /tmp/ipfstryme.$liking_me
|
||||
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $liking_me)
|
||||
|
@ -50,7 +55,7 @@ do
|
|||
ipfs --timeout=30s cat /ipns/$ipfsnodeid/.$ipfsnodeid/tryme.addr > /tmp/ipfstryme.$liking_me
|
||||
|
||||
if [[ ! -f /tmp/ipfstryme.$liking_me ]]; then
|
||||
echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me"
|
||||
echo ": READING 'ipfstryme' message from $liking_me"
|
||||
## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message
|
||||
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me
|
||||
fi
|
||||
|
|
|
@ -37,7 +37,7 @@ do
|
|||
# Try to ping my friend OR continue
|
||||
ipfs --timeout=10s ping -n 3 /p2p/$ipfsnodeid || continue
|
||||
|
||||
echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
|
||||
echo "REFRESHING Friend /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
|
||||
ipfs --timeout=90s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
|
||||
[[ -f /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && cat /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid || echo "NO ZUID"
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ ipfs bootstrap > /tmp/ipfs_swarm_peers
|
|||
ipfs swarm peers >> /tmp/ipfs_swarm_peers
|
||||
|
||||
rm ~/.zen/A_peering_peers.txt
|
||||
cp ~/.ipfs/config ~/.ipfs/config.bak
|
||||
|
||||
# for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq); ## TODO ACTIVATE IN DEFCON 4
|
||||
for ipfsnodeid in $(cat ~/.zen/ipfs_swarm/.*/tryme.addr | grep -o '[^/]*$' | sort | uniq);
|
||||
|
@ -145,7 +146,8 @@ do
|
|||
Addr=$(echo "$peerline" | rev | cut -d '/' -f 2- | rev )
|
||||
IsAlreadythere=$(cat ~/.zen/A_peering_peers.txt | grep $ipfsnodeid)
|
||||
if [[ ! $IsAlreadythere ]]; then
|
||||
echo '{ "ID": "'$ipfsnodeid'", "Addrs": ["'$Addr'"] }' >> ~/.zen/A_peering_peers.txt
|
||||
echo '{ "ID": "'$ipfsnodeid'", "Addrs": [] }' >> ~/.zen/A_peering_peers.txt
|
||||
jq '.Peering.Peers? += { "ID": "'$ipfsnodeid'", "Addrs": [] }' ~/.ipfs/config > ~/.ipfs/config.new && cp ~/.ipfs/config.new ~/.ipfs/config
|
||||
else
|
||||
####### ICI SE CONSTRUIT LA LISTE PEERING.PEERS conservée par IPFS
|
||||
cat ~/.zen/A_peering_peers.txt | grep -Ev $ipfsnodeid > ~/.zen/A_peering_peers.txt # remove old line
|
||||
|
|
Loading…
Reference in New Issue