2020-11-30 19:21:30 +01:00
|
|
|
#!/bin/bash
|
|
|
|
########################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
2020-12-03 15:51:47 +01:00
|
|
|
# Version: 2020.12.03
|
2020-11-30 19:21:30 +01: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-12-06 20:10:35 +01:00
|
|
|
# Connect to IPFS peers with bidirectionnal "like" (gchange friends)
|
|
|
|
#
|
|
|
|
|
2020-11-30 19:21:30 +01:00
|
|
|
########################################################################
|
|
|
|
# \\///
|
|
|
|
# qo-op
|
|
|
|
############# '$MY_PATH/$ME'
|
|
|
|
########################################################################
|
|
|
|
# ex: ./'$ME'
|
2020-12-02 15:18:00 +01:00
|
|
|
# GET GCHANGE FRIENDS AND FIND THEIR IPFS ID TO "ipfs swarm connect" THEM
|
2020-11-30 19:21:30 +01:00
|
|
|
########################################################################'
|
|
|
|
|
2020-12-03 15:51:47 +01:00
|
|
|
## TODO : Beware of liking_me FLOOD & Invite $liking_me people to my #Swarm0
|
2020-11-30 19:21:30 +01:00
|
|
|
|
|
|
|
########################################################################
|
2020-12-02 15:18:00 +01:00
|
|
|
## CONNECT GLOBAL "ipfs.io" ## DANGEROUS DATA LEAK only for short time...
|
2020-11-30 19:21:30 +01:00
|
|
|
########################################################################
|
|
|
|
# ADD ipfs.io public bootstrap into your swarm peers
|
|
|
|
# RUN: cat ~/.zen/astroport/ipfs.swarm.ipfs.io | ipfs swarm connect
|
|
|
|
# SOON ipfs swarm peers will GROW!!! YOU ARE VSIBLE !!!
|
|
|
|
# RUN: sudo systemctl restart ipfs # GOES BACK TO SWARM0
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# 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
|
2020-12-06 21:29:37 +01:00
|
|
|
isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
|
|
|
|
[[ ! $isIPFSRunning ]] && echo "ERROR! ipfs daemon is not running. EXIT" && exit 1
|
2020-11-30 19:21:30 +01:00
|
|
|
########################################################################
|
|
|
|
|
2020-12-03 13:37:24 +01:00
|
|
|
# Force Strict #swarm0 !!?
|
|
|
|
# ipfs bootstrap rm --all
|
2020-12-06 20:10:35 +01:00
|
|
|
echo "" > ~/.zen/A_allow_ip.txt
|
|
|
|
echo "" > ~/.zen/A_liking_me_NO_ipfstryme.txt # contains "friends" with no "ipfstryme" incoming message
|
2020-12-03 13:37:24 +01:00
|
|
|
liking_me_count=0
|
|
|
|
friend_of_mine_count=0
|
2020-11-30 19:21:30 +01:00
|
|
|
########################################################################
|
2020-12-03 13:37:24 +01:00
|
|
|
# Let's look for Friends and "IPFS swarm connect" with them
|
2020-11-30 19:21:30 +01:00
|
|
|
########################################################################
|
2020-12-04 14:45:56 +01:00
|
|
|
cd ~/.zen/astroport/zen/jaklis
|
2020-12-03 15:51:47 +01:00
|
|
|
# 1. Get Gchange "liking_me" people list
|
2020-12-03 13:37:24 +01:00
|
|
|
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
|
|
|
|
do
|
2020-12-06 21:29:37 +01:00
|
|
|
# Check if my like is reverse
|
2020-12-03 13:37:24 +01:00
|
|
|
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
|
2020-12-06 21:29:37 +01:00
|
|
|
|
2020-12-03 16:52:07 +01:00
|
|
|
[[ $friend_of_mine != null ]] && echo "Connect to my friend $liking_me" && friend_of_mine_count=$((friend_of_mine_count+1)) && ipfsadd=0 \
|
2020-12-05 00:50:22 +01:00
|
|
|
&& for peer in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content');
|
2020-12-06 21:29:37 +01:00
|
|
|
# 2. Searching "ipfstryme" message from friend_of_mine
|
2020-12-03 13:37:24 +01:00
|
|
|
do
|
2020-12-08 04:28:45 +01:00
|
|
|
ip=$(echo "$peer" | awk -F '/' '{print $3}') && [[ $ip == "" ]] && continue || echo "Adding $ip to ~/.zen/A_allow_ip.txt"
|
2020-12-06 21:29:37 +01:00
|
|
|
# Fill a file with friend of mine ip
|
|
|
|
echo $ip >> ~/.zen/A_allow_ip.txt
|
|
|
|
# Get its ipfsnodeid
|
2020-12-06 20:10:35 +01:00
|
|
|
ipfsnodeid=$(echo "$peer" | awk -F '/' '{print $7}')
|
2020-12-06 21:29:37 +01:00
|
|
|
|
|
|
|
# 3. ADD liking_me friend_of_mine to my swarm & bootstrap
|
2020-12-05 00:50:22 +01:00
|
|
|
ipfs swarm connect $peer;
|
|
|
|
ipfs bootstrap add $peer;
|
2020-12-06 21:29:37 +01:00
|
|
|
|
2020-12-03 13:37:24 +01:00
|
|
|
ipfsadd=$((ipfsadd+1))
|
|
|
|
done;
|
2020-12-06 20:10:35 +01:00
|
|
|
|
2020-12-08 04:28:45 +01:00
|
|
|
if [[ $friend_of_mine != null ]]; then
|
2020-12-08 04:08:29 +01:00
|
|
|
if [[ $ipfsadd == 0 ]]; then
|
|
|
|
# Friend of mine with no ipfstryme message (did not install astroport)
|
2020-12-08 04:28:45 +01:00
|
|
|
echo "No 'ipfstryme' message... from $liking_me"
|
2020-12-08 04:08:29 +01:00
|
|
|
echo "$liking_me" >> ~/.zen/A_liking_me_NO_ipfstryme.txt
|
2020-12-08 04:28:45 +01:00
|
|
|
|
2020-12-08 04:08:29 +01:00
|
|
|
else
|
|
|
|
nbmessage=0
|
|
|
|
for messageid in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq -r '.id')
|
|
|
|
do
|
|
|
|
nbmessage=$((nbmessage+1))
|
2020-12-08 04:28:45 +01:00
|
|
|
[ $nbmessage -gt 1 ] && echo "Delete OLD 'ipfstryme' messages from $liking_me" && ./jaklis.py delete -i $messageid
|
2020-12-08 04:08:29 +01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
2020-12-06 20:10:35 +01:00
|
|
|
|
2020-12-06 21:29:37 +01:00
|
|
|
# Automatic level_1 like from oasis.astroport.com (TODO add other default bootstrap)
|
|
|
|
# TODO get $g1pub from ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey ??
|
|
|
|
# [[ $friend_of_mine == null && $G1PUB == "2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS" ]] && ./jaklis.py like -p $g1pub -s 1
|
2020-12-08 04:28:45 +01:00
|
|
|
echo "__________________________________________"
|
2020-12-06 20:10:35 +01:00
|
|
|
liking_me_count=$((liking_me_count+1))
|
2020-12-08 04:28:45 +01:00
|
|
|
|
2020-11-30 19:21:30 +01:00
|
|
|
done
|
2020-12-03 16:03:40 +01:00
|
|
|
|
2020-11-30 19:21:30 +01:00
|
|
|
|
2020-12-03 16:10:29 +01:00
|
|
|
echo "####################################################
|
|
|
|
I have $friend_of_mine_count friends amoung $liking_me_count liking me people
|
2020-12-03 13:37:24 +01:00
|
|
|
__________________________________________
|
2020-12-03 16:10:29 +01:00
|
|
|
My actual #SWARM0"
|
2020-11-30 19:21:30 +01:00
|
|
|
ipfs swarm peers
|
2020-12-03 16:10:29 +01:00
|
|
|
echo "__________________________________________"
|
|
|
|
echo
|
2020-12-06 20:10:35 +01:00
|
|
|
## Send message to
|
|
|
|
for line in $(cat ~/.zen/A_liking_me_NO_ipfstryme.txt | uniq); do
|
|
|
|
echo "Liking ME, but no ipfstryme received..."
|
|
|
|
echo "cd ~/.zen/astroport/zen/jaklis"
|
2020-12-08 13:44:45 +01:00
|
|
|
echo "./jaklis.py send -d $line -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'"
|
2020-12-03 16:03:40 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
cd -
|