sending IPFSTRYME message to my $friend

This commit is contained in:
qo-op 2020-12-03 01:30:07 +01:00
parent 07ef6ce428
commit c98fde5028
1 changed files with 28 additions and 21 deletions

View File

@ -13,35 +13,31 @@ ME="${0##*/}"
########################################################################
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! EXIT" && exit 1
########################################################################
[[ ! -f ~/.zen/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
[[ ! -f ~/.zen/secret.dunikey ]] && echo "Missing ~/.zen/secret.dunikey. EXIT" && exit 1
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
[[ $G1PUB == "" ]] && echo "ERROR G1PUB empty !! Please check it..." && exit 1
[[ $G1PUB == "" ]] && echo "ERROR G1PUB empty !! EXIT" && exit 1
########################################################################
# GET NODE disk performance. TODO, publish and use as IPFS repartition
echo "DISK SIZE AVAILABLE & PERFORMANCE TESTING"
[[ -f ~/.zen/test.disk ]] && rm -f ~/.zen/test.disk
diskperf=$(dd if=/dev/zero of=~/.zen/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4)
[[ -f ~/.ipfs/test.disk ]] && rm -f ~/.ipfs/test.disk
diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4)
# echo $diskperf
sizeAvail=$(df -h ~/.ipfs/ | tail -n 1 | awk '{print $4}')
# IPFS LOCAL REPOSITORY for Node Identity G1 + SSB
# IPFS LOCAL REPOSITORY for Node Identity
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
# PUBLISH default "eth" NOT isLAN IP addresses for ./zen/ssb_IPFS_swarm.sh
tryme=$(ipfs id | jq -r .Addresses[] | tail -n 1 )
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "/(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $isLAN ]] && sbotc publish '{"type":"ipfstryme","text":"'"$tryme"'"}'
# find IPFSTRYME public address
echo "ipfstryme" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
for tryme in $(ipfs id | jq -r .Addresses[]);
do
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
done
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
trymev4=$(ipfs id | jq -r .Addresses[] | grep $(hostname -I | cut -f 1 -d ' '))
isLANv4=$(echo $trymev4 | cut -f3 -d '/' | grep -E "/(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ $isLAN && ! $isLANv4 ]] && sbotc publish '{"type":"ipfstryme","text":"'"$trymev4"'"}' && tryme="$trymev4"
trymev6=$(ipfs id | jq -r .Addresses[] | grep $(hostname -I | cut -f 2 -d ' '))
isLANv6=$(echo $trymev6 | cut -f3 -d '/' | grep -E "/(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ $isLAN && $isLANv4 && ! $isLANv6 ]] && sbotc publish '{"type":"ipfstryme","text":"'"$trymev6"'"}' && tryme="$trymev6"
################################
# ADD Cesium+ informations
@ -92,11 +88,11 @@ echo "$G1PUB" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey
# IPFS Node PUBLISH Adresses so Pub can become bootstrap for ${g1author}
ipfs id | jq -r .Addresses[] > ~/.zen/ipfs/.${IPFSNODEID}/Addresses
# IPFS Node PUBLISH AgentVersion & repo.stat
ipfs id | jq -r .AgentVersion > ~/.zen/ipfs/.${IPFSNODEID}/AgentVersion
ipfs repo stat > ~/.zen/ipfs/.${IPFSNODEID}/repo.stat
echo "$tryme" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
echo "$diskperf" > ~/.zen/ipfs/.${IPFSNODEID}/disk.perf
echo $(df ~/.ipfs/ | tail -n 1 | awk '{print $4}') > ~/.zen/ipfs/.${IPFSNODEID}/disk.bytes
@ -105,7 +101,18 @@ IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
###
# TODO GET ALL MY GCHANGE FRIENDS AND SEND THEM my IPFS Address
# GET ALL MY GCHANGE FRIENDS AND SEND THEM my IPFS Address
cd ~/.zen/astroport/zen/cesium-messaging
# GET LIST of issuer(s) who likes me
LIKEIN=$(./jaklis.py like | jq -r '.likes[].issuer')
for friend in $LIKEIN
do
echo "sending IPFSTRYME message to my $friend"
./jaklis.py send -d $friend -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
done
exit 0