ssb_SURVEY_contact.sh & pictures - listening Brian Eno

This commit is contained in:
qo-op 2020-03-24 20:53:44 +01:00
parent 8d8ec64bf6
commit 9906d7c203
16 changed files with 2852 additions and 89 deletions

View File

@ -32,7 +32,8 @@ scuttlebutt() {
ssbSERVER=$(which ssb-server)
[[ $ssbSERVER == "" ]] && echo "Check your ssb-server install... Cannot find it !!" && exit 1
# If exists backup ~/.ssb to ~/.ssb_$USER SSB (one time only !)
[[ -d ~/.ssb ]] && [[ ! -d ~/.ssb_$USER ]] && mv ~/.ssb ~/.ssb_$USER
[[ -d ~/.ssb_$USER ]] && echo "BACKUP already existing... ~/.ssb_$USER !!! Manual check please..." && exit 1
[[ -d ~/.ssb ]] && [[ ! -d ~/.ssb_$USER ]] && mv ~/.ssb ~/.ssb_$USER
# CREATE ~/.ssb_astroport
[[ ! -d ~/.ssb_astroport ]] && mkdir -p ~/.ssb_astroport && cd ~/.ssb_astroport
# if exists, keep ~/.ssb_$USER/secret*
@ -48,18 +49,10 @@ scuttlebutt() {
nodename=$(cat /etc/hostname)
extension=$(echo $nodename | cut -d '.' -f 2)
echo "
_ __ __ _
_ _ .__|_o _ (_ (_ |_)
(_(_)| || |(_| __)__)|_)
_|
$nodename
"
if [[ $extension == $nodename ]]; then
nodename=$nodename.home
nodename=$nodename.local
# LOCAL
cat > ~/.ssb/config <<EOF
{
@ -132,17 +125,22 @@ EOF
fi
echo "
_ __ __ _
_ _ .__|_o _ (_ (_ |_)
(_(_)| || |(_| __)__)|_)
_|
$nodename
echo "DOES SCUTTELBUTT IS RUNNING?"
echo "ADD $HOME/.zen/run-ssb_$nodename.sh & TO YOUR '/etc/rc.local' !!! "
"
echo '
__ _ _ _ _
(_ |_|_)\ /|_|_) o._ o_|_
__)|_| \ \/ |_| \ || || |_ ... SCUTTLEBUTT ... OK?
'
echo "DOES SCUTTELBUTT IS RUNNING FINE?"
echo "Then add $HOME/.zen/run-ssb_$nodename.sh & TO YOUR '/etc/rc.local' !!! "
}
$@

BIN
doc/images/astroport5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

BIN
doc/images/astroport6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
doc/images/astroport7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

2602
doc/images/astroport7.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

BIN
torrengo Executable file

Binary file not shown.

117
zen/ ssb_SURVEY_contact.sh Normal file
View File

@ -0,0 +1,117 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.21
# 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'
# SURVEY SSB contact from "invite" is happening in feed
######################################################################## _ _ _ _ _
(_)_ ____ _(_) |_ __ _| |_(_) ___ _ __
| | _ \ \ / / | __/ _| | __| |/ _ \| _ \
| | | | \ V /| | || (_| | |_| | (_) | | | |
|_|_| |_|\_/ |_|\__\__|_|\__|_|\___/|_| |_| contact SURVEY
# An New Station wants to Join our ASTROPORT !!
DETECT in SSB feed messages "type": "contact", "autofollow": true
LIKE
{
"key": "%jVQewn0/ey0tfdvYCjYXJqVivaaZ6NpeUL9xK5QeGTk=.sha256",
"value": {
"previous": "%ilrZ+8CvMXpu09LWh75Uq37j7lVJnoxTvipyooRSjpg=.sha256",
"sequence": 3,
"author": "@S2KB1zRQNAuCRs1vW08c+63+0gjI2egDj4pjUUrt+dw=.ed25519",
"timestamp": 1585068288462,
"hash": "sha256",
"content": {
"type": "contact",
"following": true,
"autofollow": true,
"contact": "@t/giTDc0EtzdPQGC7iAAzgzVOkFo++XZRvzOOlqgX1c=.ed25519"
},
"signature": "kXsFqfBGqZXZApf7UANDYlqnwLXuGdWFbMMofljBOp4dNGc4dAv+P2hzK3XV/jPT8a1u7PHIraJASugR1NCLCw==.sig.ed25519"
},
"timestamp": 1585068290213
}
'
self=$(sbotc whoami | jq -r .id) || exit 1
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"about", "about": "'"$self"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1)
messages=$(sbotc messagesByType '{"type":"contact","old":false}')
while read -r msg
do
autofollow=$(printf %s "$msg" | jq .value.content.autofollow)
[[ ! $autofollow ]] && echo "I am NOT the Pub" && printf %s "$msg" | jq && continue
echo "
___ _______ _ _ ___ ____
| |\ |\ /| ||_ / / \|\ || /\ / |
_|_| \| \/_|_ ||_ \_\_/| \||/--\\_ | RECEIVED
"
author=$(printf %s "$msg" | jq -r .value.author)
g1author=$(printf %s "$msg" | jq -r .value.author | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
# Crypt, ipfs store, send
if [[ -f ~/.ipfs/swarm.key ]]; then
ipfsnodeid=$(ipfs id -f='<id>\n')
mkdir -p ~/.zen/ipfs/.${ipfsnodeid}/INVITE/${g1author}
file=~/.zen/ipfs/.${ipfsnodeid}/INVITE/${g1author}/ipfs_swarm.key.crypt
$MY_PATH/tools/natools.py encrypt -p ${g1author} -i ~/.ipfs/swarm.key -o ${file}
cp ${file} ~/.zen/ipfs/.${ipfsnodeid}/INVITE/${g1author}/
echo "
$author
\|/ \|/ \|/
/|\ /|\ /|\ cyphering swarmkey
IPFS
~/.zen/ipfs/.${ipfsnodeid}/INVITE/${g1author}/ipfs_swarm.key.crypt
"
name=${file##*/}
id="$(sbotc blobs.add < "$file")"
type="$(file -b --mime-type "$file")"
size="$(wc -c < "$file")"
echo "
______ _ _ _ ____ __ _ _ _ _ _____
/\ (_ ||_)/ \|_)/ \|_)|__(_\ //\ |_)|\/||/|_\_/ |_)/ \(_ |
/--\__) || \\_/| \_/| \| __)\/\//--\| \| ||\|_ | | \_/__) |
SSB
#astroport-swarmkey
[$name]($id)
TO.SSB_${author}
TO.G1_${g1author}
+++
FROM.SSB_${self_name}
FROM.G1_${g1self}
FROM.IPFS_${ipfsnodeid}
"
sbotc publish '{"type":"post","text":"#astroport-swarmkey = ['"$name"']('"$id"') TO.SSB_${author} TO.G1_${g1author} +++ FROM.SSB_${self_name} FROM.G1_${g1self} FROM.IPFS_${ipfsnodeid}","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
fi
done < <(printf '%s\n' "$messages")

View File

