astroport/zen/ipfs_SWARM_refresh.sh

56 lines
2.3 KiB
Bash
Raw Normal View History

2020-04-13 19:12:20 +02:00
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.24
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# SYNC IPFS SWARM PEERS SHARED DATA .Qm****
########################################################################'
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_info
########################################################################
ipfsnodeid=$(ipfs id -f='<id>\n')
[[ $ipfsnodeid == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
########################################################################
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
########################################################################
mkdir -p "~/.zen/ipfs_swarm"
echo '
___ _ _ __ __ _ _ _ _ _ _ __
| |_)|_(_ (_\ //\ |_)|\/| |_)|_|_|_)|_(_ |_|
_|_| | __) __)\/\//--\| \| | | \|_| | \|___)| |
'
2020-04-28 00:09:16 +02:00
# REFRESH SELF NODE PUBLISHING
ipfs add -rHq ~/.zen/ipfs
ipfs name publish --quieter /ipfs/$IWALLETS
2020-04-13 19:12:20 +02:00
# GET IPNS published wallets from ALL SWARM NODES ## TODO: IF NODES are MISSING, check ./wallets_swarm/.QmNODES...
2020-04-13 19:18:21 +02:00
ipfs get --output=$HOME/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
2020-04-13 19:12:20 +02:00
count=1
# Search for All peers Nodes. ## TODO: To be changed when Swarm is too big or not expendanding
2020-04-19 13:14:47 +02:00
#for id in ./ipfs_swarm/.Qm*/; # Alternative search
2020-04-13 19:12:20 +02:00
for id in $(ipfs swarm peers | awk -F '/' '{print $7}');
do
count=$((count+1))
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
echo "Refreshing ~/.zen/ipfs_swarm/.$id"
2020-04-13 19:18:21 +02:00
rm -Rf $HOME/.zen/ipfs_swarm/.$id
2020-04-19 13:14:47 +02:00
$MY_PATH/tools/timeout.sh -t 30 ipfs get --output=$HOME/.zen/ipfs_swarm/ /ipns/$id
2020-04-13 19:12:20 +02:00
done