From 54be96467ffda4a9bb5bf31cb42d1289086ea78d Mon Sep 17 00:00:00 2001 From: qo-op Date: Mon, 30 Nov 2020 19:21:30 +0100 Subject: [PATCH] adding gchange swarm control --- cron_MINUTE.sh | 5 ++- zen/cesium-messaging/.env | 2 +- zen/cesium-messaging/userEnv.py | 2 +- zen/gchange_INIT.sh | 2 - zen/gchange_IPFS_swarm.sh | 99 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 zen/gchange_IPFS_swarm.sh diff --git a/cron_MINUTE.sh b/cron_MINUTE.sh index 38695a5..e8160fe 100755 --- a/cron_MINUTE.sh +++ b/cron_MINUTE.sh @@ -19,14 +19,13 @@ source $HOME/.profile export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) source /home/$YOU/.profile [[ $IPFSNODEID ]] && export IPFSNODEID=$IPFSNODEID || export IPFSNODEID=$(ipfs id -f='\n') -[[ $WHOAMI ]] && export WHOAMI=$WHOAMI || export WHOAMI=$($MY_PATH/zen/tools/timeout.sh -t 8 sbotc whoami | jq -r .id) ######################################################################## # HELP DEVLT: Search "TODO" in code # Write what you thing about the situation # AND how you would like to 'fix it'... # Then friends can read and enhance solution. -# WARNING: This script must be precessing less than 1 minute, so do not charge too much this script +# WARNING: This script must be processing less than 1 minute, so do not charge too much this script # _ _____ ____ _ _______ ________ ____ # | | / / | / __ \/ | / / _/ | / / ____/ / / / # | | /| / / /| | / /_/ / |/ // // |/ / / __ / / / @@ -40,6 +39,8 @@ source /home/$YOU/.profile ### EVERY STATION RUN THIS SCRIPT EVERY MINUTE. export isMinetestRunning=$(ps auxf --sort=+utime | grep -w minetest | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1) export isG1smsRunning=$(ps auxf --sort=+utime | grep -w gammu | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1) +export isKodiRunning=$(ps auxf --sort=+utime | grep -w kodi | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1) + # ? isNextcloudRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1) ### DETECT FLAVOURS (TODO: Publish and share into ipfs/.Qm***/ ) ######################################################################## diff --git a/zen/cesium-messaging/.env b/zen/cesium-messaging/.env index 9cd6e60..9d0f4d9 100644 --- a/zen/cesium-messaging/.env +++ b/zen/cesium-messaging/.env @@ -1,3 +1,3 @@ -DUNIKEY²="/home/pi/.zen/secret.dunikey" # Chemin du fichier de trousseau Ḡ1 de l'émetteur, au format PubSec +DUNIKEY="/home/pi/.zen/secret.dunikey" # Chemin du fichier de trousseau Ḡ1 de l'émetteur, au format PubSec #POD="https://g1.data.duniter.fr" # Noeud Cecium+ utilisé pour l'envoi du message POD="https://data.gchange.fr" # Noeud Gchange utilisé pour l'envoi du message diff --git a/zen/cesium-messaging/userEnv.py b/zen/cesium-messaging/userEnv.py index f8311c9..c302765 100644 --- a/zen/cesium-messaging/userEnv.py +++ b/zen/cesium-messaging/userEnv.py @@ -1,3 +1,3 @@ -DUNIKEY²="/home/pi/.zen/secret.dunikey" # Chemin du fichier de trousseau Ḡ1 de l'émetteur, au format PubSec +DUNIKEY="/home/pi/.zen/secret.dunikey" # Chemin du fichier de trousseau Ḡ1 de l'émetteur, au format PubSec POD="https://g1.data.duniter.fr" # Noeud Cecium+ utilisé pour l'envoi du message #pod="https://data.gchange.fr" # Noeud Gchange utilisé pour l'envoi du message diff --git a/zen/gchange_INIT.sh b/zen/gchange_INIT.sh index bb6274b..c43688b 100644 --- a/zen/gchange_INIT.sh +++ b/zen/gchange_INIT.sh @@ -8,7 +8,6 @@ MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ME="${0##*/}" - ######################################################################## # ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info ######################################################################## @@ -21,7 +20,6 @@ G1PUB=$(cat ~/.zen/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 echo "DISK SIZE AVAILABLE & PERFORMANCE TESTING" [[ -f ~/.zen/test.disk ]] && rm -f ~/.zen/test.disk diff --git a/zen/gchange_IPFS_swarm.sh b/zen/gchange_IPFS_swarm.sh new file mode 100644 index 0000000..d12f9ed --- /dev/null +++ b/zen/gchange_IPFS_swarm.sh @@ -0,0 +1,99 @@ +#!/bin/bash +######################################################################## +# Author: Fred (support@qo-op.com) +# Version: 2020.04.27 +# 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##*/}" + +######################################################################## +# \\/// +# qo-op +############# '$MY_PATH/$ME' +######################################################################## +# ex: ./'$ME' +# GET SSB FRIENDS AND FIND THEIR IPFS ID TO "ipfs swarm connect" THEM +########################################################################' + +## TODO: REMOVE DUPLICATES +## TODO: MODE : COOL, STRAIGHT, ARMORED + +######################################################################## +## CONNECT GLOBAL "ipfs.io" ## DANGEROUS only for short time... +######################################################################## +# ADD ipfs.io public bootstrap into your swarm peers +# RUN: cat ~/.zen/astroport/ipfs.swarm.ipfs.io | ipfs swarm connect +# SOON ipfs swarm peers will GROW!!! YOU ARE VSIBLE !!! +# RUN: sudo systemctl restart ipfs # GOES BACK TO SWARM0 +######################################################################## + +######################################################################## +# 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 +######################################################################## + +echo ' + __ __ ____ + __/ // /_______ ______ __________ ___ / __ \ + /_ _ __/ ___/ | /| / / __ `/ ___/ __ `__ \/ / / / +/_ _ __(__ )| |/ |/ / /_/ / / / / / / / / /_/ / + /_//_/ /____/ |__/|__/\__,_/_/ /_/ /_/ /_/\____/ + + +EXTEND IPFS SWARM and SHAPE IT FROM (ssb_INIT.sh) FRIENDS +Search "ipfstryme" message type in SSB feed +' +[[ ! $WHOAMI ]] && WHOAMI=$($MY_PATH/tools/timeout.sh -t 3 sbotc whoami | jq -r .id) +######################################################################## + +# GET /tmp/ssb-friends.txt +sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$WHOAMI"'", "content":{"type":"contact"}}}}]}' | jq -r '.value?.content?.contact' > /tmp/ssb-friends.txt + +# GET /tmp/ssb-NOTfriends.txt +sbotc links "{\"source\": \"${WHOAMI}\", \"rel\": \"contact\", \"values\": true, \"reverse\": true}" | jq -c . | grep 'blocking":true' | jq -r .dest > /tmp/ssb-NOTfriends.txt + +count=1 +######################################################################## +# Let's look if our SSB Friends ARE "IPFS swarm connected" +######################################################################## +echo "" > /tmp/This_NOTfriends_are_astroport +echo "" > /tmp/This_friends_connect_astroport +echo "" > /tmp/This_friends_should_install_astroport +### TODO -> send sbotc message (private or zip attached?) with this reports + +for SSBFRIEND in $(uniq /tmp/ssb-friends.txt); do + + # Force Strict #swarm0 !! + [[ $count == 1 ]] && ipfs bootstrap rm --all + + ### sbotc $SSBFRIEND name + MYFRIEND=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$SSBFRIEND"'", "content":{"type":"about", "about": "'"$SSBFRIEND"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1) + ### GET SSB "ipfstryme" message type !!! Astroport Node should have publish it during "ssb_INIT.sh" + TRYME=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$SSBFRIEND"'", "content":{"type":"ipfstryme"}}}}]}' | jq -r .value?.content?.text | tail -n 1) + + ## !! REMOVE NOTfriends from IPFS swarm + [[ $TRYME ]] && [[ $(grep -Rwl "$SSBFRIEND" /tmp/ssb-NOTfriends.txt) ]] && MES="($count) HUMMMM $MYFRIEND ($SSBFRIEND) IS NOT my friend disconnecting" && ipfs swarm disconnect $TRYME && ipfs bootstrap rm $TRYME && echo $MES >> /tmp/This_NOTfriends_are_astroport && continue + ## Ici, on peut décider de demander à faire supprimer la couche astroport à son PAS AMI + + ## ADD Friend to our IPFS swarm + [[ $TRYME ]] && MES="($count) $MYFRIEND ($SSBFRIEND) connect OK $TRYME" && ipfs swarm connect $TRYME && ipfs bootstrap add $TRYME && echo $MES >> /tmp/This_friends_connect_astroport + ## Ce pote est connecté IPFS avec moi + + ## This_friends_should_install_astroport + [[ ! $TRYME ]] && MES="($count) $MYFRIEND ($SSBFRIEND) is NOT running ASTROPORT !!!" && echo $MES >> /tmp/This_friends_should_install_astroport + + ### WHAT HAPPENED this loop on my ssb friends + echo $MES + echo "_________________________________________________" + count=$((count+1)) + +done + + +echo "__________________________________________ +$WHOAMI ipfs peers are:" +ipfs swarm peers