@ -14,7 +14,7 @@ echo "
############# $ME DELAY
########################################################################
# ex: ./$ME \"10 days\"
# SCAN NODE G1 Wallet FOR ZEN Command received (or pending) TX/IN
# Survey Node G1 Wallet for TX/IN Commands in received comments ...
########################################################################
_(_)_ _(_)_
@ -30,13 +30,9 @@ echo "
"
DELAY="$1"
# GET DUNITER SERVER
DUNITERNODE=$($MY_PATH/tools/duniter_getnode.sh)
DUNITERURL="https://$DUNITERNODE"
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "$USER Please Install IPFS !!" && exit 1
[[ ! -d ~/.zen/scan ]] && mkdir -p ~/.zen/scan # Directory containing G1 blockchain incoming TX Scan
[[ ! -d ~/.zen/g1_TX_inputs ]] && mkdir -p ~/.zen/g1_TX_inputs # Directory containing G1 blockchain incoming TX Scan
[[ ! -d ~/.zen/ipfs ]] && mkdir -p ~/.zen/ipfs # Directory where NODE store SMS & other Channel Wallets
[[ ! -d ~/.zen/ipfs_swarm ]] && mkdir -p ~/.zen/ipfs_swarm # Local copy of all SSB friends IPFS Nodes published ipfs
@ -65,90 +61,126 @@ fi
#########################################################################################################
echo "======================================="
echo "IPFS ID = $IPFSNODEID"
echo "IPFS Node ID = $IPFSNODEID
__
_|_ _ _| |\ | _ _| _ /__/| _.|| __|_
(_| |(/_(_|< | \|(_)(_|(/_ \_| | \/\/(_|||(/_|_
last $DELAY
G1 PUBKEY = $NODE_G1PUBKEY
SSB ID = %$ssbpub.ed25519
echo "G1 PUBKEY = $NODE_G1PUBKEY"
echo "SSB ID = %$ssbpub.ed25519"
echo "
#############################################
# GET G1 WALLET AMOUNT
silkaj -p $DUNITERNODE balance $NODE_G1PUBKEY
#############################################"
echo "Checking G1 Wallet received TX ($DELAY) for ZEN command"
"
# PREPARE TIMESTAMP LIMITS
TIMEBEFORE=$(date -u --date="-$DELAY" +"%s")
TIMESTAMP=$(date -u +"%s")
# GET DUNITER SERVER
DUNITERNODE=$($MY_PATH/tools/duniter_getnode.sh)
DUNITERURL="https://$DUNITERNODE"
# GET BLOCKCHAIN TX FOR TIME WINDOW
curl -s $DUNITERURL/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP > ~/.zen/g1zen.scan
## TODO VERIFY ~/.zen/g1zen.scan IS GOOD ?! AND RETRY... $DUNITERURL
curl -s $DUNITERURL/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP > /tmp/g1_TX.scan.txt
TXNB=$(cat /tmp/g1_TX.scan.txt | wc -l)
###########################################################################
# TX EXTRACTION
###########################################################################
# MORE THAN MINUTE DELAY = history.received
echo "
$DUNITERURL/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP
___
|\/ ._ ._ _ |_ _ ._
G1 |/\ | ||_|| | ||_)(/_|
$TXNB
"
# Choose between "history.received" OR "history.pending" depending on DELAY
if [[ $DELAYUNIT != "minutes" && $DELAYUNIT != "minute" ]]; then
# HOW MANY TX DO WE HAVE...
TXnb=$(cat ~/.zen/g1zen.scan | jq '.history.received[].hash' | wc -l)
TXnb=$(cat /tmp/g1_TX.scan.txt | jq '.history.received[].hash' | wc -l)
echo "DETECTED $TXnb TX... Checking TX/IN..."
# PARSE $TXnb TX
line=1
while [[ $line -le $TXnb ]]; do
# GET TX HASH
TXhash=$(cat ~/.zen/g1zen.scan | jq -r '.history.received[].hash' | head -n $line | tail -n 1 )
TXhash=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.received[].hash' | head -n $line | tail -n 1 )
# IT IS A NEW TX?
if [[ ! -f ~/.zen/scan/zen.$TXhash ]]; then
if [[ ! -f ~/.zen/g1_TX_inputs/zen.$TXhash ]]; then
# GET LAST TX ISSUER
ISSUER=$(cat ~/.zen/g1zen.scan | jq -r '.history.received[].issuers[0]' | head -n $line | tail -n 1)
ISSUER=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.received[].issuers[0]' | head -n $line | tail -n 1)
[[ $ISSUER == $NODE_G1PUBKEY ]] && ((line++)) && continue ## TX/OUT CONTINUE
echo $ISSUER > ~/.zen/scan/zen.$TXhash
echo $ISSUER > ~/.zen/g1_TX_inputs/zen.$TXhash
# GET OUTPUTS AND MAKE ZEN=G1*100 SUM
ZEN=$(cat ~/.zen/g1zen.scan | jq -r '.history.received[].outputs[]' | grep $NODE_G1PUBKEY | head -n $line | tail -n 1 | cut -d ':' -f 1)
ZEN=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.received[].outputs[]' | grep $NODE_G1PUBKEY | head -n $line | tail -n 1 | cut -d ':' -f 1)
# GET COMMENT
COMMENT=$(cat ~/.zen/g1zen.scan | jq '.history.received' | jq -r '.[].comment' | head -n $line | tail -n 1)
COMMENT=$(cat /tmp/g1_TX.scan.txt | jq '.history.received' | jq -r '.[].comment' | head -n $line | tail -n 1)
# echo "TX-IN $ISSUER => $NODE_G1PUBKEY"
echo "TX/IN :: $ZEN ZEN from $ISSUER :: $COMMENT ($TXhash)"
echo "Received $ZEN Zen From $ISSUER :: $COMMENT :: ($TXhash)"
CMD=$(echo "$COMMENT" | awk '{print toupper($1)}')
echo "
___ ___ _ ___ _
|\/ | |\ ||_)| || |_) _ _ _ o _ _|
|/\ _|_| \|| |_|| | \(/_(_(/_|\/(/_(_|
"
# Add CASE for received here
###### CREATE ZEN VALUE IN IPFS #########
[[ $CMD == "ZEN" ]] && $MY_PATH/zen_MAKE.sh $ZEN $TXhash $ISSUER
############################################
# else
# STILL OLD TX
# [[ $TXhash != "" ]] && echo "ALREADY TREATED TX/IN: $TXhash $(cat ~/.zen/scan/zen.$TXhash)" || echo "NO TX"
fi
((line++))
done
else
# MINUTE DELAY = pending // TODO: if anyone succeed in passing $VAR in jq command, both can be merge...
# MINUTE DELAY = pending // TODO: if anyone succeed in passing $VAR in jq command, both can be merge...
# HOW MANY TX DO WE HAVE...
TXnb=$(cat ~/.zen/g1zen.scan | jq '.history.pending[].hash' | wc -l)
TXnb=$(cat /tmp/g1_TX.scan.txt | jq '.history.pending[].hash' | wc -l)
echo "DETECTED $TXnb TX... Checking TX/IN..."
# PARSE $TXnb TX
line=1
while [[ $line -le $TXnb ]]; do
TXhash=$(cat ~/.zen/g1zen.scan | jq -r '.history.pending[].hash' | head -n $line | tail -n 1)
TXhash=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.pending[].hash' | head -n $line | tail -n 1)
# IT IS A NEW TX/IN?
if [[ ! -f ~/.zen/scan/zen.$TXhash ]]; then
if [[ ! -f ~/.zen/g1_TX_inputs/zen.$TXhash ]]; then
# GET LAST RX ISSUER
ISSUER=$(cat ~/.zen/g1zen.scan | jq -r '.history.pending[].issuers[0]' | head -n $line | tail -n 1)
ISSUER=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.pending[].issuers[0]' | head -n $line | tail -n 1)
[[ $ISSUER == $NODE_G1PUBKEY ]] && ((line++)) && continue ## TX/OUT CONTINUE
echo $ISSUER > ~/.zen/scan/zen.$TXhash
echo $ISSUER > ~/.zen/g1_TX_inputs/zen.$TXhash
# GET OUTPUTS AND MAKE ZEN SUM
ZEN=$(cat ~/.zen/g1zen.scan | jq -r '.history.pending[].outputs[]' | grep $NODE_G1PUBKEY | head -n $line | tail -n 1 | cut -d ':' -f 1)
ZEN=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.pending[].outputs[]' | grep $NODE_G1PUBKEY | head -n $line | tail -n 1 | cut -d ':' -f 1)
# GET COMMENT
COMMENT=$(cat ~/.zen/g1zen.scan | jq '.history.pending' | jq -r '.[].comment' | head -n $line | tail -n 1)
COMMENT=$(cat /tmp/g1_TX.scan.txt | jq '.history.pending' | jq -r '.[].comment' | head -n $line | tail -n 1)
# echo "TX-IN $ISSUER => $NODE_G1PUBKEY"
echo "TX/IN :: $ZEN ZEN from $ISSUER :: $COMMENT ($TXhash)"
echo "Pending $ZEN Zen From $ISSUER :: $COMMENT :: ($TXhash)"
CMD=$(echo "$COMMENT" | awk '{print toupper($1)}')
echo "
___ ___ _ ___ _
|\/ | |\ ||_)| || |_)_ ._ _|o._ _
|/\ _|_| \|| |_|| | (/_| |(_||| |(_|
_|
"
# Add CASE for pending here
###### CREATE ZEN VALUE IN IPFS #########
[[ $CMD == "ZEN" ]] && $MY_PATH/zen_MAKE.sh $ZEN $TXhash $ISSUER
############################################
# else
# STILL OLD TX
# [[ $TXhash != "" ]] && echo "ALREADY TREATED TX/IN: $TXhash $(cat ~/.zen/scan/zen.$TXhash)" || echo "NO TX"
fi
((line++))
done
fi
echo "FINISH"
echo "FINISH !
__
|\ | _ _| _ /__/| \ /_.|| __|_ |_ _.| _.._ _ _
| \|(_)(_|(/_ \_| | \/\/(_|||(/_|_ |_)(_||(_|| |(_(/_
silkaj -p $DUNITERNODE balance $NODE_G1PUBKEY
"
exit 0

0
zen/sbot_SURVEY.sh Normal file
View File

View File

@ -33,26 +33,21 @@ echo '
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_info
########################################################################
ipfs_process_owner=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
[[ "$ipfs_process_owner" == "" ]] && echo "ERROR ipfs daemon is not running !!" && exit 1
ipfsnodeid=$(ipfs id -f='<id>\n')
[[ $ipfsnodeid == "" ]] && echo "ERROR missing IPFS Node id !!" && exit 1
[[ $ipfsnodeid == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
########################################################################
ssbpub=$(sbotc whoami 2>/dev/null | jq -r .id)
[[ $ssbpub == "" ]] && echo "ERROR ssb-server NOT running !!" && exit 1
[[ $ssbpub == "" ]] && echo "ERROR ssb-server NOT running !! Please check it..." && exit 1
########################################################################
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
########################################################################
# IPFS Node Identity G1 + SSB
# IPFS LOCAL REPOSITORY for Node Identity G1 + SSB
mkdir -p ~/.zen/ipfs/.$ipfsnodeid/G1SSB
echo "
/\ |_ _ _|_
/--\|_)(_)|_||_ G1SSB Identity
"
## PUBLISH ABOUT MESSAGE
##############################################
# IMAGE of G1 wallet QRCode
@ -65,12 +60,41 @@ id="$(sbotc blobs.add < $qrcodefile)"
type="$(file -b --mime-type $qrcodefile)"
size="$(wc -c < $qrcodefile)"
# Publish ABOUT document
echo "
/\ |_ _ _|_
/--\|_)(_)|_||_ : PUBLISH to SSB feed...
$ssbpub
-- sbot publish --
"
sbot publish --type about --about $ssbpub --description "Welcome to [Astroport](https://astroport.com) G1SSB/IPFS Station [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid)" --name "$USER@$(cat /etc/hostname)" --image "$id"
# Publish QRCode FILE post
echo "
_ _
/ \|_) _ _ _| _
\_X| \ (_(_)(_|(/_
$g1pub
~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.qrcode.png
-- sbotc publish --
"
sbotc publish '{"type":"post","text":"[G1SSB_Wallet.png]('"$id"')\nUse https://cesium.app to send payment.\nComment your transaction with '"'Zen'"' to order ZenTag...","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
echo "
___ _ _ __
| |_)|_(_ _. _| _|
_|_| | __) (_|(_|(_| ... and ... Node IPNS publish
~/.zen/ipfs
ipfs ls /ipns/$NODEIPNS
"
# COPY NODE G1SSB ID to IPFS
echo "$ssbpub" > ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_ssb.whoami
echo "$g1pub" > ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.pubkey
@ -79,28 +103,18 @@ IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
echo "
$ssbpub
$g1pub
____ _ _ _ __
/ ___/ |___ ___| |__ (_)_ __ / _|___
| | _| / __/ __| |_ \ | | _ \| |_/ __|
| |_| | \__ \__ \ |_) | | | |_) | _\__ \
\____|_|___/___/_ __/ |_| __/|_| |___/
|_|
~/.zen/ipfs/.$ipfsnodeid/G1SSB
ipfs ls /ipns/$NODEIPNS
_ _ _ _ _
(_)_ ____ _(_) |_ __ _| |_(_) ___ _ __
| | _ \ \ / / | __/ _| | __| |/ _ \| _ \
| | | | \ V /| | || (_| | |_| | (_) | | | |
|_|_| |_|\_/ |_|\__\__|_|\__|_|\___/|_| |_|
$(sbotc invite.create 1)
# This INVITE is to be sent an 'Astroport Station' willing to Join our IPFS Swarm.
# see 'ssb_SURVEY_contact.sh' for commands executed...
"
INVITE=$(sbotc invite.create 1)
echo $INVITE
# This INVITE is to be sent an "Astroport Station" willing to Join our IPFS Swarm.
# sbot_SURVEY.sh is taking care of checking SSB Feed for commands...