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##*/}"
|
2020-04-28 00:39:00 +02:00
|
|
|
|
2020-04-13 19:12:20 +02:00
|
|
|
########################################################################
|
|
|
|
# \\///
|
|
|
|
# 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)
|
|
|
|
########################################################################
|
|
|
|
|
2020-05-08 03:46:37 +02:00
|
|
|
mkdir -p ~/.zen/ipfs_swarm
|
2020-04-13 19:12:20 +02:00
|
|
|
echo '
|
|
|
|
___ _ _ __ __ _ _ _ _ _ _ __
|
|
|
|
| |_)|_(_ (_\ //\ |_)|\/| |_)|_|_|_)|_(_ |_|
|
|
|
|
_|_| | __) __)\/\//--\| \| | | \|_| | \|___)| |
|
|
|
|
|
|
|
|
'
|
2020-04-28 00:23:54 +02:00
|
|
|
echo "I am $ipfsnodeid"
|
2020-05-04 03:19:27 +02:00
|
|
|
|
2020-05-08 03:46:37 +02:00
|
|
|
## CHANNELS SWARM INDEX COPY PROCEDURE
|
|
|
|
## SIGNAL ~/.zen/g1sms_wallets TODO
|
|
|
|
|
|
|
|
# NOW PUBLISH ~/.zen/ipfs/ to SWARM
|
2020-05-04 16:30:43 +02:00
|
|
|
[[ ! -d ~/.zen/ipfs ]] && echo "ERROR : ~/.zen/ipfs/ NOT FOUND" && exit 1
|
2020-04-28 00:12:24 +02:00
|
|
|
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
|
|
|
|
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
|
2020-05-08 03:46:37 +02:00
|
|
|
ipfs get --output=~/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
|
2020-04-28 00:09:16 +02:00
|
|
|
|
2020-04-13 19:12:20 +02:00
|
|
|
count=1
|
2020-05-08 03:46:37 +02:00
|
|
|
# Search for All peers Nodes. ## TODO: To be changed when Swarm is too big or not expanding
|
|
|
|
#for id in $(ls -d ~/.zen/ipfs_swarm/.Qm* | cut -d '.' -f 3); # Alternative search...
|
2020-04-13 19:12:20 +02:00
|
|
|
for id in $(ipfs swarm peers | awk -F '/' '{print $7}');
|
|
|
|
do
|
|
|
|
count=$((count+1))
|
2020-05-08 03:46:37 +02:00
|
|
|
# FULL REFRESH (allow deletion, for DEV period)
|
|
|
|
# TODO: COMMENT TO LOWER DISK USAGE
|
|
|
|
echo "Refreshing ~/.zen/ipfs_swarm/.$id ($count)"
|
|
|
|
rm -Rf ~/.zen/ipfs_swarm/.$id
|
|
|
|
$MY_PATH/tools/timeout.sh -t 30 ipfs get --output=~/.zen/ipfs_swarm/ /ipns/$id
|
2020-04-13 19:12:20 +02:00
|
|
|
done
|
|
|
|
|
2020-05-13 20:37:04 +02:00
|
|
|
# TODO: TASK treatment.
|