diff --git a/zen/ipfs_SWARM_refresh.sh b/zen/ipfs_SWARM_refresh.sh index 0024a65..4cdca87 100755 --- a/zen/ipfs_SWARM_refresh.sh +++ b/zen/ipfs_SWARM_refresh.sh @@ -56,7 +56,9 @@ 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 +# cp ~/.ipfs/config ~/.ipfs/config.bak +[[ -f ~/.ipfs/config.bak ]] && cp ~/.ipfs/config.bak ~/.ipfs/config +rm ~/.ipfs/config.new # 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); @@ -144,15 +146,10 @@ do echo "## CREATING Peering.Peer entries" ################################################################ Addr=$(echo "$peerline" | rev | cut -d '/' -f 2- | rev ) - IsAlreadythere=$(cat ~/.zen/A_peering_peers.txt | grep $ipfsnodeid) + IsAlreadythere=$(cat ~/.ipfs/config.new | grep $ipfsnodeid) if [[ ! $IsAlreadythere ]]; then 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 - echo "$IsAlreadythere" | jq -c --arg new "$Addr" '.Addrs? += [$new]' >> ~/.zen/A_peering_peers.txt # add new Addrs to previous line - echo "MUST add Addr using jq" + jq '.Peering.Peers? += { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config > ~/.ipfs/config.new # && cp ~/.ipfs/config.new ~/.ipfs/config fi fi else # if [[ "$myfriendpeer" != "" ]];