#!/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' # Initialize G1SSB + SSB About + IPFS Node publish ######################################################################## 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 <\__ __/> __|>_ <\__ __/> <\__ __/> / \ __/> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # [ASTROPORT](https://astroport.com) ######################################################################## ' ######################################################################## # ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_info ######################################################################## ipfsnodeid=$(ipfs id -f='\n') [[ $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 sbotc 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) [[ $g1pub == "" ]] && echo "ERROR g1pub empty !! Please check it..." && exit 1 ######################################################################## # GET NODE disk performance. TODO, publish and use as IPFS repartition diskperf=$(dd if=/dev/zero of=~/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1) # IPFS LOCAL REPOSITORY for Node Identity G1 + SSB mkdir -p ~/.zen/ipfs/.$ipfsnodeid/G1SSB # PUBLISH ipfs informations sbotc publish '{"type":"ipfsnodeid","text":"'"$(ipfs id -f='\n')"'"}' sbotc publish '{"type":"ipfstryme","text":"'"$(ipfs id | jq -r .Addresses[] | tail -n 1)"'"}' ################################ # ADD Cesium+ informations CESIUM="https://g1.data.le-sou.org" [[ -f ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_uidna ]] && uidna=$(cat ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_uidna) [[ ! $uidna ]] && title=$(curl -s ${CESIUM}/user/profile/${g1pub} | jq '._source.title') || title="Station $uidna" [[ $title == null ]] && title="Station $USER@$(cat /etc/hostname)" city=$(curl -s ${CESIUM}/user/profile/${g1pub} | jq '._source.city') [[ $city != null ]] && title="$title in $city" 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 -r '._source.avatar._content' | base64 -d > "/tmp/avatar.png" ## PUBLISH ABOUT MESSAGE ############################################## # IF AVATAR not png take IMAGE of G1 wallet QRCode qrencode -s 5 -o ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.qrcode.png "$g1pub" if [[ ! $(file "/tmp/avatar.png" | grep 'PNG') ]]; then echo "NO Cesium AVATAR - Using G1Pub QRCode" imagefile=~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.qrcode.png rm -f /tmp/avatar.png else echo "AVATAR FOUND" imagefile=/tmp/avatar.png fi # Prepare QRCode File for SSB name=${imagefile##*/} id="$(sbotc blobs.add < $imagefile)" type="$(file -b --mime-type $imagefile)" size="$(wc -c < $imagefile)" echo " /\ |_ _ _|_ /--\|_)(_)|_||_ : PUBLISH to SSB feed... $ssbpub image: $id / $type / $size " # sbot publish --type about --about $ssbpub --description "[Astroport Node](https://astroport.com) [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid) - Wallet $g1pub - $diskperf" --name "$title" --image "$id" echo "sbotc publish \"{\"type\":\"about\",\"about\":\"$ssbpub\",\"description\":\"[Astroport Node](https://astroport.com) [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid) - Wallet $g1pub - $diskperf\",\"name\":\"$title\",\"image\":\"$id\"}\"" sbotc publish "{\"type\":\"about\",\"about\":\"$ssbpub\",\"description\":\"[Astroport Node](https://astroport.com) [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid) - Wallet $g1pub - $diskperf\",\"name\":\"$title\",\"image\":\"$id\"}" # REQUEST DUNITER G1 Wallet balance export LC_ALL=C.UTF-8 #attipix export LANG=C.UTF-8 #attipix DUNITERNODE=$($MY_PATH/tools/duniter_getnode.sh) [[ $DUNITERNODE ]] && g1balance=$(silkaj -p $DUNITERNODE balance $g1pub 2>&1) || g1balance=$(silkaj balance $g1pub 2>&1) # SSB PUBLISH G1 wallet silkaj balance # TODO crash bad text format [[ $g1balance ]] && sbotc publish '{"type":"post","text":"'"$g1balance"'"}' echo " _ _ / \|_) _ _ _| _ \_X| \ (_(_)(_|(/_ ! AVATAR $g1balance ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.qrcode.png -- sbotc publish -- " # IF no AVATAR, publish message with QRCode if [[ ! $(file "/tmp/avatar.png" | grep 'PNG') ]]; then sbotc publish '{"type":"post","text":"[My G1 Wallet QRCode]('"$id"')\nI am using [Cesium](https://cesium.app) to manage my wallet with (base64 to base58) secret.dunikey","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}' else sbotc publish '{"type":"post","text":"[Cesium Avatar]('"$id"')\n from my Wallet [Cesium](https://demo.cesium.app/#/app/wot/'"$g1pub"')","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}' fi echo " ___ _ _ __ | |_)|_(_ _. _| _| _|_| | __) (_|(_|(_| ~/.zen/ipfs " # COPY NODE G1SSB ID to IPFS echo "$ssbpub" > ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_ssb.whoami 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 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 " ipfs ls /ipns/$ipfsnodeid _ _ _ _ _ (_)_ ____ _(_) |_ __ _| |_(_) ___ _ __ | | _ \ \ / / | __/ _| | __| |/ _ \| _ \ | | | | \ V /| | || (_| | |_| | (_) | | | | |_|_| |_|\_/ |_|\__\__|_|\__|_|\___/|_| |_| # This INVITE is to be sent an to 'Astroport Station' willing to Join our IPFS Swarm. # see 'ssb_SURVEY_contact.sh' for commands executed... " 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 sbotc invite.accept $ssb_invit_link exit 0