astroport/zen/ssb_INIT.sh

150 lines
6.0 KiB
Bash
Raw Normal View History

2020-03-21 05:02:16 +01:00
#!/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
2020-03-22 05:41:24 +01:00
############# '$MY_PATH/$ME'
2020-03-21 05:02:16 +01:00
########################################################################
# ex: ./'$ME'
2020-04-19 11:30:03 +02:00
# Initialize G1SSB + SSB About + IPFS Node publish
2020-03-21 05:02:16 +01:00
########################################################################
o__ __o __o o__ __o o__ __o o__ __o
/v v\ __|> /v v\ /v v\ <| v\
/> <\ | /> <\ /> <\ / \ <\
o/ <o> _\o____ _\o____ \o/ o/
<| _\__o__ | \_\__o__ \_\__o__ |__ _<|
\\ | < > \ \ | \
\ / | \ / \ / <o> /
o o o o o o o | o
<\__ __/> __|>_ <\__ __/> <\__ __/> / \ __/>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# [ASTROPORT](https://astroport.com)
########################################################################
'
2020-03-29 15:44:01 +02:00
2020-03-23 19:07:37 +01:00
########################################################################
2020-03-24 01:20:10 +01:00
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_info
2020-03-23 19:07:37 +01:00
########################################################################
2020-03-24 01:20:10 +01:00
ipfsnodeid=$(ipfs id -f='<id>\n')
[[ $ipfsnodeid == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
2020-03-23 19:07:37 +01:00
########################################################################
2020-03-22 04:45:20 +01:00
ssbpub=$(sbotc whoami 2>/dev/null | jq -r .id)
[[ $ssbpub == "" ]] && echo "ERROR ssb-server NOT running !! Please check it..." && exit 1
2020-03-24 01:20:10 +01:00
########################################################################
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
2020-04-15 04:37:01 +02:00
[[ $g1pub == "" ]] && echo "ERROR g1pub empty !! Please check it..." && exit 1
2020-03-24 01:20:10 +01:00
########################################################################
2020-03-22 04:45:20 +01:00
# IPFS LOCAL REPOSITORY for Node Identity G1 + SSB
2020-03-24 01:20:10 +01:00
mkdir -p ~/.zen/ipfs/.$ipfsnodeid/G1SSB
# PUBLISH ipfs informations
2020-04-28 02:38:20 +02:00
sbotc publish '{"type":"ipfsnodeid","text":"'"$ipfsnodeid"'"}'
sbotc publish '{"type":"ipfstryme","text":"'"$(ipfs id | jq -r .Addresses[] | tail -n 1)"'"}'
2020-03-22 04:45:20 +01:00
# ADD Cesium+ informations
# GET CESIUM+ geoPoint DATA (TODO install , load balance CesiumPod?)
CESIUM="https://g1.data.le-sou.org"
geopointlat=$(curl -s ${CESIUM}/user/profile/${g1pub} | jq '._source.geoPoint.lat')
[[ $geopointlat != null ]] && sbotc publish '{"type":"cesium_geoPoint.lat","text":"'"$geopointlat"'"}'
geopointlon=$(curl -s ${CESIUM}/user/profile/${g1pub} | jq '._source.geoPoint.lon')
[[ $geopointlon != null ]] && sbotc publish '{"type":"cesium_geoPoint.lon","text":"'"$geopointlon"'"}'
# GET Cesium+ Avatar image
curl -s ${CESIUM}/user/profile/${g1pub} | jq '._source.avatar._content' | sed 's/\"//g' | base64 -d > "/tmp/avatar.png"
2020-03-21 05:02:16 +01:00
## PUBLISH ABOUT MESSAGE
##############################################
# IF AVATAR not png take IMAGE of G1 wallet QRCode
if [[ ! $(file "/tmp/avatar.png" | grep 'PNG') ]]; then
qrcodefile=~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.qrcode.png
qrencode -s 5 -o $qrcodefile "$g1pub"
else
qrcodefile=/tmp/avatar.png
fi
2020-03-24 01:20:10 +01:00
# Prepare QRCode File for SSB
2020-03-21 05:02:16 +01:00
name=${qrcodefile##*/}
id="$(sbotc blobs.add < $qrcodefile)"
type="$(file -b --mime-type $qrcodefile)"
size="$(wc -c < $qrcodefile)"
2020-03-24 01:20:10 +01:00
echo "
2020-03-24 01:20:10 +01:00
/\ |_ _ _|_
/--\|_)(_)|_||_ : PUBLISH to SSB feed...
2020-03-21 05:02:16 +01:00
$ssbpub
2020-03-21 05:02:16 +01:00
-- sbot publish --
"
2020-04-28 04:00:17 +02:00
sbot publish --type about --about $ssbpub --description "[Astroport Node](https://astroport.com) [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid) - Wallet $g1pub - Use your KEY ~/.ssb/secret.dunikey in [Cesium](https://cesium.app)" --name "Station $USER@$(cat /etc/hostname)" --image "$id"
2020-03-22 04:45:20 +01:00
echo "
_ _
/ \|_) _ _ _| _
2020-04-28 04:00:17 +02:00
\_X| \ (_(_)(_|(/_ ! AVATAR
2020-03-22 04:45:20 +01:00
2020-03-24 01:20:10 +01:00
$g1pub
~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.qrcode.png
2020-03-24 03:10:28 +01:00
-- sbotc publish --
"
2020-04-28 04:00:17 +02:00
[[ ! $(file "/tmp/avatar.png" | grep 'PNG') ]] && sbotc publish '{"type":"post","text":"[G1SSB_Wallet.png]('"$id"')\nUse https://cesium.app to send payment.\nComment your transaction with '"'Zen'"' to create ZenTags...","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
2020-03-22 04:45:20 +01:00
echo "
2020-03-22 04:45:20 +01:00
___ _ _ __
| |_)|_(_ _. _| _|
2020-03-26 03:20:04 +01:00
_|_| | __) (_|(_|(_|
~/.zen/ipfs
2020-03-22 04:45:20 +01:00
"
# COPY NODE G1SSB ID to IPFS
echo "$ssbpub" > ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_ssb.whoami
echo "$g1pub" > ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.pubkey
2020-04-27 22:57:41 +02:00
# 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
ipfs id | jq -r .Addresses[] | tail -n 1 > ~/.zen/ipfs/.${ipfsnodeid}/tryme.addr
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
echo "
2020-03-26 03:20:04 +01:00
ipfs ls /ipns/$NODEIPNS
2020-03-24 01:20:10 +01:00
_ _ _ _ _
(_)_ ____ _(_) |_ __ _| |_(_) ___ _ __
| | _ \ \ / / | __/ _| | __| |/ _ \| _ \
| | | | \ V /| | || (_| | |_| | (_) | | | |
|_|_| |_|\_/ |_|\__\__|_|\__|_|\___/|_| |_|
2020-03-22 04:45:20 +01:00
# This INVITE is to be sent an to 'Astroport Station' willing to Join our IPFS Swarm.
# see 'ssb_SURVEY_contact.sh' for commands executed...
2020-03-29 16:15:39 +02:00
2020-03-22 04:45:20 +01:00
"
2020-03-29 16:15:39 +02:00
echo "PLEASE ENTER SSB INVITATION LINK (or HIT ENTER to create yours)"
read ssb_invit_link
[[ $ssb_invit_link == "" ]] && INVITE=$(sbotc invite.create 1) && echo $INVITE && exit 0
2020-03-29 16:15:39 +02:00
sbot invite.accept $ssb_invit_link
2020-03-29 15:44:01 +02:00
2020-03-29 16:15:39 +02:00
exit 0