diff --git a/.install/ipfs_alone.sh b/.install/ipfs_alone.sh index 5556bbd..aeb0216 100755 --- a/.install/ipfs_alone.sh +++ b/.install/ipfs_alone.sh @@ -23,9 +23,9 @@ err() { # CHECK if daemon is already running if [[ $(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) ]]; then - echo "ipfs daemon already running...! Must STOP ipfs AND remove ~/.ipfs to install again !!" ipfs id && echo "ipfs swarm peers: " && ipfs swarm peers echo "ipfs bootstrap list: " && ipfs bootstrap list + echo "ipfs daemon already running...! Must STOP ipfs AND remove ~/.ipfs to install again !!" echo "Please RUN : sudo service ipfs stop" exit 1 fi @@ -120,8 +120,8 @@ ipfs config Datastore.StorageMax $diskSize ## Activate Rapid "ipfs p2p" ipfs config --json Experimental.Libp2pStreamMounting true ipfs config --json Experimental.P2pHttpProxy true -ipfs config --json Swarm.ConnMgr.LowWater 60 -ipfs config --json Swarm.ConnMgr.HighWater 180 +ipfs config --json Swarm.ConnMgr.LowWater 0 +ipfs config --json Swarm.ConnMgr.HighWater 0 ######### CLEAN DEFAULT BOOTSTRAP TO STAY INVISIBLE ########### ipfs bootstrap rm --all ########################################### diff --git a/README.md b/README.md index 229ec15..6804883 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Grâce aux contrats, même Netflix pourra choisir de fermer ses datacenter, pour **Découvrez l'[Internet des gens](https://astroport.com)** astrXbian est une première façon de programmer Astroport en le connectant avec KODI. -Utilisé de cette façon, il constitue un **Vidéo Club "pair à pair" entre amis** +Utilisé de cette façon, il constitue un **Vidéo Club "pair à pair" entre amis** Il permet de mettre en partage vos copies privées dans votre essaim au travers du média-center KODI. Vos relations Gchange s'appliquent comme relations (A-B(-C)) (ami (d'amis)) de votre essaim IPFS et de toutes données à échanger selon le nombre d'étoiles envoyées. @@ -92,7 +92,7 @@ Il contrôle son réseau IPFS en fonction des "étoiles" transmisent par Gchange ASTROPORT, automate cellulaire sécurisé, prend en compte vos relations pour ouvrir des canaux de partage selon 5 niveaux de confiance. Ces "stargate" permettent de créer des espaces numériques public ou privés tout en contrôlant l'étendue du partage. ---- +--- ## INSTALLATION (Debian/Ubuntu/Mint ou Xbian) @@ -130,7 +130,7 @@ Cela tombe bien, parce que tout utilisateur averti de son ordinateur se doit de Il s'agit des logiciels ipfs et de diverses couches cryptographiques compatible avec toute application du système hote pour en partager les données avec les amis de son essaim cette distribution permet de facilement relier nos ordinateurs en cloud sans datacenter. -**Ouvrez un terminal puis copiez/collez cette ligne de commande**: +**Ouvrez un terminal puis copiez/collez cette ligne de commande**: ```bash <(wget -qO- https://git.p2p.legal/axiom-team/astrXbian/raw/branch/master/install.sh)``` @@ -169,7 +169,7 @@ Ensemble transformons le monde numérique pour qu'il devienne LIBRE P2P et LEGAL ## Installation Image pour Rpi4 -Nous avons préparé une image système pré-installée +Nous avons préparé une image système pré-installée [TELECHARGER IMAGE POUR RPI](https://qo-op.com/astrXbian_2021_03_10.img) - Copier l'image sur une carte micro-SD. Utiliser un RaspberryPi4 (2 ou 4Go) est recommandé! @@ -181,14 +181,14 @@ NB: Les films placés dans ~/astroport/film/$TMDBID/ sont automatiquement transf -- Automate Astroport/KODI en demonstration pour Xbian.org -- -## PRINCIPE DE FONCTIONNEMENT +## PRINCIPE DE FONCTIONNEMENT ([index des PAD astroport](https://pad.p2p.legal/s/astroport-index)) > Astroport/KODI vous permet de partager les vidéos que vous aimez avec les gens que vous aimez. -Le répertoire ~/astroport sert de sas de transfert de vos fichiers dans IPFS. +Le répertoire ~/astroport sert de sas de transfert de vos fichiers dans IPFS. Votre essaim de pairs connectés se dessine selon les "étoiles" échangées sur https://gchange.fr -Chaque noeud astXbian possède une identité (paire de clef ed25519) qui correspond à son identité sur https://gchange.fr et un portefeuille sur https://cesium.app +Chaque noeud astXbian possède une identité (paire de clef ed25519) qui correspond à son identité sur https://gchange.fr et un portefeuille sur https://cesium.app Lorsqu'une identité "like/étoile" un autre compte sur Gchange, elle lui expédie le message "ipfstryme" ```~/.zen/ipfs/.${IPFSNODEID}/tryme.addr``` qui contient les adresses IP/IPFS connues (amis d'ami). @@ -220,7 +220,7 @@ L'essaim se restructure toutes les minutes (code: ```cron_MINUTE.sh```) et activ Chaque station fabrique 5 clefs qui sont envoyées à tous ses amis en fonction des étoiles attribuées. Ces "stargate" partagés sur le même espace IPNS sont signés par chaque participant qui le modifie construisant une blockchain (sauvegarde). -En cas de conflit (quand le swarm est trop grand ou désynchronisé), une procédure envoi des messages aux 2 signatures et invite à résoudre de façon manuelle le problème. +En cas de conflit (quand le swarm est trop grand ou désynchronisé), une procédure envoi des messages aux 2 signatures et invite à résoudre de façon manuelle le problème. # Magic commands @@ -250,7 +250,7 @@ ipfs ls /ipns/k51qzi5uqu5dk1nt1pfbtgfis4bep8pcip78w30xykhgba7y7wk0xyu8nwci5m MYCODE=$(cat ~/.zen/ipfs_swarm/.$IPFSNODEID/.mycode); for CODE in $(ls ~/.zen/ipfs_swarm/.12D*/.mycode); do - echo + echo ipfsnodeid=$(echo $CODE | cut -d '.' -f 3 | cut -d '/' -f 1 ); code=$(cat $CODE); IPNSCODE=$(ipfs cat /ipns/$ipfsnodeid/.$ipfsnodeid/.mycode) @@ -272,7 +272,7 @@ for ipfsnodeid in $(ipfs swarm peers | grep -o '[^/]*$'); do ipfs cat /ipns/$ipf # ANNEXES ## PRESENTATIONS VIDEO - + ### [Fred présente Astroport à la Ressourcerie](https://tube.p2p.legal/videos/watch/7ff4a8c9-7fb7-44ef-a1ee-bdf8ecc74cfe) ### [Première visite de Astroport/KODI](https://tube.p2p.legal/videos/watch/d74631e9-b1bd-43f4-9db7-5effca1ef46a) @@ -329,7 +329,7 @@ https://forum.monnaie-libre.fr/t/offres-emplois/16903?u=qoop - 1 DU par compte ouvert sur https://oasis.astroport.com - 2 DU par article autour du DIY Raspberry Pi sur https://copylaradio.com (+ 1 DU pour l'ouverture du compte) -A la clef un concours des meilleurs articles par activation de la Zen Economie sur Astroport. +A la clef un concours des meilleurs articles par activation de la Zen Economie sur Astroport. Pour rejoindre l'Astrocrew installez AstrXbian TestNET en cour s de développement et devenez programmateur de cette automate cellulaire (BASH + multilanguage). Le nouveau JEu du LOVE peut commencer. diff --git a/actions/p4n.swarmscraper.sh b/actions/p4n.swarmscraper.sh new file mode 100755 index 0000000..0a8df8a --- /dev/null +++ b/actions/p4n.swarmscraper.sh @@ -0,0 +1,140 @@ +#!/bin/bash +######################################################################## +# Author: Astrocrew +# Version: 0.1 +# 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##*/}" +countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l) +[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0 + +YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1 +G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "NO ~/.zen/secret.dunikey EXIT" && exit 1 +IPFSNODEID=$(ipfs --timeout=20s id -f='\n' 2>/dev/null) && [[ $IPFSNODEID == "" ]] && echo 'NO IPFS RUNNING. EXIT' && exit 1 +[ ! -d ~/.zen/ipfs/.$IPFSNODEID/astroport ] && echo 'ASTROPORT NOT READY' && exit 1 + +##############################################################" +## Backing up europa p4n collected spots from collective intelligence ## +# SWARM is collectively PLAYing bataille navale +# Randomly get geaodata in south europe +# FOCUS on SOUTH EUROPE +# LON = -10 to 30 +# LAT = 35 to 60 +# https://fr.mapsofworld.com/lat_long/europe.html +##############################################################" +# initial first spot. +lon=0 +lat=40 +try=1 + +# Randomly choose spot from in RANGE $lat.$lon +while [[ $(ls ~/.zen/ipfs_swarm/.*/astroport/map/$lat.$lon/p4n/spot.json 2>/dev/null) ]]; do + echo "astroport/$lat.$lon geodata already swarm captured. CONTINUE" + FLOOR=-5; #-10; + CEILING=10; #30 + RANGE=$(($CEILING-$FLOOR+1)); + RESULT=$RANDOM; + let "RESULT %= $RANGE"; + lon=$(($RESULT+$FLOOR)); +#echo $lon + + FLOOR=40; #35; + CEILING=50; #60; + RANGE=$(($CEILING-$FLOOR+1)); + RESULT=$RANDOM; + let "RESULT %= $RANGE"; + lat=$(($RESULT+$FLOOR)); +#echo $lat + try=$(($try+1)); + [ $try -eq 99 ] && break ## tirages aléatoire maximum +done + +##############################################################" +## $lat.$lon GEODATA NOT SCRAPED YET ? +##############################################################" +if [ ! -d ~/.zen/ipfs/.$IPFSNODEID/astroport/map/$lat.$lon/p4n/ ]; then +### ADD Spot randomness + # Fuzzle geoloc + one=$(echo "000$RANDOM$RANDOM$RANDOM" | cut -b1-12) + latitude="$lat.$one" + two=$(echo "000$RANDOM$RANDOM$RANDOM" | cut -b1-12) + longitude="$lon.$two" + +### SCRAPE P4N + ## curl spot.json into /astroport/map/$lat.$lon/p4n/spot.json + echo "GETTING /astroport/map/$lat.$lon/p4n/spot.json" + mkdir -p ~/.zen/ipfs/.$IPFSNODEID/astroport/map/$lat.$lon/p4n/ + echo "https://www.park4night.com/services/V3/getLieuxAroundMeLite.php?latitude=$latitude&longitude=$longitude" + curl -s "https://www.park4night.com/services/V3/getLieuxAroundMeLite.php?latitude=$latitude&longitude=$longitude" -o ~/.zen/ipfs/.$IPFSNODEID/astroport/map/$lat.$lon/p4n/spot.json + echo "SAVED ~/.zen/ipfs/.$IPFSNODEID/astroport/map/$lat.$lon/p4n/spot.json" + ## TODO REFRESH OLD spot.json +fi + +##############################################################" +## GEODATA. continue. Let's extract lieu pdf from my spot +##############################################################" +geodata=$(ls ~/.zen/{ipfs,ipfs_swarm}/.*/astroport/map/$lat.$lon/p4n/spot.json 2>/dev/null | tail -n 1) +ipfsnodeid=$(echo "$geodata" | cut -d '/' -f 6 | cut -d '.' -f 2) + +if [[ "$ipfsnodeid" != "$IPFSNODEID" ]]; then + echo "This spot.json is already managed by $ipfsnodeid" + echo "getting one for mine" + geodata=$(ls ~/.zen/ipfs/.*/astroport/map/*.*/p4n/spot.json | shuf | tail -n 1) +fi + +[[ $geodata ]] && ipfsnodeid=$(echo "$geodata" | cut -d '/' -f 6 | cut -d '.' -f 2) || exit 1 + +## SUB-SCRAPE SOME of my p4n/spot.json RANDOM "lieu" +echo "SUB-SCRAPING lieu FROM /astroport/map/$lat.$lon/p4n/spot.json" + + loop=1 + while [ $loop -lt 21 ]; do + #{"id":"208264","latitude":"40.730727","longitude":"0.367303","hauteur_limite":"0.00","publique":"1","top_liste":"0","code":"APN","validation_admin":"1","distance":"97.341"} + # flatten json + + lieu=$(cat $geodata | jq -r '.lieux[] | "\(.id),\(.latitude),\(.longitude),\(.hauteur_limite),\(.publique),\(.top_liste),\(.code),\(.validation_admin),\(.distance)"' | shuf | tail -n 1) + ## GET RANDOM LIEU ID AND TRY MORE TO GET ( prefered APN) + lid=$(echo "$lieu" | cut -d ',' -f 1); code=$(echo "$lieu" | cut -d ',' -f 7) + [[ "$code" != "APN" ]] && [ -d ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid ] && lieu=$(cat $geodata | jq -r '.lieux[] | "\(.id),\(.latitude),\(.longitude),\(.hauteur_limite),\(.publique),\(.top_liste),\(.code),\(.validation_admin),\(.distance)"' | shuf | tail -n 1) + lid=$(echo "$lieu" | cut -d ',' -f 1); code=$(echo "$lieu" | cut -d ',' -f 7) + [[ "$code" != "APN" ]] && [ -d ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid ] && lieu=$(cat $geodata | jq -r '.lieux[] | "\(.id),\(.latitude),\(.longitude),\(.hauteur_limite),\(.publique),\(.top_liste),\(.code),\(.validation_admin),\(.distance)"' | shuf | tail -n 1) + lid=$(echo "$lieu" | cut -d ',' -f 1); code=$(echo "$lieu" | cut -d ',' -f 7) + [[ "$code" != "APN" ]] && [ -d ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid ] && lieu=$(cat $geodata | jq -r '.lieux[] | "\(.id),\(.latitude),\(.longitude),\(.hauteur_limite),\(.publique),\(.top_liste),\(.code),\(.validation_admin),\(.distance)"' | shuf | tail -n 1) + lid=$(echo "$lieu" | cut -d ',' -f 1); code=$(echo "$lieu" | cut -d ',' -f 7) + [ -d ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid ] && lieu=$(cat $geodata | jq -r '.lieux[] | "\(.id),\(.latitude),\(.longitude),\(.hauteur_limite),\(.publique),\(.top_liste),\(.code),\(.validation_admin),\(.distance)"' | shuf | tail -n 1) + lid=$(echo "$lieu" | cut -d ',' -f 1); code=$(echo "$lieu" | cut -d ',' -f 7) + [ -d ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid ] && lieu=$(cat $geodata | jq -r '.lieux[] | "\(.id),\(.latitude),\(.longitude),\(.hauteur_limite),\(.publique),\(.top_liste),\(.code),\(.validation_admin),\(.distance)"' | shuf | tail -n 1) + lid=$(echo "$lieu" | cut -d ',' -f 1); code=$(echo "$lieu" | cut -d ',' -f 7) + + [[ "$lid" == "" ]] && continue + + if [[ $(which chromium) ]]; then + mkdir -p /tmp/$lid && cd /tmp/$lid + echo "Downloading https://www.park4night.com/?page=lieu&id=$lid&bulle=YES" + mkdir -p ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid/$code + echo "id,latitude,longitude,hauteur_limite,publique,top_liste,code,validation_admin,distance" > ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid/$code/lieu.txt + echo "$lieu" >> ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid/$code/lieu.txt + + [ ! -f ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid/bulle.pdf ] && chromium --timeout=30000 --headless --no-sandbox --disable-gpu --print-to-pdf=output.pdf "https://www.park4night.com/?page=lieu&id=$lid&bulle=YES" 2>/dev/null + [ ! -f ./output.pdf ] && rm -Rf ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid + [ -f ./output.pdf ] && mv ./output.pdf ~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid/bulle.pdf + + echo "~/.zen/ipfs/.$IPFSNODEID/astroport/map/p4n/lieu/$lid/bulle.png" + sleep $((1 + RANDOM % 2)) + cd - && rm -Rf /tmp/$lid + + # TODO FUTURE BATCH to convert & crop to jpg image (imagemagick) + # convert -density 300 -depth 8 -quality 90 -trim ./output.pdf ./output.jpg + else + sudo apt-get install chromium -y + fi + loop=$(($loop+1)); + done + +## CHECK SWARM GEODATA MAP +# ls -d ~/.zen/ipfs_swarm/.*/astroport/map/*/ | rev | cut -d '/' -f 2 | rev | sort +## NB OF lieu: ls -d ~/.zen/ipfs_swarm/.*/astroport/map/p4n/lieu/*/ | rev | cut -d '/' -f 2 | rev | sort | wc +# ipfs cat /ipns/$IPFSNODEID/.$IPFSNODEID/astroport/map/$lat.$lon/p4n/spot.json | jq +exit 0 diff --git a/ajouter_video.sh b/ajouter_video.sh index bb3f141..b34c484 100755 --- a/ajouter_video.sh +++ b/ajouter_video.sh @@ -27,6 +27,16 @@ ME="${0##*/}" [[ $(which ffmpeg) == "" ]] && echo "ERREUR! Installez ffmpeg" && echo "sudo apt install ffmpeg" && exit 1 [[ $(which xdpyinfo) == "" ]] && echo "ERREUR! Installez x11-utils" && echo "sudo apt install x11-utils" && exit 1 +URL="$1" +[ $URL ] && echo "URL: $URL" && REVSOURCE="$(echo "$URL" | awk -F/ '{print $3}' | rev)_"\ +&& IMPORT=$(zenity --entry --width 640 --title="$URL => Astroport" --text="Choisissez comment copier cette source" --entry-text="Video" MP3 Web) \ +&& [[ $IMPORT == "Video" ]] && IMPORT="Youtube" \ +&& CHOICE="$IMPORT" + + + +[[ $CHOICE == "Web" ]] && CHOICE=$(zenity --entry --width 640 --title="$URL => Astroport" --text="Cette source WEB est à encrigistrer comme " --entry-text="Page" WebSite) + # REMOVE GtkDialog errors for zenity shopt -s expand_aliases alias zenity='zenity 2> >(grep -v GtkDialog >&2)' @@ -43,7 +53,7 @@ IPFSNODEID=$(ipfs id -f='\n') [[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title ]] && XZUID="$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title)" || XZUID="$(cat /etc/hostname)" [[ -f ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid ]] && AXID=$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid) -zenity --warning --width 300 --text "Ajoutez un MEDIA dans ASTROPORT" +# zenity --warning --width 300 --text "Ajoutez un MEDIA dans ASTROPORT" ######################################################################## @@ -76,7 +86,7 @@ fi ######################################################################## # CHOOSE CATEGORY (remove anime, not working!) -CHOICE=$(zenity --entry --width 300 --title="Catégorie" --text="Choisissez la catégorie de votre vidéo" --entry-text="Film" Serie Video KODI Youtube MP3) +[[ $CHOICE == "" ]] && CHOICE=$(zenity --entry --width 300 --title="Catégorie" --text="Choisissez la catégorie de votre media" --entry-text="Film" Serie Youtube Video) [[ $CHOICE == "" ]] && exit 1 # LOWER CARACTERS @@ -84,7 +94,7 @@ CAT=$(echo "${CHOICE}" | awk '{print tolower($0)}') # UPPER CARACTERS CHOICE=$(echo "${CAT}" | awk '{print toupper($0)}') -PREFIX=$(echo "${CAT}" | head -c 1 | awk '{ print toupper($0) }' ) # ex: F, S, A, Y, M ... +PREFIX=$(echo "${CAT}" | head -c 1 | awk '{ print toupper($0) }' ) # ex: F, S, A, Y, M ... P W [[ $PREFIX == "" ]] && exit 1 ######################################################################## @@ -101,9 +111,8 @@ case ${CAT} in ######################################################################## youtube) -zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Envoyez le LOG : https://git.p2p.legal .DEVELOPPEMENT' - -YTURL=$(zenity --entry --width 300 --title "Lien ou identifiant à copier" --text "Indiquez le lien (URL) ou l'ID de la vidéo" --entry-text="") +YTURL="$URL" +[[ $YTURL == "" ]] && YTURL=$(zenity --entry --width 300 --title "Lien ou identifiant à copier" --text "Indiquez le lien (URL) ou l'ID de la vidéo" --entry-text="") [[ $YTURL == "" ]] && exit 1 # Create TEMP directory to copy $YID_$TITLE.$FILE_EXT @@ -113,7 +122,7 @@ mkdir -p ${YTEMP} # youtube-dl $YTURL echo "VIDEO $YTURL" /usr/local/bin/youtube-dl -f '[height=720]/best' \ ---write-info-json --write-annotations \ +--no-playlist --write-info-json --write-annotations \ --no-mtime -o "${YTEMP}/%(id)s&%(title)s.%(ext)s" $YTURL # Get filename, extract ID, make destination dir and move copy. @@ -126,7 +135,7 @@ JSON_FILE=$(echo ${FILE_NAME} | sed "s/${FILE_EXT}/json/g") YID=$(echo "${FILE_NAME}" | cut -d "&" -f 1) YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | sed "s/[(][^)]*[)]//g" | sed -e 's/[^A-Za-z0-9._-]/_/g' | sed -e 's/__/_/g' ) # Remove YoutubeID_ and (what is in perentheses) [[ $(which detox) ]] && YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | detox --inline) -MEDIAID="${YID}" +MEDIAID="$REVSOURCE${YID}" TITLE="${YNAME%.*}" MEDIAKEY="YOUTUBE_${MEDIAID}" ## CORRECT PARAMETERS to Make Kodi compatible YASTRXBIAN FILE @@ -152,7 +161,7 @@ GENRES=$(zenity --list --checklist --title="GENRE" --height=${haut} \ # FORMAT GENRES genre1|genre2|genre3 -FILE_PATH="$HOME/astroport/youtube/$YID" +FILE_PATH="$HOME/astroport/youtube/$MEDIAID" mkdir -p ${FILE_PATH} && mv -f ${YTEMP}/* ${FILE_PATH}/ # rename FILE_NAME to YNAME (URL clean) mv "${FILE_PATH}/${FILE_NAME}" "${FILE_PATH}/${YNAME}" && FILE_NAME="${YNAME}" @@ -176,6 +185,43 @@ rm -Rf ${YTEMP} ;; ######################################################################## +# CASE ## WEB + web) + + zenity --warning --width 600 --text 'DEVELOPPEMENT . ZONE . Please Participate https://git.p2p.legal' + + ## httrack all web site + [[ ! $(which httrack) ]] && zenity --warning --width ${large} --text "Utilitaire de copie de site web absent.. Lancez la commande 'sudo apt install httrack'" && exit 1 + echo "httrack --mirror $URL" + ;; + + +######################################################################## +# CASE ## PAGE + page) + + zenity --warning --width 600 --text 'DEVELOPPEMENT . ZONE . Please Participate https://git.p2p.legal' + + ## record one page only + [[ ! $(which chromium) ]] && zenity --warning --width ${large} --text "Utilitaire de copie de page web absent.. Lancez la commande 'sudo apt install chromium'" && exit 1 + cd /tmp/ && rm output.pdf && chromium --headless --no-sandbox --print-to-pdf $URL + + TITLE=$(zenity --entry --width 480 --title "Titre" --text "Indiquez le titre de la vidéo" --entry-text="${URL}") + [[ $TITLE == "" ]] && exit 1 + FILE_NAME="$(echo "${TITLE}" | detox --inline).pdf" ## TODO make it better + + MEDIAID="$REVSOURCE$(echo "${TITLE}" | detox --inline)" + MEDIAKEY="PAGE_${MEDIAID}" + FILE_PATH="$HOME/astroport/youtube/$MEDIAID" + mkdir -p ${FILE_PATH} && mv -f output.pdf ${FILE_PATH}/${FILE_NAME} + + + echo "page;${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};_IPNSKEY_;${RES};/ipfs/_IPFSREPFILEID_/$FILE_NAME" > ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt + + + ;; + +######################################################################## # CASE ## MP3 # _____ # _ __ ___ _ __|___ / @@ -186,7 +232,7 @@ rm -Rf ${YTEMP} ######################################################################## mp3) -zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Envoyez le LOG : https://git.p2p.legal .DEVELOPPEMENT' +zenity --warning --width 600 --text 'DEVELOPPEMENT . ZONE . Please Participate https://git.p2p.legal' # Create TEMP directory YTEMP="/tmp/$(date -u +%s%N | cut -b1-13)" @@ -222,7 +268,7 @@ FILE_EXT="${FILE_NAME##*.}" YID=$(echo "${FILE_NAME}" | cut -d "&" -f 1) YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | sed "s/[(][^)]*[)]//g" | sed -e 's/[^A-Za-z0-9._-]/_/g' | sed -e 's/__/_/g') # Remove YoutubeID_ and (what is in perentheses) -[[ $(which detox) ]] && YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | detox --inline) +[[ $(which detox) ]] && YNAME="$(echo "${FILE_NAME}" | cut -d "&" -f 2- | detox --inline)" [[ ! $islink && "$song" != "" ]] && FILE_PATH="$HOME/astroport/$CAT/$artist/_o-o_" \ || FILE_PATH="$HOME/astroport/$CAT/${YID}" @@ -384,7 +430,7 @@ echo "${CAT};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/ video) - zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Envoyez le LOG : https://git.p2p.legal .DEVELOPPEMENT' + zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Inscrivez-vous sur https://git.p2p.legal' ## GENERAL MEDIAKEY for uploaded video. Title + Decription + hashtag + hashipfs # SELECT FILE TO ADD TO ASTROPORT/KODI @@ -427,9 +473,11 @@ echo "${CAT};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/ #| < (_) | (_| | | #|_|\_\___/ \__,_|_| # COPY UQLOAD LINKS DETECTED IN KODI LOG - +############################################## +### TODO INSTALL FROM START and AUTO SCRAPE KODI LOG +############################################## kodi) - +# OPTION REMOVED if [[ ! -f $HOME/.local/bin/uqload_downloader ]]; then cd /tmp git clone https://github.com/papiche/uqload_downloader.git @@ -442,8 +490,6 @@ echo "${CAT};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/ zenity --warning --width ${large} --text "UTILISEZ download_from_kodi_log.sh en ligne de commande..." exit 0 fi - - ;; ######################################################################## @@ -462,12 +508,13 @@ esac # ADD $FILE to IPFS / ASTROPORT / KODI echo "new_file_in_astroport.sh \"$HOME/astroport/${CAT}/${MEDIAID}/\" \"${FILE_NAME}\"" [[ -f ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt ]] && cat ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt -[[ -f ~/astroport/${CAT}/${MEDIAID}/video.json ]] && cat ~/astroport/${CAT}/${MEDIAID}/video.json - -######################################################################## +# LOG NOISE # [[ -f ~/astroport/${CAT}/${MEDIAID}/video.json ]] && cat ~/astroport/${CAT}/${MEDIAID}/video.json ######################################################################## +## CREATION DU FICHIER ajouter_video.txt OK ######################################################################## +### AJOUT DANS IPFS ####################################################### ######################################################################## +####################################new_file_in_astroport.sh################## ######################################################################## [[ "$CAT" == "film" || "$CAT" == "serie" ]] && CHOICE="TMDB" diff --git a/cron_MINUTE.sh b/cron_MINUTE.sh index 75947bf..2681856 100755 --- a/cron_MINUTE.sh +++ b/cron_MINUTE.sh @@ -27,8 +27,8 @@ IPFSNODEID=$(ipfs --timeout=10s id -f='\n') YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) if [[ ! ${YOU} ]]; then # reduice water levels for swarm - ipfs config --json Swarm.ConnMgr.LowWater 200 - ipfs config --json Swarm.ConnMgr.HighWater 400 + ipfs config --json Swarm.ConnMgr.LowWater 50 + ipfs config --json Swarm.ConnMgr.HighWater 100 [[ "${USER}" == "xbian" ]] && sudo service ipfs restart || sudo systemctl restart ipfs echo "ERROR! ipfs daemon was not running. RELAUNCHING." exit 1 @@ -36,7 +36,7 @@ fi ######################################################################## # CORRECT VSTREAM ASTROPORT SITE/ART REMOVED AFTER PLUGIN UPDATE [[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py ]] && [[ -f ~/.zen/astroport.py ]] && cp -f ~/.zen/astroport.py ~/.kodi/addons/plugin.video.vstream/resources/sites/ -[[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ]] && cp ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ~/.kodi/addons/plugin.video.vstream/resources/art/ +[[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ]] && cp ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ~/.kodi/addons/plugin.video.vstream/resources/art/ 2>/dev/null ######################################################################## ### NO IP GATEWAY : EXIT @@ -77,11 +77,11 @@ dayofthemonth=$(date +%d) weeknumber=$(date +%V) # WAKEUP TIME -if [[ ! -f /home/$YOU/.zen/A_Station_ON ]]; then - echo "onheure=$heure; onminute=$minute; ontimebar=$timebar" > /home/$YOU/.zen/A_Station_ON - [[ -f /tmp/A_Station_ON ]] && cp /tmp/A_Station_ON /home/$YOU/.zen/A_Station_ON +if [[ ! -f /tmp/A_Station_ON ]]; then + echo "onheure=$heure; onminute=$minute; ontimebar=$timebar" > /tmp/A_Station_ON + [[ -f /home/$YOU/.zen/A_Station_ON ]] && cp /home/$YOU/.zen/A_Station_ON /tmp/A_Station_ON && rm /home/$YOU/.zen/A_Station_ON else - source /home/$YOU/.zen/A_Station_ON + source /tmp/A_Station_ON old=$ontimebar new=$timebar # feeding variables by using read and splitting with IFS @@ -103,7 +103,10 @@ echo "RUNTIME $runtime mn ($timebar)" if [[ $(($runtime % 4)) == 0 ]]; then ## PING ALL MY FRIENDS TO ENHANCE SWARM CONNECTIVITY echo "## FRIENDS IPFS PINGing" - for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=5s -n 3 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done + for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do + [[ $g1pub ]] && latency=$(ipfs ping --timeout=2s -n 3 /p2p/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null | grep "Average" | cut -d ':' -f 2); + [[ $latency ]] && echo $latency > ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1pub/ping.average.txt + done fi ######################################################################## ## CHECK & (RE)ACTIVATE ipfs p2p tunnels @@ -187,12 +190,17 @@ fi # ################################################################## # TODO: IDEA make gchange/ipfs/ipns refresh speed depending on ipfs swarm size and DEFCON level ! -## SYNC GCHANGE EVERY 2 hours runtime -[[ $(($runtime % 97)) == 0 ]] && $MY_PATH/zen/gchange_INIT.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_INIT.txt -## SYNC SWARM EVERY 20 mn runtime -[[ $(($runtime % 17)) == 0 ]] && $MY_PATH/zen/gchange_IPFS_swarm.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_IPFS_swarm.txt -# QUICK SYNC SWARM EVERY 12 minutes -[[ $(($runtime % 11)) == 0 ]] && $MY_PATH/zen/ipfs_FRIENDS_refresh.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.ipfs_FRIENDS_refresh.txt +## SYNC GCHANGE EVERY 12 hours runtime +[[ $(($runtime % 725)) == 0 || "$runtime" == "5" ]] && $MY_PATH/zen/gchange_INIT.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_INIT.txt +## SYNC SWARM EVERY 6h runtime +[[ $(($runtime % 370)) == 0 || "$runtime" == "10" ]] && $MY_PATH/zen/gchange_IPFS_swarm.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_IPFS_swarm.txt +# QUICK SYNC SWARM EVERY 30 minutes +## CLEAN OLD SESSION +if [[ $(($runtime % 30)) == 0 ]]; then + kill -9 $(ps auxf --sort=+utime | grep -w p4n.swarmscraper.sh | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}') + killall chromium + $MY_PATH/zen/ipfs_SWARM_refresh.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.ipfs_SWARM_refresh.txt +fi ## TODO ACTIVATE/DESACTIVATE LOG ######################################################################## # ACTIVATE ~/astroport directory monitoring (xbian only) @@ -228,9 +236,6 @@ fi # # REFRESHing MEDIAKEY / ZenTAG nano DHTs => Zen File ECONOMY wallet cycle if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || "$timebar" == "03:03" || $(($runtime % 720)) == 0 || $runtime == 12 ]]; then - # Every 12h runtime restarting IPFS daemon - [[ "$timebar" == "03:03" ]] && [[ -f /etc/sudoers.d/systemctl ]] && sudo systemctl restart ipfs && exit 0 - [[ "$timebar" == "03:03" ]] && [[ ${YOU} == "xbian" ]] && sudo service ipfs restart && exit 0 #### Refresh & publish MEDIAKEYs $MY_PATH/zen/ipns_TAG_refresh.sh @@ -239,12 +244,17 @@ if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || "$timebar" == "03:03" || rm -f ~/.zen/A_dead_swarm.txt fi +# At 03:03 and every 6h runtime restarting IPFS daemon +[[ "$timebar" == "03:03" || $(($runtime % 363)) == 0 ]] && [[ -f ~/.ipfs/config.new ]] && cp ~/.ipfs/config.new ~/.ipfs/config +[[ "$timebar" == "03:03" || $(($runtime % 363)) == 0 ]] && [[ -f /etc/sudoers.d/systemctl ]] && sudo systemctl restart ipfs && exit 0 +[[ "$timebar" == "03:03" || $(($runtime % 363)) == 0 ]] && [[ ${YOU} == "xbian" ]] && sudo service ipfs restart && exit 0 + ################################################################## ################################################################## # 5 mn / 24h REBOOT & MIDNIGHT:01 : CLEANING & UPDATE ################################################################## ################################################################## -if [[ "$timebar" == "00:01" || "$runtime" == "5" || $(($runtime % 1380)) == 0 ]]; then +if [[ "$timebar" == "00:01" || "$runtime" == "30" || $(($runtime % 1380)) == 0 ]]; then echo ' # ____ ____ ____ ___ # / __ \/ __ \ _ / __ < / @@ -305,6 +315,20 @@ echo ' # RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh $MY_PATH/zen/manage_stargates.sh + + ######################################################################## + # ACTIVATE TO CONTROL SWARM STATION SAME CODE VERSION + ######################################################################## + ## myCODE is a SECURITY about code SIMILARITY + ## EACH NODE CAN CHECK IF ANOTHER HAS SAME IPFS CODE HASH + MyCODE=$(ipfs add -rq --ignore="__pycache__" ~/.zen/astrXbian/ | tail -n 1) + [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/.mycode ]] && echo $MyCODE > ~/.zen/ipfs/.${IPFSNODEID}/.mycode + [[ "$(cat ~/.zen/ipfs/.${IPFSNODEID}/.mycode)" != "$MyCODE" ]] && echo $MyCODE > ~/.zen/ipfs/.${IPFSNODEID}/.mycode + echo "MyCODE = $MyCODE CODE is ready to be published" + ######################################################################## + # MEAN CONTROL SWARM STATION HAVE SAME CODE VERSION + ######################################################################## + fi ### DISAPEAR ONE HOUR FROM IPFS SWARM ZOMBIES > 300 peers in swarm diff --git a/docs/Infos-utiles.md b/docs/Infos-utiles.md index 5e81a3b..fd845fc 100644 --- a/docs/Infos-utiles.md +++ b/docs/Infos-utiles.md @@ -2,7 +2,7 @@ * https://git.p2p.legal/axiom-team/astrXbian * https://oasis.astroport.com -* https://colibris-wiki.org/astroport +* https://colibris-wiki.org/astroport # Liens annexes @@ -23,7 +23,7 @@ # jaklis : commandes de messaging / like ``` -## GET ALERT MESSAGES +## GET ALERT MESSAGES ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$G1PUB" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ALERT")' | jq -r '.id' ## SEND MONITORING MESSAGE TO onelove @@ -32,3 +32,15 @@ ## LINKING ME PEOPLE ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' ``` + + +# EXEMPLES DE COMMANDES BALISES +``` + +## CHECK SWARM STATIONS TIMESTAMPS +for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS); do echo $g1id; [[ "$g1id" == "index.html" ]] && continue; ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id); ts=$(ipfs --timeout=10s cat /ipns/$ipfsnodeid/.$ipfsnodeid/.timestamp); echo $(date -ud @$ts); done +for ts in $(cat ~/.zen/ipfs_swarm/.*/.timestamp); do echo $(date -ud @$ts); done + + + +``` diff --git a/install.sh b/install.sh index d507d75..457519f 100755 --- a/install.sh +++ b/install.sh @@ -21,7 +21,7 @@ for i in git fail2ban inotify-tools curl net-tools libsodium* python3-dev python done #sudo apt-get install build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox httrack html2text ssmtp sudo -y -for i in build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox httrack html2text ssmtp sudo; do +for i in build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox nmap httrack html2text ssmtp imagemagick ttf-mscorefonts-installer; do if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then sudo apt install -y $i fi @@ -47,7 +47,7 @@ python3 -m pip install -U pip python3 -m pip install -U setuptools wheel python3 -m pip install -U cryptography Ed25519 base58 google protobuf duniterpy if [[ "$USER" == "pi" ]]; then ## PROPOSE QR_CODE PRINTER - echo "INSTALLER ACCES SMS ET IMPRIMANTE A QR CODE? saisissez OUI, sinon tapez sur ENTREE" + echo "SOUHAITEZ VOUS AJOUTER UNE IMPRIMANTE A QR CODE? saisissez OUI, sinon tapez sur ENTREE" read saisie if [[ $saisie != "" ]]; then sudo apt install printer-driver-all cups -y @@ -78,7 +78,7 @@ echo "Installation de IPFS https://ipfs.io" ~/.zen/astrXbian/.install/ipfs_alone.sh ######################################################################## -echo "Configuration jaklis: Centre de communication GCHANGE+" +echo "Configuration jaklis: Centre de communication CESIUM+ GCHANGE+ & MONNAIE LIBRE (gva protocole)" cd ~/.zen/astrXbian/zen/jaklis ./setup.sh @@ -117,19 +117,16 @@ fi mkdir -p ~/astroport/film mkdir -p ~/astroport/serie mkdir -p ~/astroport/anime +echo '${TYPE};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/ipfs/_IPFSREPFILEID_/$URLENCODE_FILE_NAME' > ~/astroport/ajouter_video.modele.txt ## PREPARE www EXCHANGE ZONE ~/astroport/www wwwuser=$(ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1) || wwuser="www-data" -mkdir -p ~/astroport/www -mkdir -p ~/astroport/www/audio -mkdir -p ~/astroport/www/video -mkdir -p ~/astroport/www/site sudo chown -R $USER:$wwwuser ~/astroport/www sudo chmod -R g+rw ~/astroport/www ####################################################################### ## CREATE symlinks for ~/.zen/www/swarm & me -sudo chown -R $USER:www-data /.zen/astrXbian/www/boris -sudo chmod -R g+rw /.zen/astrXbian/www/boris +sudo chown -R $USER:www-data ~/.zen/astrXbian/www/boris +sudo chmod -R g+rw ~/.zen/astrXbian/www/boris ln -s /home/$USER/.zen/ipfs_swarm ~/.zen/astrXbian/www/boris/swarm ln -s /home/$USER/.zen/ipfs ~/.zen/astrXbian/www/boris/me diff --git a/ipfs4astroport.sh b/ipfs4astroport.sh new file mode 100755 index 0000000..430c39f --- /dev/null +++ b/ipfs4astroport.sh @@ -0,0 +1,257 @@ +#!/bin/bash +######################################################################## +{ # this ensures the entire script is downloaded # +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +ME="${0##*/}" + +# CHECK not root user !! +if [ "$EUID" -eq 0 ] + then echo -e "DO NOT EXECUTE AS root. Choose a user for your Astroport Station (we like pi)" + exit 1 +else echo -e "OK $USER, let's go!"; +fi + +echo "Hello, + +This script (you could read and modify as it is open source software) is about to transform your computer into an astroport station. + +This process involve different upgrades to be made on your system. +1. install IPFS, the interplanetary file system (https://ipfs.io) +2. install python cryptographic libraries to run natools, your key wizard companion +3. download 'astroport' code release you have choosen. + +~/.zen directory and datastructure will emerge +~/.zen/ipfs & ~/.zen/ipfs_swarm contains all meshed media index from you and your friends. + +ASTROPORT is activated by cron every minute it maintains the connection with your friends. +It is the vessel that gives you avvess to your p2p AVATAR. +You carry and share your data around your friends through a confidence network +established through 1 to 5 'hearts' exchanged, opening 5 stargates where any can push/pull data. + +TODO +Just indicate which is the directory assigned to each star. +Then any of your friends from such star level can replicate (modify) those data with you. + +Your station is publishing its index every time it changes and every 6 hours for all MEDIAKEY from PIN station. +Following that principle add new directory into ~/.zen/ipfs and index any dataset, it will be published on your IPFS semaphore. + +Now you need to enter your password to obtain sudo access. +Please. +" +# Ask user password on start +sudo true + +## Error funciton +err() { + echo -e "ERREUR: $1" + exit 1 +} + +# CHECK if daemon is already running +if [[ $(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) ]]; then + ipfs id && echo "ipfs swarm peers: " && ipfs swarm peers + echo "ipfs bootstrap list: " && ipfs bootstrap list + echo "ipfs daemon already running...! Must STOP ipfs AND remove ~/.ipfs to install again !!" + echo "Please RUN : sudo service ipfs stop" + exit 1 +fi + +[[ -d ~/.ipfs ]] && echo "IPFS install exist! Please remove or backup before executing this script EXIT" && exit 1 + +echo -e "Check and install python curl, git and tools." + +[[ $(which pip3) ]] && python3 -m pip install -U pip && python3 -m pip install -U wheel cryptography Ed25519 base58 google protobuf duniterpy==0.62.0 termcolor python-dotenv gql==3.0.0a5 requests pybase64 || (echo "python3 pip3 is missing on your device. EXIT" && exit 1) +[[ ! $(which curl) ]] && sudo apt-get install curl -y +[[ ! $(which git) ]] && sudo apt-get install git -y + +[[ ! -d ~/.zen ]] && mkdir ~/.zen + +# CHECK node IP isLAN? +myIP=$(hostname -I | awk '{print $1}') +echo "Your IP is $myIP" +isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +[[ $isLAN ]] && echo "You are located in a LAN" || echo "You have a public IP address" +MACHINE_TYPE=`uname -m` +echo "You are running $MACHINE_TYPE CPU" + +echo "Downloading ipfs binaries" +if [ ${MACHINE_TYPE} == 'x86_64' ]; then + curl -s https://dist.ipfs.io/ipfs-update/v1.6.0/ipfs-update_v1.6.0_linux-amd64.tar.gz -o $MY_PATH/ipfs-update.tar.gz +elif [ ${MACHINE_TYPE:0:3} == 'arm' ]; then + curl -s https://dist.ipfs.io/ipfs-update/v1.6.0/ipfs-update_v1.6.0_linux-arm.tar.gz -o $MY_PATH/ipfs-update.tar.gz +elif [ ${MACHINE_TYPE} == 'aarch64' ]; then + curl -s https://dist.ipfs.io/go-ipfs/v0.9.1/go-ipfs_v0.9.1_linux-arm64.tar.gz -o /tmp/ipfs_aarch64_v0.9.1.tar.gz +else + echo "Your $MACHINE_TYPE is not supported yet... Please add an issue." && exit 1 +fi + +if [ -f $MY_PATH/ipfs-update.tar.gz ]; then + echo "INSTALL ipfs-update >>>>>>>>>>>>>>>>>>>>>>>>>>" + sudo tar -xvzf $MY_PATH/ipfs-update.tar.gz -C /usr/src/ || err "Untar ipfs-update" + rm $MY_PATH/ipfs-update.tar.gz + cd /usr/src/ipfs-update/ + sudo ./install.sh || err "Install ipfs-update" + cd $MY_PATH + + echo "INSTALL ipfs 0.9.1 >>>>>>>>>>>>>>>>>>>>>>>>>>" + sudo ipfs-update install 0.9.1 || err "Install IPFS" + +else + ## TERRAPI4 aarch64 install ipfs_aarch64_v0.9.1 + echo "INSTALL ipfs 0.9.1 >>>>>>>>>>>>>>>>>>>>>>>>>> arm64" + sudo tar -xvzf /tmp/ipfs_aarch64_v0.9.1.tar.gz -C /usr/src/ || err "Untar ipfs_aarch64" + rm /tmp/ipfs_aarch64_v0.9.1.tar.gz + cd /usr/src/go-ipfs/ + sudo ./install.sh || err "Install ipfs_aarch64" + cd $MY_PATH + +fi + +# INIT ipfs +[[ $isLAN ]] && ipfs init -p lowpower \ +|| ipfs init -p server + +## Special Xbian init.d config + ## DEBIAN SYSTEMCTL + echo "SYSTEMD ipfs SERVICE >>>>>>>>>>>>>>>> ON" +cat > /tmp/ipfs.service <>>>>>>>>>>>>>>>>> " +# echo "Vous pouvez régler la ressouce CPU maximum (60%)?" && read cpuy + + [[ -d ~/.ipfs ]] && sudo chown -R $USER:$USER ~/.ipfs + sudo systemctl daemon-reload + sudo systemctl enable ipfs + + +########################################### +echo "# ACTIVATE IPFS OPTIONS: #swarm0 INIT" +########################################### +### IMPORTANT !!!!!!! IMPORTANT !!!!!! +########################################### +# DHT PUBSUB mode +ipfs config Pubsub.Router gossipsub +# MAXSTORAGE = 1/2 available +availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}') +diskSize="$((availableDiskSize / 2))" +ipfs config Datastore.StorageMax $diskSize +## Activate Rapid "ipfs p2p" +ipfs config --json Experimental.Libp2pStreamMounting true +ipfs config --json Experimental.P2pHttpProxy true +ipfs config --json Swarm.ConnMgr.LowWater 50 +ipfs config --json Swarm.ConnMgr.HighWater 100 + +## Install gateway on 8181 port +ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8181" + +######################################################################## +# GET IPFS KEYS & CONVERSIONS +######################################################################## +IPFSNODEID=$(ipfs config Identity.PeerID) +## TODO convert to secret.dunikey + +######################################################################## +echo "CREATION IDENTITE BALISE IPFS ~/.zen/ipfs/.${IPFSNODEID} /G1SSB" +######################################################################## +rm -Rf ~/.zen/ipfs +mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/G1SSB +######################################################################## +# Give $XZUID to your (gchange friends) +######################################################################## +XZUID="$(hostname)-$RANDOM$RANDOM" +echo "SETTING _xbian.zuid PROFILE NAME = $XZUID" +echo "$XZUID" > ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid +echo 'balise /ipns/$IPFSNODEID/.$IPFSNODEID/_xbian.zuid' + +######################################################################## +######################################################################## +echo "Getting tryme.addr & .mycode from OASIS +-- Change oasis address to fork your Astroport Code Universe --" +######################################################################## +ipfs bootstrap rm --all + +OASIS=12D3KooWBYme2BsNUrtx4mEdNX6Yioa9AV7opWzQp6nrPs6ZKabN +# aries=12D3KooWSQYTxeoZZ39SNosEKxi7RUdGTtAQAqpKeZJxjzqqrZTx +for bootnode in $(curl -s https://tube.copylaradio.com/ipns/$OASIS/.$OASIS/tryme.addr) +do + ## ADD $bootnode TO BOOTSTRAP + ipfs bootstrap add $bootnode +done + +codesign=$(curl -s https://tube.copylaradio.com/ipns/$OASIS/.$OASIS/.mycode) + +## ADD NETWORK EXPLORATION FROM LIKES +######################################################################## +echo "RESTARTING ipfs" +######################################################################## +sudo service ipfs restart +echo ".... WAIT for SWARM to connect ..." +sleep 10 + +echo ".... ACTUAL SWARM PEERS ..." +ipfs swarm peers + +echo "IPFS DONE +==================== +Station Astroport INSTALL +Activation ~/.zen/astrXbian/zen/cron_VRFY.sh +Récupération CODE /ipfs/$codesign +" + +## GETTING SAME SOURCE CODE AS OASIS +mkdir -p /home/$USER/.zen/astrXbian/ +ipfs get --output=/home/$USER/.zen/astrXbian/ /ipfs/$codesign + +## Make scripts executable +find /home/$USER/.zen/astrXbian/ -name "*.sh" -exec chmod u+x '{}' \; +find /home/$USER/.zen/astrXbian/ -name "*.py" -exec chmod u+x '{}' \; + +######################################################################## +echo "# Setting $USER SUDO permissions ON fail2ban mount umount apt-get apt systemctl" +######################################################################## +## USED FOR fail2ban-client (DEFCON) +echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/fail2ban-client" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/fail2ban-client') +## USED FOR RAMDISK (video live streaming) +echo "$USER ALL=(ALL) NOPASSWD:/bin/mount" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/mount') +echo "$USER ALL=(ALL) NOPASSWD:/bin/umount" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/umount') +## USED FOR SYSTEM UPGRADE +echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/apt-get" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/apt-get') +echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/apt" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/apt') +## USED FOR "systemctl restart ipfs" +echo "$USER ALL=(ALL) NOPASSWD:/bin/systemctl" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/systemctl') + +## TODO G1SSB CONFIG +echo "## INSTALL TiddlyWiki /ipns/${IPFSNODEID}/.${IPFSNODEID}/index.html" +[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/index.html ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID} && cp ~/.zen/astrXbian/.install/templates/tiddlywiki/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html + + +echo "Congratulation ! You are part of the astroport interplanetary fleet. + +New. Activate your station offline storage. +Install ipfs companion : https://docs.ipfs.io/install/ipfs-companion/ +FR : https://translate.google.com/translate?sl=auto&tl=fr&u=https://docs.ipfs.io/install/ipfs-companion/ +" + +echo "FIND AND CONNECT WITH YOUR FRIENDS +https://tube.copylaradio.com/ipns/$OASIS/.$OASIS/" +## OPEN https://translate.google.com/translate?sl=auto&tl=fr&u=https://docs.ipfs.io/install/ipfs-companion/ + +} # this ensures the entire script is downloaded # +# IPFS CONFIG documentation: https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#addressesswarm diff --git a/www/boris/film.php b/www/boris/film.php index d7d8d0e..7b36928 100644 --- a/www/boris/film.php +++ b/www/boris/film.php @@ -5,6 +5,7 @@ require_once('functions.php'); $videosList = array(); +// HOWTO PASS Query parameters to exec ? exec("/bin/bash -c './get_astrxbian_index.sh F'", $videos); exec("/bin/bash -c './check_my_wallet.sh'", $gg1); diff --git a/www/boris/get_astrxbian_index.sh b/www/boris/get_astrxbian_index.sh index 3ba5005..c31e7c5 100755 --- a/www/boris/get_astrxbian_index.sh +++ b/www/boris/get_astrxbian_index.sh @@ -5,8 +5,10 @@ # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## PREFIX="$1" -[[ $PREFIX == "" ]] && PREFIX="Y" +FILTER="$2" +[[ $PREFIX == "" ]] && PREFIX="*" YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1 # Filter no ipns link -cat ./{me,swarm}/.*/astroport/kodi/vstream/*ASTRXBIAN | grep -Ev "];;" | sort | uniq | tail -n +2 +[[ ! $FILTER ]] && cat /home/$YOU/.zen/{ipfs,ipfs_swarm}/.*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | grep -Ev "];;" | sort | uniq | tail -n +2 && exit 0 +cat /home/$YOU/.zen/{ipfs,ipfs_swarm}/.*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | grep -Ev "];;" | grep "$FILTER" | sort | uniq | tail -n +2 diff --git a/zen/cron_VRFY.sh b/zen/cron_VRFY.sh index 9917077..fe84265 100755 --- a/zen/cron_VRFY.sh +++ b/zen/cron_VRFY.sh @@ -13,28 +13,39 @@ echo ' # qo-op ############# '$MY_PATH/$ME' ######################################################################## -# ex: ./'$ME' -# VERIFY CRON for cron_MINUTE.sh and ACTIVATE it +# Activate / Desactivate ASTROPORT cron_MINUTE.sh job ########################################################################' # Get crontab crontab -l > /tmp/mycron -# Remove any previous line containing "cron_MINUTE" -awk -i inplace -v rmv="cron_MINUTE" '!index($0,rmv)' /tmp/mycron + # DOUBLE CHECK (awk = nawk or gawk -i ?) -crontest=$(cat /tmp/mycron | grep -F 'cron_MINUTE') -# ADD cron_MINUTE.sh TO cron ? +# Remove any previous line containing "SHELL & PATH" +# awk -i inplace -v rmv="cron_MINUTE" '!index($0,rmv)' /tmp/mycron +awk -i inplace -v rmv="SHELL" '!index($0,rmv)' /tmp/mycron +awk -i inplace -v rmv="PATH" '!index($0,rmv)' /tmp/mycron + +crontest=$(cat /tmp/mycron | grep -F 'cron_MINUTE.sh') + if [[ ! $crontest ]]; then - # NOT LOGGING TO FILE >> /tmp/astroport.log (TO MUCH DATA) - rm -f /tmp/newcron - [[ ! $(cat /tmp/mycron | grep -F 'SHELL') ]] && echo "SHELL=/bin/bash" >> /tmp/newcron - [[ ! $(cat /tmp/mycron | grep -F 'PATH') ]] && echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> /tmp/newcron + ## HEADER + [[ ! $(cat /tmp/mycron | grep -F 'SHELL') ]] && echo "SHELL=/bin/bash" > /tmp/newcron + [[ ! $(cat /tmp/mycron | grep -F 'PATH') ]] && echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> /tmp/newcron cat /tmp/mycron >> /tmp/newcron + # ADD cron_MINUTE.sh line echo "* * * * * /bin/bash $MY_PATH/../cron_MINUTE.sh 2>&1>/dev/null" >> /tmp/newcron crontab /tmp/newcron + echo "ASTROPORT is ON" else - echo "No operation needed. Your crontab is: " && crontab -l + ## HEADER + [[ ! $(cat /tmp/mycron | grep -F 'SHELL') ]] && echo "SHELL=/bin/bash" > /tmp/newcron + [[ ! $(cat /tmp/mycron | grep -F 'PATH') ]] && echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> /tmp/newcron + ## REMOVE cron_MINUTE.sh line + cat /tmp/mycron | grep -Ev 'cron_MINUTE.sh' >> /tmp/newcron + crontab /tmp/newcron + echo "ASTROPORT is OFF" fi + # Clean -rm -f /tmp/mycron +rm -f /tmp/mycron /tmp/newcron exit 0 diff --git a/zen/gchange_INIT.sh b/zen/gchange_INIT.sh index c0e81d4..3c6a7b1 100755 --- a/zen/gchange_INIT.sh +++ b/zen/gchange_INIT.sh @@ -41,20 +41,20 @@ cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ######################################################################## GCHANGE="https://data.gchange.fr" ## GET LATEST GCHANGE PROFILE -curl -s ${GCHANGE}/user/profile/${G1PUB} > /tmp/A_${G1PUB}.cache +curl -s ${GCHANGE}/user/profile/${G1PUB} > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange.json # UPDATE _g1.gchange_title -title=$(cat /tmp/A_${G1PUB}.cache | jq -r '._source.title') +title=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange.json | jq -r '._source.title') [[ $title ]] && echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title # UPDATE _g1.astroport_title with city title="Station $YOU@$XZUID" -city=$(cat /tmp/A_${G1PUB}.cache | jq -r '._source.city') +city=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange.json | jq -r '._source.city') [[ "$city" != "null" ]] && title="$title in $city" echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.astroport_title # UPDATE _g1.gchange_avatar.png -cat /tmp/A_${G1PUB}.cache | jq -r '._source.avatar._content' | base64 -d > "/home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_avatar.png" +cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange.json | jq -r '._source.avatar._content' | base64 -d > "/home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_avatar.png" # CREATE _nodename [[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename ]] && nodename=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename) @@ -78,7 +78,7 @@ export LANG=C.UTF-8 #attipix [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/.ipfsnodeid ]] && echo ${IPFSNODEID} > ~/.zen/ipfs/.${IPFSNODEID}/.ipfsnodeid ######################################################################## -# NODE DISK PERFORMANCE, manual remove ~/.ipfs/test.disk to run again +# NODE DISK PERFORMANCE, manual remove ~/.ipfs/test.disk (every week in cron_MINUTE) then run again if [[ ! -f ~/.ipfs/test.disk ]]; then diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4) echo "DISK PERFORMANCE TESTING : $diskperf" @@ -103,8 +103,8 @@ fi ######################################################################## echo "#################################################### Customisation TiddlyWiki" -# [[ ! -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID} && cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html -cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html +[[ ! $(cat ~/.zen/ipfs/.${IPFSNODEID}/index.html | grep ${IPFSNODEID}) ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID} && cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html +# cp -f ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)" wiki="/home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html" @@ -154,11 +154,11 @@ ipfsnodeid=${IamINBOOTSTRAP##*/} ################## SEND ipfstryme MESSAGES to FRIENDS rm -f /tmp/friend_of_mine ## Getting Gchange liking_me list -~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me +~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/liking_me ## Adding random bootstrap to liking_me list -~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#" | rev | cut -d '/' -f 1 | rev | shuf | head -n 1) >> /tmp/liking_me +~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#" | rev | cut -d '/' -f 1 | rev | shuf | head -n 1) >> ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/liking_me -for liking_me in $(cat /tmp/liking_me | sort | uniq); +for liking_me in $(cat ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/liking_me | sort | uniq); do [[ "$liking_me" == "" ]] && continue ## Protect from empty line !! ##### BOOTSTRAP AUTO LIKE BACK (NOT liking Myself) @@ -174,6 +174,12 @@ do fi + ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $liking_me) + echo "Reading stars.level from Stations IPNS Capsules." + starsin=$(ipfs --timeout=10s cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/stars.level) + starsout=$(ipfs --timeout=10s cat /ipns/$IPFSNODEID/.$IPFSNODEID/FRIENDS/$liking_me/stars.level) + echo "I received $starsin stars while I sent $starsout stars." + ##### CHECKING IF WE LIKE EACH OTHER (AVOID LIKING MYSELF) ~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me > /tmp/Gstars.json @@ -189,7 +195,12 @@ do # REFRESH & PUBLISH stars friends map stars="$(cat /tmp/Gstars.json | jq -r '.yours.level')" - [[ "$stars" == "null" || "$stars" == "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me && echo "$friend_of_mine NO STAR !! Removing $liking_me" && continue ## REMOVE NO GOOD FRIENDS (no star) + if [[ "$stars" == "null" || "$stars" == "" ]]; then + rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me + echo "$friend_of_mine NO STAR !! Removing $liking_me" + ## TODO : remove "ipfs pin" in "~/.zen/PIN/" + continue ## REMOVE NO GOOD FRIENDS (no star) + fi cp /tmp/Gstars.json ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ && rm -f /tmp/Gstars.json echo "$stars" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/stars.level && echo "***** $stars STARS *****" @@ -200,22 +211,26 @@ do # zuid=$(ipfs --timeout=10s cat /ipns/${ipfsnodeid}/.${ipfsnodeid}/_xbian.zuid) # [[ ${zuid} ]] && touch ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/${zuid} +## NOT USEFULL TRYING # SEND jaklis message if tryme.addr is different from last one - if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]] - then - echo "I AM $G1PUB" - echo "Sending IPFSTRYME message to $liking_me" - if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then - ~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr - else - echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr' - fi - echo "$friend_of_mine" >> /tmp/friend_of_mine - else - echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me" - fi - # MEMORIZE actual tryme.addr +# if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]] +# then +# echo "I AM $G1PUB" +# echo "Sending IPFSTRYME message to $liking_me" +# +# if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then +# ~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr +# else +# echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr' +# fi +# echo "$friend_of_mine" >> /tmp/friend_of_mine +# else +# echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me" +# fi + + # MEMORIZE actual tryme.addr (gchange_IPFS_swarm.sh is getting it from IPNS capsule) cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ + fi sleep $((1 + RANDOM % 2)) # SLOW DOWN diff --git a/zen/gchange_IPFS_swarm.sh b/zen/gchange_IPFS_swarm.sh index 31c8b75..2202dcf 100755 --- a/zen/gchange_IPFS_swarm.sh +++ b/zen/gchange_IPFS_swarm.sh @@ -32,26 +32,44 @@ echo $(date) ######################################################################## # Let's look for Friends and "IPFS swarm connect" with them ######################################################################## -# 1. Get Gchange "liking_me" people list (made by gchange_INIT.sh) -[[ ! -f /tmp/liking_me ]] && ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me +rm -f /tmp/liking_me ## FILE WILL BE REFRESHED -for liking_me in $(cat /tmp/liking_me | sort | uniq); +# Check liking_me station in my swarm FRIENDS +for swarm_frof in $(ls ~/.zen/ipfs_swarm/.*/FRIENDS/$G1PUB/stars.level | cut -d '/' -f 6 | cut -d '.' -f 2); ## FROM IPFS do + liking_me=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $swarm_frof) + ## PUBLISH /tmp/liking_me for ./tools/add_externIP_to_ipfstryme.sh + echo "$liking_me" >> /tmp/liking_me + + do_I_like=$(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$liking_me 2>/dev/null) +# Get Gchange "liking_me" people list (made by gchange_INIT.sh) +# [[ ! -f /tmp/liking_me ]] && ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me.try && [ ! -s /tmp/liking_me.try ] && cp /tmp/liking_me.try /tmp/liking_me && rm /tmp/liking_me.try +#for liking_me in $(cat /tmp/liking_me | sort | uniq); ## FROM GCHANGE +#do [[ "$liking_me" == "" || "$liking_me" == "$G1PUB" ]] && continue # DE TOUS CEUX QUI M'AIMENT JE VAIS LIRE LES MESSAGES pour collecter leurs ipfstryme vers ~/.zen/A_swarm_map.txt # SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt # Check if my like is reverse liking_me_count=$((liking_me_count+1)) - echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me" - ## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message - ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me + echo ">>>>>> CHECKING liking_me n° $liking_me_count " + ## IPFS WAY TO DO IT (LESS STRESS ON GCHANGE) + rm /tmp/ipfstryme.$liking_me 2>/dev/null + ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $liking_me) + echo "Getting /ipns/$ipfsnodeid/.$ipfsnodeid/tryme.addr ..." + ipfs --timeout=30s cat /ipns/$ipfsnodeid/.$ipfsnodeid/tryme.addr > /tmp/ipfstryme.$liking_me + + if [[ ! -f /tmp/ipfstryme.$liking_me ]]; then + echo ": READING 'ipfstryme' message from $liking_me" + ## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message + ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me + fi ## ZOMBIE NODE sends more that 300 ipfstryme ? ## [[ $(cat /tmp/ipfstryme.$liking_me | sort | uniq | wc -l) -gt 300 ]] && echo "THIS NODE IS A ZOMBIE..." && rm -f /tmp/ipfstryme.$liking_me && continue # CLEAN /tmp/ipfstryme.$liking_me > /tmp/ipfstryme.clean - for line in $(cat /tmp/ipfstryme.$liking_me); + for line in $(cat /tmp/ipfstryme.$liking_me | shuf); do ipfsnodeid=$(echo $line | rev | cut -d '/' -f 1 | rev) [[ $ipfsnodeid == "" ]] && break @@ -63,7 +81,6 @@ do echo "__________________________________________" done - for peerline in $(cat /tmp/ipfstryme.* | sort | uniq); do echo "======================================================" @@ -77,7 +94,7 @@ do [[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) [[ ! $whoisg1 ]] && continue - # KEEPING LAST ipfstryme MESSAGES only + # KEEPING LAST ipfstryme MESSAGES only (CAN BE REMOVED SOON WHEN FULL IPFS) nbmessage=0 for messageid in $(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$whoisg1" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id') do @@ -88,6 +105,10 @@ do [[ $nbmessage == 0 ]] && echo "NO ipfstryme MESSAGE from $whoisg1" && echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt && continue # SEND MESSAGE ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $whoisg1 -t 'Astroport' -m 'Aucun message de ta part https://copylaradio.com'" + ## CHECKING VALUE CAPSULE + starsin=$(ipfs --timeout=10s cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/stars.level) + starsout=$(ipfs --timeout=10s cat /ipns/$IPFSNODEID/.$IPFSNODEID/FRIENDS/$whoisg1/stars.level) + # REFRESH A_swarm_map.txt echo $peerline >> ~/.zen/A_swarm_map.txt cat ~/.zen/A_swarm_map.txt | sort | uniq > /tmp/A_swarm_map.txt @@ -95,20 +116,27 @@ do # FRIEND ADDRESS DISCOVERY echo "Am I friend with my FRIEND friend $whoisg1 ?" - friend_of_mine=$(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID - if [[ "$friend_of_mine" != "null" ]]; then + # ipfs cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/tryme.addr # IS my own /ipns/$IPFSNODEID/.$IPFSNODEID/tryme.addr + + # GCHANGE : friend_of_mine=$(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID + ## LOOKING IN SWARM CACHE + friend_of_mine=$(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$whoisg1 2>/dev/null) + if [[ $friend_of_mine ]]; then if [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]] then echo "OK FRIEND" # COUNT UNIQ FRIENDS friend_of_mine_count=$((friend_of_mine_count+1)) echo "$peerline" >> ~/.zen/A_my_swarm.txt - ipfs bootstrap add "$peerline" + # ipfs bootstrap add "$peerline" + ## NOW WILL BE USING Peering.Peers config else echo "ALREADY RECORDED FRIEND" fi + ## Sync ipfs_swarm ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid else + ## REMOVE FRIENDS DIRECTORY (should be removed from Astroport App) echo "NOT FULL FRIEND $ipfsnodeid / $whoisg1" [[ "$liking_me" != "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me # SEND ME A MESSAGE TO DECIDE WHAT TO DO ? @@ -127,17 +155,19 @@ echo "#################################################### I have $friend_of_mine_count friends amoung $liking_me_count liking me people __________________________________________ My actual #SWARM0" -ipfs swarm peers +# ipfs swarm peers echo $(date) echo "####################################################" -# ipfs SWARM shaping +# ipfs_SWARM_refresh [[ $(cat ~/.zen/A_my_swarm.txt | wc -l) -gt 0 ]] && ~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh && exit 0 || echo "SWARM LOST !! " -## SHOULD HAVE exit 0 before !! ######################################################################## -## SWARM LOST !! EMERGENCY RECOVERY !! TEST CODE +######################################################################## +## ERROR !! SHOULD HAVE exit 0 before !! +######################################################################## +## SWARM LOST !! EMERGENCY RECOVERY CODE !!! ######################################################################## ipfs bootstrap > /tmp/ipfs_bootstrap diff --git a/zen/ipfs_FRIENDS_refresh.sh b/zen/ipfs_FRIENDS_refresh.sh index abf7557..2a96ec5 100755 --- a/zen/ipfs_FRIENDS_refresh.sh +++ b/zen/ipfs_FRIENDS_refresh.sh @@ -32,14 +32,24 @@ IPFSNODEID=$(ipfs --timeout=20s id -f='\n') for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS | shuf); do [[ "$g1id" == "index.html" ]] && continue - ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id) + [ -d ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1id ] && ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id) || continue + echo "==============================================" + echo "$ipfsnodeid" + echo "==============================================" # Try to ping my friend OR continue - ipfs --timeout=10s ping -n 3 /p2p/$ipfsnodeid || continue + #ipfs --timeout=10s ping -n 3 /p2p/$ipfsnodeid || continue - echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/" - ipfs --timeout=90s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid - [[ -f /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && cat /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid || echo "NO ZUID" + #echo "REFRESHING Friend /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/" + #ipfs --timeout=90s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid + #[[ -f /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && cat /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid || echo "NO ZUID" + + echo "This is the list of your friend $g1id friends liking you" + ls -d ~/.zen/ipfs_swarm/.$ipfsnodeid/FRIENDS/*/ 2>/dev/null | rev | cut -d '/' -f 2 | rev + echo "LIKING YOU?" + ls -d ~/.zen/ipfs_swarm/.$ipfsnodeid/FRIENDS/$G1PUB/ 2>/dev/null | rev | cut -d '/' -f 2 | rev done + exit 0 + diff --git a/zen/ipfs_P2P_forward.sh b/zen/ipfs_P2P_forward.sh index 1d5d9f8..40cc95e 100755 --- a/zen/ipfs_P2P_forward.sh +++ b/zen/ipfs_P2P_forward.sh @@ -67,3 +67,13 @@ fi ipfs p2p ls + +## CONNECT WITH COMMAND +## ipfs cat /ipns/$IPFSNODEID/.$IPFSNODEID/x_ssh-$zuid.sh | bash +rm ~/.zen/ipfs/.$IPFSNODEID/x_ssh-$zuid.sh ## DEBUG +if [[ ! -f ~/.zen/ipfs/.$IPFSNODEID/x_ssh-$zuid.sh ]]; then + echo "echo 'Choix du port local pour ssh-$zuid ?'; read PORT; [[ ! \$(ipfs p2p ls | grep x/ssh-$zuid) ]] && ipfs --timeout=5s ping -n 1 /p2p/$IPFSNODEID && ipfs p2p forward /x/ssh-$zuid /ip4/127.0.0.1/tcp/\$PORT /p2p/$IPFSNODEID && ssh $YOU@127.0.0.1 -p \$PORT" > ~/.zen/ipfs/.$IPFSNODEID/x_ssh-$zuid.sh +fi + +## THIS PORT FORWARDING HUB COULD BE MADE MORE CONTROLABLE USING FRIENDSHIP LEVEL & IPFS BALISES + diff --git a/zen/ipfs_SWARM_refresh.sh b/zen/ipfs_SWARM_refresh.sh index a3bceb9..417d4ab 100755 --- a/zen/ipfs_SWARM_refresh.sh +++ b/zen/ipfs_SWARM_refresh.sh @@ -19,9 +19,10 @@ IPFSNODEID=$(ipfs --timeout=20s id -f='\n') # This script is controling IPFS swarm # Sync friends peers ~/.zen/ipfs/ into ~/.zen/ipfs_swarm/.IPFSNODEID's/ directories # add not friend_of_mine IPs to fail2ban +## CREATES index.html to web publish ######################################################################## ######################################################################## -mkdir -p ~/.zen/ipfs_swarm +[ ! -d ~/.zen/ipfs_swarm ] && mkdir -p ~/.zen/ipfs_swarm echo ' ___ _ _ __ __ _ _ _ _ _ _ __ | |_)|_(_ (_\ //\ |_)|\/| |_)|_|_|_)|_(_ |_| @@ -45,36 +46,44 @@ touch /tmp/treated.ipfs.swarm ######################################################################## ######################################################################## echo "******************************************************************" -echo "RETRIEVING MY OWN DATA FROM IPNS TO ~/.zen/ipfs_swarm" -#ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID +echo "REFRESHING MY OWN DATA FROM IPNS TO ~/.zen/ipfs_swarm" +find /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/ -type f -mtime +8 -exec rm '{}' \; +find /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/ -empty -type d -delete; +ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID ######################################################################## count=1 ipfs bootstrap > /tmp/ipfs_swarm_peers ipfs swarm peers >> /tmp/ipfs_swarm_peers -for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq); + +rm ~/.zen/A_peering_peers.txt +[[ ! -f ~/.ipfs/config.bak ]] && cp ~/.ipfs/config ~/.ipfs/config.bak ## Backup previous original +cp ~/.ipfs/config ~/.ipfs/config.new ## Prepare Peering.Peers changes + +# for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq); ## TODO ACTIVATE IN DEFCON 4 +for ipfsnodeid in $(cat ~/.zen/ipfs_swarm/.*/tryme.addr | grep -o '[^/]*$' | sort | uniq); do ## $ipfsnodeid already Treated ? [[ "$ipfsnodeid" == "$IPFSNODEID" ]] && continue - [[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && XID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid) || XID='' - [[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title ]] && XZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || XZUID='' - [[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT STATION - # [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue - [[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && echo "DEAD SWARM" && continue + [[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && XID=$(ipfs --timeout=20s cat /ipns/$ipfsnodeid/.$ipfsnodeid/_xbian.zuid) || XID='' + [[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title ]] && GZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || GZUID='' + # [[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT FRIEND STATION + # [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue ## TODO ACTIVATE IN DEFCON 4 + # [[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && echo "DEAD SWARM" && continue ## TODO ACTIVATE IN DEFCON 4 # control ip isLAN? - peerline=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | tail -n 1) + peerline=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | grep '/quic/' | head -n 1) ## Prefer quic protocol addresses [[ ! $peerline ]] && peerline=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | tail -n 1) - ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | tail -n 1) && [[ ! $ip ]] && continue + ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | grep '/quic/' | head -n 1 | awk -F '/' '{print $3}') && [[ ! $ip ]] && continue isLAN=$(echo $ip | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") nowdate=$(date) - # Convert ipfsnodeid into g1pub + # Convert ipfsnodeid into g1pub (only for 12D adresses, others are not Astroport) [[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt echo "#############################################################" - echo "### ANALYZING $ipfsnodeid ($ip) $XID $XZUID ###" + echo "### ANALYZING $ipfsnodeid ($ip) $XID $GZUID ###" echo "$peerline" myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) if [[ "$myfriendpeer" != "" ]]; @@ -92,8 +101,8 @@ do if [ $? != 0 ]; then grep -vEi $ip ~/.zen/A_my_swarm.txt echo $ipfsnodeid >> ~/.zen/A_dead_swarm.txt - echo "SEND MESSAGE ABOUT UNREACHABLE FRIEND $whoisg1 ($XID) ($XZUID)" - ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $G1PUB -t "ALERT" -m "Impossible de se synchroniser avec $whoisg1 ($XID) ($XZUID)" + echo "SEND MESSAGE ABOUT UNREACHABLE FRIEND $whoisg1 ($XID) ($GZUID)" + ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $G1PUB -t "ALERT" -m "Impossible de se synchroniser avec $whoisg1 ($XID) ($GZUID)" # KEEPING LAST 10 ALERT MESSAGES nbmessage=0 for messageid in $(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$G1PUB" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ALERT")' | jq -r '.id') @@ -104,26 +113,50 @@ do continue fi fi - ## Add to bootstrap if XID exists - [[ "$XID" != "" ]] && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline" - echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/" - ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid - if [ $? != 0 ]; - then - echo "TIMEOUT REACHED ___ REMOVE $ipfsnodeid FROM ~/.zen/A_my_swarm.txt"; - else + ################################################################ + ## Refresh bootstrap if XID exists + if [[ "$XID" != "" ]]; then + ipfs bootstrap rm "/ipfs/$ipfsnodeid" && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline" + ################################################################ - ## REFRESH stargates keys from my friend ################################################################ - mkdir -p ~/.zen/key/stargates/$whoisg1 - ipfs --timeout=60s get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/ - ## DECRYPT - if [[ $? == 0 ]]; then - [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate1" - [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate2" - [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate3" - [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate4" - [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate5" + echo "Removing 8 days older data from ~/.zen/ipfs_swarm/.$ipfsnodeid/" + find /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/ -type f -mtime +8 -exec rm '{}' \; + find /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/ -empty -type d -delete; + ################################################################ + echo "OK Friend SWARM REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/" + ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid + ################################################################ + if [ $? != 0 ]; + then + echo "TIMEOUT REACHED ___ REMOVE FROM .Peering.Peers "; + # jq '.Peering.Peers |= map( if .ID=="'$ipfsnodeid'" then del(.) else . end )' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new + else + ################################################################ + echo "@@ CREATING Peering.Peer @@" + echo ".Peering.Peers += { \"Addrs\": [], \"ID\": \"'$ipfsnodeid'\" }" + ################################################################ + Addr=$(echo "$peerline" | rev | cut -d '/' -f 2- | rev ) + IsAlreadythere=$(cat ~/.ipfs/config.new | grep \"$ipfsnodeid\") && echo $IsAlreadythere + if [[ ! $IsAlreadythere ]]; then + echo '{ "ID": "'$ipfsnodeid'", "Addrs": [] }' >> ~/.zen/A_peering_peers.txt + #jq '.Peering.Peers? += { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new + jq '.Peering.Peers[.Peering.Peers| length] |= . + { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new + fi + ################################################################ + echo "## REFRESH stargates keys from my friend" + ################################################################ + mkdir -p ~/.zen/key/stargates/$whoisg1 + ipfs --timeout=60s get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/ + ## DECRYPT STARGATE KEYS + if [[ $? == 0 ]]; then + [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate1" + [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate2" + [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate3" + [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate4" + [[ -f $HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate5" + ## KEYS COULD BE ADDED TO ~/.ipfs/keystore/ ? + fi fi fi else # if [[ "$myfriendpeer" != "" ]]; @@ -135,7 +168,7 @@ do # [[ -f ~/.zen/DEFCON ]] && export DEFCON=$(cat ~/.zen/DEFCON) || export DEFCON=$(cat ~/.zen/astrXbian/DEFCON) # like in crom_MINUTE.sh echo "!!! UNKNOWN FRIEND !!! $ip ___ $ipfsnodeid ________ # DEFCON : $DEFCON " - [[ -d ~/.zen/ipfs_swarm/.$ipfsnodeid ]] && rm -Rf ~/.zen/ipfs_swarm/.$ipfsnodeid && "REMOVE ipfs_swarm DIRECTORY" + [[ -d ~/.zen/ipfs_swarm/.$ipfsnodeid ]] && rm -Rf ~/.zen/ipfs_swarm/.$ipfsnodeid && echo "REMOVE ipfs_swarm DIRECTORY" ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | head -n 1) isLAN=$(echo $ip | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") @@ -178,7 +211,19 @@ do done -if [[ $DEFCON -eq 3 ]]; + +######################################################################## +## FIND LOCAL IPFS NODE - SERACH FOR FOAF stargate replications +######################################################################## +# SUBNET=$(ip route | tail -n 3 | cut -d ' ' -f 1) +# [[ ! $(which nmap) ]] && sudo apt-get install nmap -y && nmap --open -p 4001 $SUBNET +######################################################################## +######################################################################## + + +######################################################################## +if [[ $DEFCON -eq 3 ]];######################################################### +######################################################################## then ## DEFCON 3 # ACTIVATE PRIVATE SMARM !! 1ST BOOTSRAP creates and send a key to every level3 friends he knows (PUB) # RUN ONCE ONLY @@ -218,6 +263,8 @@ then ## DEFCON 3 fi fi fi + + ######################################################################## # REFRESH Film Serie Anime Youtube ${PREFIX}ASTRXBIAN index ######################################################################## @@ -231,25 +278,36 @@ do echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN cat ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | sed "s/anime;/film;/g" | sed '/^[[:space:]]*$/d' | grep -Ev "CAT;TMDB" | sort | uniq >> ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN done + +## ACCESS TO www-data FOR www/boris ACCESS +chown $YOU:www-data ~/.zen/ipfs/.$IPFSNODEID/*ASTRXBIAN +chmod 664 ~/.zen/ipfs/.$IPFSNODEID/*ASTRXBIAN + +## CORRECT SWARM FILE ACCESS RIGHTS to www-data +chmod 644 /home/$YOU/.zen/ipfs_swarm}/.*/astroport/kodi/vstream/*ASTRXBIAN + # Remove old database # rm ~/.kodi/userdata/addon_data/plugin.video.vstream/astroport_cache.db ######################################################################## -# REFRESH tiddlywiki WALL OF FRIENDS +## RENEW LIST OF FRIENDS index.html +######################################################################## +# REFRESH tiddlywiki WALL OF FRIENDS /ipns/${IPFSNODEID}/.${IPFSNODEID}/FRIENDS/index.html ######################################################################## zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)" +updated="$(date +"%Y-%m-%d_%H:%M")" echo "******************************************************************" echo "### PUBLISH tiddlywiki WALL OF FRIENDS ###" echo " - WIKI des Amis de ${IPFSNODEID} + - $zuid Friends - ${IPFSNODEID}

- Astroport × WIKI des Amis de $zuid + Astroport × WIKI des Amis de $zuid $updated

@@ -259,12 +317,12 @@ for wiki in $(ls ~/.zen/ipfs_swarm/.12D*/index.html | grep -Ev "${IPFSNODEID}" 2 ipfsnodeid=$(echo $wiki | cut -d '.' -f 3- | cut -d '/' -f 1) whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) echo "
  • - - \"$whoisg1\" + + \"$whoisg1\"

    - - \"$ipfsnodeid\" + + $ipfsnodeid