From d554fe89122e06778eac65f278728336e361bdeb Mon Sep 17 00:00:00 2001 From: qo-op Date: Thu, 14 May 2020 00:47:30 +0200 Subject: [PATCH] read nodename --- zen/ssb_INIT.sh | 34 +++++++++++++++++++++++----------- zen/tools/make_G1SSB_secret.sh | 4 +++- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/zen/ssb_INIT.sh b/zen/ssb_INIT.sh index ba77faa..a6eac68 100755 --- a/zen/ssb_INIT.sh +++ b/zen/ssb_INIT.sh @@ -46,15 +46,17 @@ g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) ######################################################################## # GET NODE disk performance. TODO, publish and use as IPFS repartition -echo "DISK PERFORMANCE TESTING" +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) # echo $diskperf +sizeAvail=$(df -h ~/ | tail -n 1 | awk '{print $4}') + # IPFS LOCAL REPOSITORY for Node Identity G1 + SSB mkdir -p ~/.zen/ipfs/.$ipfsnodeid/G1SSB -# PUBLISH ipfs informations +# SSB 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)"'"}' @@ -62,18 +64,20 @@ sbotc publish '{"type":"ipfstryme","text":"'"$(ipfs id | jq -r .Addresses[] | ta # ADD Cesium+ informations CESIUM="https://g1.data.le-sou.org" +# PREPARE title [[ -f ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_uidna ]] && uidna=$(cat ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_uidna) [[ ! $uidna ]] && title=$(curl -s ${CESIUM}/user/profile/${g1pub} | jq -r '._source.title') || title="Station $uidna" [[ $title == null ]] && title="Station $USER@$(cat /etc/hostname)" city=$(curl -s ${CESIUM}/user/profile/${g1pub} | jq -r '._source.city') [[ $city != null ]] && title="$title in $city" +# REFRESH cesium_geoPoint in SSB feed 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 +# REFRESH Cesium+ Avatar image curl -s ${CESIUM}/user/profile/${g1pub} | jq -r '._source.avatar._content' | base64 -d > "/tmp/_g1.avatar.png" ## PUBLISH ABOUT MESSAGE @@ -92,6 +96,7 @@ if [[ ! $(file "/tmp/_g1.avatar.png" | grep 'PNG') ]]; then else echo "AVATAR FOUND" imagefile=/tmp/_g1.avatar.png + # PUBLISH AVATAR TO IPFS cp /tmp/_g1.avatar.png ~/.zen/ipfs/.$ipfsnodeid/G1SSB/ fi @@ -112,25 +117,31 @@ $imagefile $id : $type : $size bits " +nodename=$(cat /etc/hostname) +extension=$(echo $nodename | cut -d '.' -f 2) +if [[ $extension == $nodename ]]; then + nodename=$nodename.local +fi + +# OLD ssb-server publish # 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 Station](https://astroport.com) [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid) - Wallet $g1pub - $diskperf\",\"name\":\"$title\",\"image\":\"$id\"}\"" -sbotc publish "{\"type\":\"about\",\"about\":\"$ssbpub\",\"description\":\"![QRCode]($qrid)\\n[Astroport Station](https://astroport.com)\\n IPFS: [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid) \\n G1: $g1pub \\n PERF: $diskperf\",\"name\":\"$title\",\"image\":\"$id\"}" - -# REQUEST DUNITER G1 Wallet balance +# NEW sbotc publish to oasis +sbotc publish "{\"type\":\"about\",\"about\":\"$ssbpub\",\"description\":\"![QRCode]($qrid)\\n[Astroport #Swarm0 Station](https://astroport.com)\\n - [GChange Market](http://$nodename/gchange/#/app/wot/$g1pub) \\n - [Cesium Wallet](https://$nodename/cesium/#/app/wot/$g1pub/) \\n IPFS NODE ID : [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid) \\n DISK: $sizeAvail = $diskperf\",\"name\":\"$title\",\"image\":\"$id\"}" +######################################################################## +# 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 FIND WHY THIS ***** COMA , IS EVERYWHERE json_escape () { printf '%s' "$1" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' } INLINE=$(json_escape "$g1balance") -[[ $INLINE ]] && sbotc publish '{"type":"post","text":'$INLINE'}' +# TODO FIND WHY THIS ***** COMA , IS EVERYWHERE +# [[ $INLINE ]] && sbotc publish '{"type":"post","text":'$INLINE'}' #INLINE="${g1balance@Q}" #[[ $INLINE ]] && sbotc publish '{"type":"post","text":"'$INLINE'"}' @@ -148,7 +159,8 @@ $g1balance " # IF no AVATAR, publish message with QRCode if [[ ! $(file "/tmp/_g1.avatar.png" | grep 'PNG') ]]; then - sbotc publish '{"type":"post","text":"![QRCode]('"$qrid"')\n Scan QRCode with [Cesium](https://cesium.app).\n Thank you\n ONE :heart:","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}' +# Published on about document now +# sbotc publish '{"type":"post","text":"![QRCode]('"$qrid"')\n Scan QRCode with [Cesium](https://cesium.app).\n Thank you\n ONE :heart:","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}' else # Publish only if new avatar if [[ $(diff /tmp/_g1.avatar.png ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.avatar.png) ]]; then diff --git a/zen/tools/make_G1SSB_secret.sh b/zen/tools/make_G1SSB_secret.sh index 6b685d6..74fd3eb 100755 --- a/zen/tools/make_G1SSB_secret.sh +++ b/zen/tools/make_G1SSB_secret.sh @@ -98,7 +98,9 @@ else PUB="true" fi if [[ ! $(which oasis) ]]; then - echo "INSTALL...." + echo "INSTALL.... http://$nodename" + echo "ENTER Station accessible Network name !!! Suggestion : $nodename" + read nodename # Install nvm if [[ ! $(which node) || ! $(which npm) ]]; then curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash