astroport/zen/ssb_IPFS_swarm.sh

60 lines
2.8 KiB
Bash
Raw Normal View History

2020-04-27 23:26:51 +02:00
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
2020-04-27 23:32:49 +02:00
# Version: 2020.04.27
2020-04-27 23:26:51 +02:00
# 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 02:38:20 +02:00
2020-04-27 23:26:51 +02:00
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
2020-04-28 02:38:20 +02:00
# GET SSB FRIENDS AND FIND THEIR IPFS ID TO "ipfs swarm connect" THEM
2020-04-27 23:26:51 +02:00
########################################################################'
########################################################################
# 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)
########################################################################
echo '
#####
#### #### ##### # # # ##### ###### ####
# # # # # # # # # #
#### #### ##### ##### # # # ##### ####
# # # # # # ##### # #
# # # # # # # # # # # #
#### #### ##### ####### # # # ####
2020-04-28 14:27:25 +02:00
Get ipfs addresses from SSB friends and add to bootstrap & swarm peers'
2020-04-27 23:26:51 +02:00
# GET /tmp/ssb-friends.json to choose SWARM peers
self=$(sbotc whoami | jq -r .id)
sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"contact"}}}}]}' | jq -r '.value?.content?.contact' > /tmp/ssb-friends.json || rm -f /tmp/ssb-friends.json
2020-04-28 02:38:20 +02:00
# SSB FRIENDS ARE "swarm connected"
2020-04-27 23:26:51 +02:00
for SSBFRIEND in $(cat /tmp/ssb-friends.json); do
#
### GET SSB "ipfstryme" message type !!!
2020-04-28 02:44:20 +02:00
TRYME=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$SSBFRIEND"'", "content":{"type":"ipfstryme"}}}}]}' | jq -r .value?.content?.text | tail -n 1)
2020-04-28 14:27:25 +02:00
[[ $TRYME ]] && ipfs swarm connect $TRYME && ipfs bootstrap add $TRYME
2020-04-28 14:29:01 +02:00
# Modify ipfs swarm peers and bootstrap related to ssb friends
2020-04-27 23:26:51 +02:00
done
2020-04-28 02:12:48 +02:00
# All memorized IPFS Nodes are swarm connected (again?)
2020-04-28 02:44:20 +02:00
#for IPFSNODEADDR in $(cat ~/.zen/ipfs_swarm/.Qm*/tryme.addr); do
# ipfs swarm connect $IPFSNODEADDR
2020-04-28 02:12:48 +02:00
# Renew ipfs_swarm knows ...
2020-04-28 02:44:20 +02:00
#done