This commit is contained in:
Boris 2021-09-16 23:45:24 +02:00
commit bd2c4d29f9
20 changed files with 950 additions and 322 deletions

View File

@ -23,9 +23,9 @@ err() {
# CHECK if daemon is already running # 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 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 ipfs id && echo "ipfs swarm peers: " && ipfs swarm peers
echo "ipfs bootstrap list: " && ipfs bootstrap list 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" echo "Please RUN : sudo service ipfs stop"
exit 1 exit 1
fi fi
@ -120,8 +120,8 @@ ipfs config Datastore.StorageMax $diskSize
## Activate Rapid "ipfs p2p" ## Activate Rapid "ipfs p2p"
ipfs config --json Experimental.Libp2pStreamMounting true ipfs config --json Experimental.Libp2pStreamMounting true
ipfs config --json Experimental.P2pHttpProxy true ipfs config --json Experimental.P2pHttpProxy true
ipfs config --json Swarm.ConnMgr.LowWater 60 ipfs config --json Swarm.ConnMgr.LowWater 0
ipfs config --json Swarm.ConnMgr.HighWater 180 ipfs config --json Swarm.ConnMgr.HighWater 0
######### CLEAN DEFAULT BOOTSTRAP TO STAY INVISIBLE ########### ######### CLEAN DEFAULT BOOTSTRAP TO STAY INVISIBLE ###########
ipfs bootstrap rm --all ipfs bootstrap rm --all
########################################### ###########################################

View File

@ -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)** **Découvrez l'[Internet des gens](https://astroport.com)**
astrXbian est une première façon de programmer Astroport en le connectant avec KODI. 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. 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. 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. 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. 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) ## 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 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. 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)``` ```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 ## 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) [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é! - 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 -- -- 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. > 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 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). 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. 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). 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 # Magic commands
@ -250,7 +250,7 @@ ipfs ls /ipns/k51qzi5uqu5dk1nt1pfbtgfis4bep8pcip78w30xykhgba7y7wk0xyu8nwci5m
MYCODE=$(cat ~/.zen/ipfs_swarm/.$IPFSNODEID/.mycode); MYCODE=$(cat ~/.zen/ipfs_swarm/.$IPFSNODEID/.mycode);
for CODE in $(ls ~/.zen/ipfs_swarm/.12D*/.mycode); for CODE in $(ls ~/.zen/ipfs_swarm/.12D*/.mycode);
do do
echo echo
ipfsnodeid=$(echo $CODE | cut -d '.' -f 3 | cut -d '/' -f 1 ); ipfsnodeid=$(echo $CODE | cut -d '.' -f 3 | cut -d '/' -f 1 );
code=$(cat $CODE); code=$(cat $CODE);
IPNSCODE=$(ipfs cat /ipns/$ipfsnodeid/.$ipfsnodeid/.mycode) 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 # ANNEXES
## PRESENTATIONS VIDEO ## PRESENTATIONS VIDEO
### [Fred présente Astroport à la Ressourcerie](https://tube.p2p.legal/videos/watch/7ff4a8c9-7fb7-44ef-a1ee-bdf8ecc74cfe) ### [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) ### [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 - 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) - 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). 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. Le nouveau JEu du LOVE peut commencer.

140
actions/p4n.swarmscraper.sh Executable file
View File

@ -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='<id>\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

View File

@ -27,6 +27,16 @@ ME="${0##*/}"
[[ $(which ffmpeg) == "" ]] && echo "ERREUR! Installez ffmpeg" && echo "sudo apt install ffmpeg" && exit 1 [[ $(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 [[ $(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 # REMOVE GtkDialog errors for zenity
shopt -s expand_aliases shopt -s expand_aliases
alias zenity='zenity 2> >(grep -v GtkDialog >&2)' alias zenity='zenity 2> >(grep -v GtkDialog >&2)'
@ -43,7 +53,7 @@ IPFSNODEID=$(ipfs id -f='<id>\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/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) [[ -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!) # 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 [[ $CHOICE == "" ]] && exit 1
# LOWER CARACTERS # LOWER CARACTERS
@ -84,7 +94,7 @@ CAT=$(echo "${CHOICE}" | awk '{print tolower($0)}')
# UPPER CARACTERS # UPPER CARACTERS
CHOICE=$(echo "${CAT}" | awk '{print toupper($0)}') 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 [[ $PREFIX == "" ]] && exit 1
######################################################################## ########################################################################
@ -101,9 +111,8 @@ case ${CAT} in
######################################################################## ########################################################################
youtube) youtube)
zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Envoyez le LOG : https://git.p2p.legal .DEVELOPPEMENT' 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=$(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 [[ $YTURL == "" ]] && exit 1
# Create TEMP directory to copy $YID_$TITLE.$FILE_EXT # Create TEMP directory to copy $YID_$TITLE.$FILE_EXT
@ -113,7 +122,7 @@ mkdir -p ${YTEMP}
# youtube-dl $YTURL # youtube-dl $YTURL
echo "VIDEO $YTURL" echo "VIDEO $YTURL"
/usr/local/bin/youtube-dl -f '[height=720]/best' \ /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 --no-mtime -o "${YTEMP}/%(id)s&%(title)s.%(ext)s" $YTURL
# Get filename, extract ID, make destination dir and move copy. # 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) 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) 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)
MEDIAID="${YID}" MEDIAID="$REVSOURCE${YID}"
TITLE="${YNAME%.*}" TITLE="${YNAME%.*}"
MEDIAKEY="YOUTUBE_${MEDIAID}" MEDIAKEY="YOUTUBE_${MEDIAID}"
## CORRECT PARAMETERS to Make Kodi compatible YASTRXBIAN FILE ## 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 # 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}/ mkdir -p ${FILE_PATH} && mv -f ${YTEMP}/* ${FILE_PATH}/
# rename FILE_NAME to YNAME (URL clean) # rename FILE_NAME to YNAME (URL clean)
mv "${FILE_PATH}/${FILE_NAME}" "${FILE_PATH}/${YNAME}" && FILE_NAME="${YNAME}" 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 # CASE ## MP3
# _____ # _____
# _ __ ___ _ __|___ / # _ __ ___ _ __|___ /
@ -186,7 +232,7 @@ rm -Rf ${YTEMP}
######################################################################## ########################################################################
mp3) 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 # Create TEMP directory
YTEMP="/tmp/$(date -u +%s%N | cut -b1-13)" 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) 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) 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_" \ [[ ! $islink && "$song" != "" ]] && FILE_PATH="$HOME/astroport/$CAT/$artist/_o-o_" \
|| FILE_PATH="$HOME/astroport/$CAT/${YID}" || FILE_PATH="$HOME/astroport/$CAT/${YID}"
@ -384,7 +430,7 @@ echo "${CAT};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/
video) 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 ## GENERAL MEDIAKEY for uploaded video. Title + Decription + hashtag + hashipfs
# SELECT FILE TO ADD TO ASTROPORT/KODI # 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 # COPY UQLOAD LINKS DETECTED IN KODI LOG
##############################################
### TODO INSTALL FROM START and AUTO SCRAPE KODI LOG
##############################################
kodi) kodi)
# OPTION REMOVED
if [[ ! -f $HOME/.local/bin/uqload_downloader ]]; then if [[ ! -f $HOME/.local/bin/uqload_downloader ]]; then
cd /tmp cd /tmp
git clone https://github.com/papiche/uqload_downloader.git 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..." zenity --warning --width ${large} --text "UTILISEZ download_from_kodi_log.sh en ligne de commande..."
exit 0 exit 0
fi fi
;; ;;
######################################################################## ########################################################################
@ -462,12 +508,13 @@ esac
# ADD $FILE to IPFS / ASTROPORT / KODI # ADD $FILE to IPFS / ASTROPORT / KODI
echo "new_file_in_astroport.sh \"$HOME/astroport/${CAT}/${MEDIAID}/\" \"${FILE_NAME}\"" 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}/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" [[ "$CAT" == "film" || "$CAT" == "serie" ]] && CHOICE="TMDB"

View File

@ -27,8 +27,8 @@ IPFSNODEID=$(ipfs --timeout=10s id -f='<id>\n')
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
if [[ ! ${YOU} ]]; then if [[ ! ${YOU} ]]; then
# reduice water levels for swarm # reduice water levels for swarm
ipfs config --json Swarm.ConnMgr.LowWater 200 ipfs config --json Swarm.ConnMgr.LowWater 50
ipfs config --json Swarm.ConnMgr.HighWater 400 ipfs config --json Swarm.ConnMgr.HighWater 100
[[ "${USER}" == "xbian" ]] && sudo service ipfs restart || sudo systemctl restart ipfs [[ "${USER}" == "xbian" ]] && sudo service ipfs restart || sudo systemctl restart ipfs
echo "ERROR! ipfs daemon was not running. RELAUNCHING." echo "ERROR! ipfs daemon was not running. RELAUNCHING."
exit 1 exit 1
@ -36,7 +36,7 @@ fi
######################################################################## ########################################################################
# CORRECT VSTREAM ASTROPORT SITE/ART REMOVED AFTER PLUGIN UPDATE # 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/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 ### NO IP GATEWAY : EXIT
@ -77,11 +77,11 @@ dayofthemonth=$(date +%d)
weeknumber=$(date +%V) weeknumber=$(date +%V)
# WAKEUP TIME # WAKEUP TIME
if [[ ! -f /home/$YOU/.zen/A_Station_ON ]]; then if [[ ! -f /tmp/A_Station_ON ]]; then
echo "onheure=$heure; onminute=$minute; ontimebar=$timebar" > /home/$YOU/.zen/A_Station_ON echo "onheure=$heure; onminute=$minute; ontimebar=$timebar" > /tmp/A_Station_ON
[[ -f /tmp/A_Station_ON ]] && cp /tmp/A_Station_ON /home/$YOU/.zen/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 else
source /home/$YOU/.zen/A_Station_ON source /tmp/A_Station_ON
old=$ontimebar old=$ontimebar
new=$timebar new=$timebar
# feeding variables by using read and splitting with IFS # feeding variables by using read and splitting with IFS
@ -103,7 +103,10 @@ echo "RUNTIME $runtime mn ($timebar)"
if [[ $(($runtime % 4)) == 0 ]]; then if [[ $(($runtime % 4)) == 0 ]]; then
## PING ALL MY FRIENDS TO ENHANCE SWARM CONNECTIVITY ## PING ALL MY FRIENDS TO ENHANCE SWARM CONNECTIVITY
echo "## FRIENDS IPFS PINGing" 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 fi
######################################################################## ########################################################################
## CHECK & (RE)ACTIVATE ipfs p2p tunnels ## 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 ! # TODO: IDEA make gchange/ipfs/ipns refresh speed depending on ipfs swarm size and DEFCON level !
## SYNC GCHANGE EVERY 2 hours runtime ## SYNC GCHANGE EVERY 12 hours runtime
[[ $(($runtime % 97)) == 0 ]] && $MY_PATH/zen/gchange_INIT.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_INIT.txt [[ $(($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 20 mn runtime ## SYNC SWARM EVERY 6h runtime
[[ $(($runtime % 17)) == 0 ]] && $MY_PATH/zen/gchange_IPFS_swarm.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_IPFS_swarm.txt [[ $(($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 12 minutes # QUICK SYNC SWARM EVERY 30 minutes
[[ $(($runtime % 11)) == 0 ]] && $MY_PATH/zen/ipfs_FRIENDS_refresh.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.ipfs_FRIENDS_refresh.txt ## 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 ## TODO ACTIVATE/DESACTIVATE LOG
######################################################################## ########################################################################
# ACTIVATE ~/astroport directory monitoring (xbian only) # ACTIVATE ~/astroport directory monitoring (xbian only)
@ -228,9 +236,6 @@ fi
# #
# REFRESHing MEDIAKEY / ZenTAG nano DHTs => Zen File ECONOMY wallet cycle # 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 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 #### Refresh & publish MEDIAKEYs
$MY_PATH/zen/ipns_TAG_refresh.sh $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 rm -f ~/.zen/A_dead_swarm.txt
fi 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 # 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 ' echo '
# ____ ____ ____ ___ # ____ ____ ____ ___
# / __ \/ __ \ _ / __ < / # / __ \/ __ \ _ / __ < /
@ -305,6 +315,20 @@ echo '
# RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh # RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh
$MY_PATH/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 fi
### DISAPEAR ONE HOUR FROM IPFS SWARM ZOMBIES > 300 peers in swarm ### DISAPEAR ONE HOUR FROM IPFS SWARM ZOMBIES > 300 peers in swarm

View File

@ -2,7 +2,7 @@
* https://git.p2p.legal/axiom-team/astrXbian * https://git.p2p.legal/axiom-team/astrXbian
* https://oasis.astroport.com * https://oasis.astroport.com
* https://colibris-wiki.org/astroport * https://colibris-wiki.org/astroport
# Liens annexes # Liens annexes
@ -23,7 +23,7 @@
# jaklis : commandes de messaging / like # 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' ~/.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 ## SEND MONITORING MESSAGE TO onelove
@ -32,3 +32,15 @@
## LINKING ME PEOPLE ## LINKING ME PEOPLE
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' ~/.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
```

View File

@ -21,7 +21,7 @@ for i in git fail2ban inotify-tools curl net-tools libsodium* python3-dev python
done 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 #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 if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
sudo apt install -y $i sudo apt install -y $i
fi fi
@ -47,7 +47,7 @@ python3 -m pip install -U pip
python3 -m pip install -U setuptools wheel python3 -m pip install -U setuptools wheel
python3 -m pip install -U cryptography Ed25519 base58 google protobuf duniterpy python3 -m pip install -U cryptography Ed25519 base58 google protobuf duniterpy
if [[ "$USER" == "pi" ]]; then ## PROPOSE QR_CODE PRINTER 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 read saisie
if [[ $saisie != "" ]]; then if [[ $saisie != "" ]]; then
sudo apt install printer-driver-all cups -y 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 ~/.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 cd ~/.zen/astrXbian/zen/jaklis
./setup.sh ./setup.sh
@ -117,19 +117,16 @@ fi
mkdir -p ~/astroport/film mkdir -p ~/astroport/film
mkdir -p ~/astroport/serie mkdir -p ~/astroport/serie
mkdir -p ~/astroport/anime 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 ## 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" 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 chown -R $USER:$wwwuser ~/astroport/www
sudo chmod -R g+rw ~/astroport/www sudo chmod -R g+rw ~/astroport/www
####################################################################### #######################################################################
## CREATE symlinks for ~/.zen/www/swarm & me ## CREATE symlinks for ~/.zen/www/swarm & me
sudo chown -R $USER:www-data /.zen/astrXbian/www/boris sudo chown -R $USER:www-data ~/.zen/astrXbian/www/boris
sudo chmod -R g+rw /.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_swarm ~/.zen/astrXbian/www/boris/swarm
ln -s /home/$USER/.zen/ipfs ~/.zen/astrXbian/www/boris/me ln -s /home/$USER/.zen/ipfs ~/.zen/astrXbian/www/boris/me

257
ipfs4astroport.sh Executable file
View File

@ -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 <<EOF
[Unit]
Description=IPFS daemon
After=network.target
[Service]
User=_USER_
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --enable-gc
Restart=on-failure
CPUAccounting=true
CPUQuota=60%
[Install]
WantedBy=multi-user.target
EOF
sudo cp -f /tmp/ipfs.service /etc/systemd/system/
sudo sed -i "s/_USER_/$USER/g" /etc/systemd/system/ipfs.service
echo "Activating ipfs daemon >>>>>>>>>>>>>>>>>> "
# 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

View File

@ -5,6 +5,7 @@ require_once('functions.php');
$videosList = array(); $videosList = array();
// HOWTO PASS Query parameters to exec ?
exec("/bin/bash -c './get_astrxbian_index.sh F'", $videos); exec("/bin/bash -c './get_astrxbian_index.sh F'", $videos);
exec("/bin/bash -c './check_my_wallet.sh'", $gg1); exec("/bin/bash -c './check_my_wallet.sh'", $gg1);

View File

@ -5,8 +5,10 @@
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
######################################################################## ########################################################################
PREFIX="$1" 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 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 # 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

View File

@ -13,28 +13,39 @@ echo '
# qo-op # qo-op
############# '$MY_PATH/$ME' ############# '$MY_PATH/$ME'
######################################################################## ########################################################################
# ex: ./'$ME' # Activate / Desactivate ASTROPORT cron_MINUTE.sh job
# VERIFY CRON for cron_MINUTE.sh and ACTIVATE it
########################################################################' ########################################################################'
# Get crontab # Get crontab
crontab -l > /tmp/mycron 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 ?) # DOUBLE CHECK (awk = nawk or gawk -i ?)
crontest=$(cat /tmp/mycron | grep -F 'cron_MINUTE') # Remove any previous line containing "SHELL & PATH"
# ADD cron_MINUTE.sh TO cron ? # 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 if [[ ! $crontest ]]; then
# NOT LOGGING TO FILE >> /tmp/astroport.log (TO MUCH DATA) ## HEADER
rm -f /tmp/newcron [[ ! $(cat /tmp/mycron | grep -F 'SHELL') ]] && echo "SHELL=/bin/bash" > /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
[[ ! $(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 cat /tmp/mycron >> /tmp/newcron
# ADD cron_MINUTE.sh line
echo "* * * * * /bin/bash $MY_PATH/../cron_MINUTE.sh 2>&1>/dev/null" >> /tmp/newcron echo "* * * * * /bin/bash $MY_PATH/../cron_MINUTE.sh 2>&1>/dev/null" >> /tmp/newcron
crontab /tmp/newcron crontab /tmp/newcron
echo "ASTROPORT is ON"
else 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 fi
# Clean # Clean
rm -f /tmp/mycron rm -f /tmp/mycron /tmp/newcron
exit 0 exit 0

View File

@ -41,20 +41,20 @@ cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
######################################################################## ########################################################################
GCHANGE="https://data.gchange.fr" GCHANGE="https://data.gchange.fr"
## GET LATEST GCHANGE PROFILE ## 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 # 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 [[ $title ]] && echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title
# UPDATE _g1.astroport_title with city # UPDATE _g1.astroport_title with city
title="Station $YOU@$XZUID" 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" [[ "$city" != "null" ]] && title="$title in $city"
echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.astroport_title echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.astroport_title
# UPDATE _g1.gchange_avatar.png # 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 # CREATE _nodename
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename ]] && nodename=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_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 [[ ! -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 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) 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" echo "DISK PERFORMANCE TESTING : $diskperf"
@ -103,8 +103,8 @@ fi
######################################################################## ########################################################################
echo "#################################################### echo "####################################################
Customisation TiddlyWiki" 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 [[ ! $(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 ~/.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)" zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)"
wiki="/home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html" wiki="/home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html"
@ -154,11 +154,11 @@ ipfsnodeid=${IamINBOOTSTRAP##*/}
################## SEND ipfstryme MESSAGES to FRIENDS ################## SEND ipfstryme MESSAGES to FRIENDS
rm -f /tmp/friend_of_mine rm -f /tmp/friend_of_mine
## Getting Gchange liking_me list ## 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 ## 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 do
[[ "$liking_me" == "" ]] && continue ## Protect from empty line !! [[ "$liking_me" == "" ]] && continue ## Protect from empty line !!
##### BOOTSTRAP AUTO LIKE BACK (NOT liking Myself) ##### BOOTSTRAP AUTO LIKE BACK (NOT liking Myself)
@ -174,6 +174,12 @@ do
fi 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) ##### 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 ~/.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 # REFRESH & PUBLISH stars friends map
stars="$(cat /tmp/Gstars.json | jq -r '.yours.level')" 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 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 *****" 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=$(ipfs --timeout=10s cat /ipns/${ipfsnodeid}/.${ipfsnodeid}/_xbian.zuid)
# [[ ${zuid} ]] && touch ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/${zuid} # [[ ${zuid} ]] && touch ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/${zuid}
## NOT USEFULL TRYING
# SEND jaklis message if tryme.addr is different from last one # 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) ]] # if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]]
then # then
echo "I AM $G1PUB" # echo "I AM $G1PUB"
echo "Sending IPFSTRYME message to $liking_me" # 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 # if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then
else # ~/.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
echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr' # else
fi # echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr'
echo "$friend_of_mine" >> /tmp/friend_of_mine # fi
else # echo "$friend_of_mine" >> /tmp/friend_of_mine
echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me" # else
fi # echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me"
# MEMORIZE actual tryme.addr # 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/ cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/
fi fi
sleep $((1 + RANDOM % 2)) # SLOW DOWN sleep $((1 + RANDOM % 2)) # SLOW DOWN

View File

@ -32,26 +32,44 @@ echo $(date)
######################################################################## ########################################################################
# Let's look for Friends and "IPFS swarm connect" with them # Let's look for Friends and "IPFS swarm connect" with them
######################################################################## ########################################################################
# 1. Get Gchange "liking_me" people list (made by gchange_INIT.sh) rm -f /tmp/liking_me ## FILE WILL BE REFRESHED
[[ ! -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
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 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 [[ "$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 # 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 # SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt
# Check if my like is reverse # Check if my like is reverse
liking_me_count=$((liking_me_count+1)) liking_me_count=$((liking_me_count+1))
echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me" echo ">>>>>> CHECKING liking_me n° $liking_me_count "
## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message ## IPFS WAY TO DO IT (LESS STRESS ON GCHANGE)
~/.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 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 ? ## 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 ## [[ $(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 # CLEAN /tmp/ipfstryme.$liking_me
> /tmp/ipfstryme.clean > /tmp/ipfstryme.clean
for line in $(cat /tmp/ipfstryme.$liking_me); for line in $(cat /tmp/ipfstryme.$liking_me | shuf);
do do
ipfsnodeid=$(echo $line | rev | cut -d '/' -f 1 | rev) ipfsnodeid=$(echo $line | rev | cut -d '/' -f 1 | rev)
[[ $ipfsnodeid == "" ]] && break [[ $ipfsnodeid == "" ]] && break
@ -63,7 +81,6 @@ do
echo "__________________________________________" echo "__________________________________________"
done done
for peerline in $(cat /tmp/ipfstryme.* | sort | uniq); for peerline in $(cat /tmp/ipfstryme.* | sort | uniq);
do do
echo "======================================================" echo "======================================================"
@ -77,7 +94,7 @@ do
[[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) [[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
[[ ! $whoisg1 ]] && continue [[ ! $whoisg1 ]] && continue
# KEEPING LAST ipfstryme MESSAGES only # KEEPING LAST ipfstryme MESSAGES only (CAN BE REMOVED SOON WHEN FULL IPFS)
nbmessage=0 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') 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 do
@ -88,6 +105,10 @@ do
[[ $nbmessage == 0 ]] && echo "NO ipfstryme MESSAGE from $whoisg1" && echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt && continue [[ $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'" # 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 # REFRESH A_swarm_map.txt
echo $peerline >> ~/.zen/A_swarm_map.txt echo $peerline >> ~/.zen/A_swarm_map.txt
cat ~/.zen/A_swarm_map.txt | sort | uniq > /tmp/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 # FRIEND ADDRESS DISCOVERY
echo "Am I friend with my FRIEND friend $whoisg1 ?" 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 # ipfs cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/tryme.addr # IS my own /ipns/$IPFSNODEID/.$IPFSNODEID/tryme.addr
if [[ "$friend_of_mine" != "null" ]]; then
# 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) ]] if [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]]
then then
echo "OK FRIEND" echo "OK FRIEND"
# COUNT UNIQ FRIENDS # COUNT UNIQ FRIENDS
friend_of_mine_count=$((friend_of_mine_count+1)) friend_of_mine_count=$((friend_of_mine_count+1))
echo "$peerline" >> ~/.zen/A_my_swarm.txt echo "$peerline" >> ~/.zen/A_my_swarm.txt
ipfs bootstrap add "$peerline" # ipfs bootstrap add "$peerline"
## NOW WILL BE USING Peering.Peers config
else else
echo "ALREADY RECORDED FRIEND" echo "ALREADY RECORDED FRIEND"
fi fi
## Sync ipfs_swarm
ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
else else
## REMOVE FRIENDS DIRECTORY (should be removed from Astroport App)
echo "NOT FULL FRIEND $ipfsnodeid / $whoisg1" echo "NOT FULL FRIEND $ipfsnodeid / $whoisg1"
[[ "$liking_me" != "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me [[ "$liking_me" != "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me
# SEND ME A MESSAGE TO DECIDE WHAT TO DO ? # 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 I have $friend_of_mine_count friends amoung $liking_me_count liking me people
__________________________________________ __________________________________________
My actual #SWARM0" My actual #SWARM0"
ipfs swarm peers # ipfs swarm peers
echo $(date) echo $(date)
echo "####################################################" 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 !! " [[ $(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 ipfs bootstrap > /tmp/ipfs_bootstrap

View File

@ -32,14 +32,24 @@ IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n')
for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS | shuf); for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS | shuf);
do do
[[ "$g1id" == "index.html" ]] && continue [[ "$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 # 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/" #echo "REFRESHING Friend /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
ipfs --timeout=90s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid #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" #[[ -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 done
exit 0 exit 0

View File

@ -67,3 +67,13 @@ fi
ipfs p2p ls 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

View File

@ -19,9 +19,10 @@ IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n')
# This script is controling IPFS swarm # This script is controling IPFS swarm
# Sync friends peers ~/.zen/ipfs/ into ~/.zen/ipfs_swarm/.IPFSNODEID's/ directories # Sync friends peers ~/.zen/ipfs/ into ~/.zen/ipfs_swarm/.IPFSNODEID's/ directories
# add not friend_of_mine IPs to fail2ban # 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 ' echo '
___ _ _ __ __ _ _ _ _ _ _ __ ___ _ _ __ __ _ _ _ _ _ _ __
| |_)|_(_ (_\ //\ |_)|\/| |_)|_|_|_)|_(_ |_| | |_)|_(_ (_\ //\ |_)|\/| |_)|_|_|_)|_(_ |_|
@ -45,36 +46,44 @@ touch /tmp/treated.ipfs.swarm
######################################################################## ########################################################################
######################################################################## ########################################################################
echo "******************************************************************" echo "******************************************************************"
echo "RETRIEVING MY OWN DATA FROM IPNS TO ~/.zen/ipfs_swarm" echo "REFRESHING MY OWN DATA FROM IPNS TO ~/.zen/ipfs_swarm"
#ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$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;
ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID
######################################################################## ########################################################################
count=1 count=1
ipfs bootstrap > /tmp/ipfs_swarm_peers ipfs bootstrap > /tmp/ipfs_swarm_peers
ipfs swarm peers >> /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 do
## $ipfsnodeid already Treated ? ## $ipfsnodeid already Treated ?
[[ "$ipfsnodeid" == "$IPFSNODEID" ]] && continue [[ "$ipfsnodeid" == "$IPFSNODEID" ]] && continue
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && XID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid) || XID='' [[ -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 ]] && XZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || XZUID='' [[ -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 STATION # [[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT FRIEND STATION
# [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue # [[ $(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 # [[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && echo "DEAD SWARM" && continue ## TODO ACTIVATE IN DEFCON 4
# control ip isLAN? # 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) [[ ! $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])/") 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) 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 [[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt
echo "#############################################################" echo "#############################################################"
echo "### ANALYZING $ipfsnodeid ($ip) $XID $XZUID ###" echo "### ANALYZING $ipfsnodeid ($ip) $XID $GZUID ###"
echo "$peerline" echo "$peerline"
myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid )
if [[ "$myfriendpeer" != "" ]]; if [[ "$myfriendpeer" != "" ]];
@ -92,8 +101,8 @@ do
if [ $? != 0 ]; then if [ $? != 0 ]; then
grep -vEi $ip ~/.zen/A_my_swarm.txt grep -vEi $ip ~/.zen/A_my_swarm.txt
echo $ipfsnodeid >> ~/.zen/A_dead_swarm.txt echo $ipfsnodeid >> ~/.zen/A_dead_swarm.txt
echo "SEND MESSAGE ABOUT UNREACHABLE FRIEND $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) ($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) ($GZUID)"
# KEEPING LAST 10 ALERT MESSAGES # KEEPING LAST 10 ALERT MESSAGES
nbmessage=0 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') 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 continue
fi fi
fi fi
## Add to bootstrap if XID exists ################################################################
[[ "$XID" != "" ]] && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline" ## Refresh bootstrap if XID exists
echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/" if [[ "$XID" != "" ]]; then
ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid ipfs bootstrap rm "/ipfs/$ipfsnodeid" && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline"
if [ $? != 0 ];
then
echo "TIMEOUT REACHED ___ REMOVE $ipfsnodeid FROM ~/.zen/A_my_swarm.txt";
else
################################################################ ################################################################
## REFRESH stargates keys from my friend
################################################################ ################################################################
mkdir -p ~/.zen/key/stargates/$whoisg1 echo "Removing 8 days older data from ~/.zen/ipfs_swarm/.$ipfsnodeid/"
ipfs --timeout=60s get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/ find /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/ -type f -mtime +8 -exec rm '{}' \;
## DECRYPT find /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/ -empty -type d -delete;
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" echo "OK Friend SWARM REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
[[ -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" ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
[[ -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" if [ $? != 0 ];
[[ -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" 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
fi fi
else # if [[ "$myfriendpeer" != "" ]]; 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 [[ -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 " 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) 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])/") 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 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 then ## DEFCON 3
# ACTIVATE PRIVATE SMARM !! 1ST BOOTSRAP creates and send a key to every level3 friends he knows (PUB) # ACTIVATE PRIVATE SMARM !! 1ST BOOTSRAP creates and send a key to every level3 friends he knows (PUB)
# RUN ONCE ONLY # RUN ONCE ONLY
@ -218,6 +263,8 @@ then ## DEFCON 3
fi fi
fi fi
fi fi
######################################################################## ########################################################################
# REFRESH Film Serie Anime Youtube ${PREFIX}ASTRXBIAN index # 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 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 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 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 # Remove old database
# rm ~/.kodi/userdata/addon_data/plugin.video.vstream/astroport_cache.db # 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)" zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)"
updated="$(date +"%Y-%m-%d_%H:%M")"
echo "******************************************************************" echo "******************************************************************"
echo "### PUBLISH tiddlywiki WALL OF FRIENDS ###" echo "### PUBLISH tiddlywiki WALL OF FRIENDS ###"
echo "<html> echo "<html>
<head> <head>
<title>WIKI des Amis de ${IPFSNODEID}</title> <title> - $zuid Friends - ${IPFSNODEID}</title>
<link rel='stylesheet' href='https://tube.copylaradio.com/crowdbunker.css' type='text/css' /> <link rel='stylesheet' href='https://tube.copylaradio.com/crowdbunker.css' type='text/css' />
<link rel='icon' type='image/png' href='https://tube.copylaradio.com/astrocrowdbunker.png' /> <link rel='icon' type='image/png' href='https://tube.copylaradio.com/astrocrowdbunker.png' />
</head> </head>
<body><header> <body><header>
<h1> <h1>
<a href='https://astroport.com'><span>Astroport</span> × <span>WIKI des Amis de $zuid</span></a> <a href='https://astroport.com'><span>Astroport</span> × <span>WIKI des Amis de $zuid $updated</span></a>
</h1> </h1>
</header> </header>
@ -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) ipfsnodeid=$(echo $wiki | cut -d '.' -f 3- | cut -d '/' -f 1)
whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
echo "<li> echo "<li>
<a href=\"https://oasis.astroport.com/ipns/$ipfsnodeid/.$ipfsnodeid/index.html\"> <a target=\"gchange\" href=\"https://www.gchange.fr/#/app/user/$whoisg1/\">
<img src=\"https://oasis.astroport.com/ipns/$ipfsnodeid/.$ipfsnodeid/QR.png\" alt=\"$whoisg1\" /> <img src=\"https://tube.copylaradio.com/ipns/$ipfsnodeid/.$ipfsnodeid/QR.png\" alt=\"$whoisg1\" />
</a> </a>
<p class='video-title'> <p class='video-title'>
<a href=\"https://oasis.astroport.com/ipns/$ipfsnodeid/.$ipfsnodeid/index.html\"> <a href=\"https://tube.copylaradio.com/ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/index.html\">
\"$ipfsnodeid\" $ipfsnodeid
</a> </a>
</p> </p>
<iframe id=\"$ipfsnodeid\" <iframe id=\"$ipfsnodeid\"
@ -282,7 +340,10 @@ echo "</main></body></html>" >> ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/index.html
######################################################################## ########################################################################
## [[ $(which wp) ]] && ~/.zen/astrXbian/zen/wordpress_channel.sh ## [[ $(which wp) ]] && ~/.zen/astrXbian/zen/wordpress_channel.sh
# REFRESH IPNS SELF PUBLISH ## CLEAN RUN p4n.swarmscraper.sh
~/.zen/astrXbian/actions/p4n.swarmscraper.sh
# IPNS SELF PUBLISH = mise à jour balise Station
######################################################################## ########################################################################
~/.zen/astrXbian/zen/ipns_self_publish.sh ~/.zen/astrXbian/zen/ipns_self_publish.sh
######################################################################## ########################################################################

View File

@ -30,20 +30,7 @@ G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
echo "## FRIENDS IPFS PINGing" echo "## FRIENDS IPFS PINGing"
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=3s -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 ]] && ipfs ping --timeout=3s -n 3 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
########################################################################
# 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
# [[ "$G1PUB" == "Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS" ]] && ipfs name publish -k mastodon $(cat ~/.zen/ipfs/.${IPFSNODEID}/.mycode)
# echo "MyCODE = $MyCODE CODE is published
# ipfs ls /ipns/k51qzi5uqu5dk1nt1pfbtgfis4bep8pcip78w30xykhgba7y7wk0xyu8nwci5m"
########################################################################
# ACTIVATE TO CONTROL SWARM STATION SAME CODE VERSION
########################################################################
echo " echo "
_ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \
@ -66,6 +53,7 @@ count=0
for mediakey in $(ls ~/.zen/ipfs/.${IPFSNODEID}/KEY/); # Alternative search for mediakey in $(ls ~/.zen/ipfs/.${IPFSNODEID}/KEY/); # Alternative search
do do
[[ "${mediakey}" == "" ]] && continue ## prevent empty mediakey [[ "${mediakey}" == "" ]] && continue ## prevent empty mediakey
[[ ! $(echo "${mediakey}" | grep "TMDB_") ]] && continue ## REFRESH ONLY TMDB (level 1), youtube is level 0
IPNSLINK=$(ipfs key list -l | grep ${mediakey} | cut -d ' ' -f 1) IPNSLINK=$(ipfs key list -l | grep ${mediakey} | cut -d ' ' -f 1)
[[ "${IPNSLINK}" == "" ]] && continue ## prevent empty IPNSLINK [[ "${IPNSLINK}" == "" ]] && continue ## prevent empty IPNSLINK
count=$((count+1)) && echo "$count) " count=$((count+1)) && echo "$count) "
@ -177,7 +165,7 @@ do
<source src=\"$TUBELINK\" type=\"$MIMETYPE\"> <source src=\"$TUBELINK\" type=\"$MIMETYPE\">
</$HTMLTAG> </$HTMLTAG>
<h1 class='video-title'><a href=\"$LOCALTUBELINK\">$TITLE $MIMETYPE (Conservez OFFLINE)</a></h1> <h1 class='video-title'><a href=\"$LOCALTUBELINK\">$TITLE $MIMETYPE (Conservez OFFLINE)</a></h1>
<h1 class='video-title'><a target='copylaradio' href='https://www.copylaradio.com/forum/traductions-4/question/expliquer-ipfs-en-francais-35''>Aidez nous à traduire, publier la documentation Astroport/IPFS</a> ?</h1> <h1 class='video-title'><a target='copylaradio' href='https://www.copylaradio.com/makers''>Recrutement Astrocrew! Offres de Stage, Job - Astroport - Exploration P2P</a> ?</h1>
</article> </article>
</main> </main>
<center><br>Ce media possède un G1 portefeuille avec lequel il paye son hébergement. <center><br>Ce media possède un G1 portefeuille avec lequel il paye son hébergement.
@ -249,6 +237,8 @@ for ipnslink in $(ls ~/.zen/PIN/*/IPNSLINK); do
ipfsid=$(echo $ipnslink | cut -d '/' -f 6) ipfsid=$(echo $ipnslink | cut -d '/' -f 6)
mediakey=$(cat ~/.zen/PIN/${ipfsid}/MEDIAKEY) mediakey=$(cat ~/.zen/PIN/${ipfsid}/MEDIAKEY)
[[ ! $(echo "${mediakey}" | grep "TMDB_") ]] && continue ## REFRESH ONLY TMDB (level 1), youtube is level 0
[[ ! $(ipfs key list | grep ${mediakey}) ]] && echo "ERROR MISSING MEDIAKEY" && continue [[ ! $(ipfs key list | grep ${mediakey}) ]] && echo "ERROR MISSING MEDIAKEY" && continue
## GET ACTUAL IPNS .chain VALUE ## GET ACTUAL IPNS .chain VALUE

View File

@ -5,12 +5,13 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}" ME="${0##*/}"
countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l) 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 [[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0
######################################################################## ########################################################################
IPFSNODEID=$(ipfs --timeout=30s id -f='<id>\n') IPFSNODEID=$(ipfs --timeout=30s id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "ipfs TIMEOUT" && exit 1 [[ $IPFSNODEID == "" ]] && echo "ipfs TIMEOUT" && exit 1
######################################################################## ########################################################################
## TESSERACT DOUBLE ACTION
########################################################################
echo "Adding ~/.zen/ipfs to IPFS" echo "Adding ~/.zen/ipfs to IPFS"
MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1) MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
OLDCHAIN=$(cat ~/.zen/ipfs/.${IPFSNODEID}/.chain) OLDCHAIN=$(cat ~/.zen/ipfs/.${IPFSNODEID}/.chain)
@ -21,7 +22,7 @@ then
echo $MIPFS > ~/.zen/ipfs/.${IPFSNODEID}/.chain echo $MIPFS > ~/.zen/ipfs/.${IPFSNODEID}/.chain
MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1) MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs --timeout=180s name publish --quieter /ipfs/$MIPFS) NODEIPNS=$(ipfs --timeout=180s name publish --quieter /ipfs/$MIPFS)
echo "$NODEIPNS:TIME:$(cat ~/.zen/ipfs/.${IPFSNODEID}/.timestamp):CHAIN:$(cat ~/.zen/ipfs/.${IPFSNODEID}/.chain)" echo "$NODEIPNS:TIME:$(cat ~/.zen/ipfs/.${IPFSNODEID}/.timestamp):CHAIN:$(cat ~/.zen/ipfs/.${IPFSNODEID}/.chain)"
fi fi
echo "PUBLISHED ~/.zen/ipfs TO http://127.0.0.1:8181/ipns/$IPFSNODEID" echo "PUBLISHED ~/.zen/ipfs TO http://127.0.0.1:8181/ipns/$IPFSNODEID"
######################################################################## ########################################################################

View File

@ -25,7 +25,7 @@ G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
######################################################################## ########################################################################
path="$1" path="$1"
# Add trailing / if needed # Add trailing / if needed
length=${#path} length=${#path}
last_char=${path:length-1:1} last_char=${path:length-1:1}
[[ $last_char != "/" ]] && path="$path/"; : [[ $last_char != "/" ]] && path="$path/"; :
@ -49,8 +49,8 @@ PREFIX=$(echo "$TYPE" | head -c 1 | awk '{ print toupper($0) }' ) # ex: F, Y, M
# File is placed in ROOT ~/astroport ? # File is placed in ROOT ~/astroport ?
if [[ $PREFIX == "" ]] if [[ $PREFIX == "" ]]
then then
[[ "$USER" != "xbian" ]] && zenity --warning --width 300 --text "Désolé votre fichier ne peut pas être traité" [[ "$USER" != "xbian" ]] && zenity --warning --width 300 --text "Désolé votre fichier ne peut pas être traité"
er="$er | WARNING. $TYPE is root file UNTREATED" && echo "$er" && exit 1 er="$er | WARNING. $TYPE is root file UNTREATED" && echo "$er" && exit 1
fi fi
[[ ! -d ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/ ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/ [[ ! -d ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/ ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/
@ -59,41 +59,41 @@ fi
# EXTRACT INDEX REFERENCE : TMDB or YOUTUBE (can be extended with new ) # EXTRACT INDEX REFERENCE : TMDB or YOUTUBE (can be extended with new )
######################################################################## ########################################################################
case ${CAT} in case ${CAT} in
video) video)
INDEXPREFIX="VIDEO_" INDEXPREFIX="VIDEO_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE="${file%.*}" TITLE="${file%.*}"
;; ;;
youtube) youtube)
INDEXPREFIX="YOUTUBE_" INDEXPREFIX="YOUTUBE_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE="${file%.*}" TITLE="${file%.*}"
;; ;;
mp3) mp3)
## DIFFERENT TREATMENT ## DIFFERENT TREATMENT
INDEXPREFIX="MP3_" INDEXPREFIX="MP3_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE=$(echo "$file" | cut -d "&" -f 2-) TITLE=$(echo "$file" | cut -d "&" -f 2-)
er="$er | Please use new_mp3_in_astroport.sh ... EXIT" er="$er | Please use new_mp3_in_astroport.sh ... EXIT"
echo "$er" echo "$er"
exit 1 exit 1
;; ;;
film | serie) film | serie)
INDEXPREFIX="TMDB_" INDEXPREFIX="TMDB_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) # Path contains TMDB id REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) # Path contains TMDB id
if ! [[ "$REFERENCE" =~ ^[0-9]+$ ]] # ${REFERENCE} NOT A NUMBER if ! [[ "$REFERENCE" =~ ^[0-9]+$ ]] # ${REFERENCE} NOT A NUMBER
then then
er="$er | ERROR: $path BAD TMDB code. Get it from https://www.themoviedb.org/ or use your 06 phone number" er="$er | ERROR: $path BAD TMDB code. Get it from https://www.themoviedb.org/ or use your 06 phone number"
echo "$er" echo "$er"
exit 1 exit 1
fi fi
;; ;;
## TODO ADD "httrack" for website copying ## TODO ADD "httrack" for website copying
## httrack "https://wiki.lowtechlab.org" -O "./wiki.lowtechlab.org" "+*.lowtechlab.org/*" -v -%l "fr" ## httrack "https://wiki.lowtechlab.org" -O "./wiki.lowtechlab.org" "+*.lowtechlab.org/*" -v -%l "fr"
## ##
*) *)
er="$CAT inconnu" && echo "$er" && exit 1 er="$CAT inconnu" && echo "$er" && exit 1
;; ;;
esac esac
MEDIAKEY="${INDEXPREFIX}${REFERENCE}" MEDIAKEY="${INDEXPREFIX}${REFERENCE}"
@ -102,28 +102,28 @@ MEDIAKEY="${INDEXPREFIX}${REFERENCE}"
######################################################################## ########################################################################
echo "SEARCH for ;$REFERENCE; in ${PREFIX}ASTRXBIAN" echo "SEARCH for ;$REFERENCE; in ${PREFIX}ASTRXBIAN"
if [[ ${REFERENCE:0:1} != "0" ]]; then ## REFERENCE COULD BE A PHONE NUMBER (not in TMDB copy force) if [[ ${REFERENCE:0:1} != "0" ]]; then ## REFERENCE COULD BE A PHONE NUMBER (not in TMDB copy force)
isREFERENCEinINDEX=$(grep ";$REFERENCE;" ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN ) isREFERENCEinINDEX=$(grep ";$REFERENCE;" ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN )
if [[ ${isREFERENCEinINDEX} ]] if [[ ${isREFERENCEinINDEX} ]]
then then
if [[ -d ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB} ]] if [[ -d ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB} ]]
then then
# FILE IS MINE, NEW VERSION?! replacing it in INDEX # FILE IS MINE, NEW VERSION?! replacing it in INDEX
ipnslink=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link) ipnslink=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link)
echo "FOUND IPNS ${MEDIAKEY} = $ipnslink" echo "FOUND IPNS ${MEDIAKEY} = $ipnslink"
# DELETING GCHANGE AD, WILL BE CREATED AGAIN # DELETING GCHANGE AD, WILL BE CREATED AGAIN
gchangeAD=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad) gchangeAD=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad)
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" deleteoffer -i $gchangeAD ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" deleteoffer -i $gchangeAD
rm ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad rm ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad
else else
er="$er | FILE IS ALREADY EXISTING FROM ANOTHER FRIEND" && echo "$er" er="$er | FILE IS ALREADY EXISTING FROM ANOTHER FRIEND" && echo "$er"
## SEND messages to warn about need to Unify MEDIAKEY IPNS KEY ## SEND messages to warn about need to Unify MEDIAKEY IPNS KEY
ipfsnodeid=$(echo ${isREFERENCEinINDEX} | tail -n 1 | cut -d '.' -f 3- | cut -d '/' -f 1) ipfsnodeid=$(echo ${isREFERENCEinINDEX} | tail -n 1 | cut -d '.' -f 3- | cut -d '/' -f 1)
destg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) destg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
[[ "$IPFSNODEID" != "$ipfsnodeid" ]] && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $destg1 -t "MEDIAKEY COLLISION ${MEDIAKEY}" -m "Conflit de MEDIAKEY. Choisir quelle clef IPNS conserver..." [[ "$IPFSNODEID" != "$ipfsnodeid" ]] && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $destg1 -t "MEDIAKEY COLLISION ${MEDIAKEY}" -m "Conflit de MEDIAKEY. Choisir quelle clef IPNS conserver..."
## ##
fi fi
fi fi
fi fi
@ -148,30 +148,31 @@ URLENCODE_FILE_NAME=$(echo ${file} | jq -Rr @uri)
## CREATE NEW ipns KEY : ${MEDIAKEY} ## CREATE NEW ipns KEY : ${MEDIAKEY}
######################################################################## ########################################################################
## IPFS SELF IPNS DATA STORAGE ## IPFS SELF IPNS DATA STORAGE
## ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ ## ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/
######################################################################## ########################################################################
if [[ ! $(ipfs key list | grep "${MEDIAKEY}") ]]; then if [[ ! $(ipfs key list | grep "${MEDIAKEY}") ]]; then
## IPNS KEY CREATION ## IPNS KEY CREATION
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB} mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}
KEY=$(ipfs key gen "${MEDIAKEY}") KEY=$(ipfs key gen "${MEDIAKEY}")
KEYFILE=$(ls -t ~/.ipfs/keystore/ | head -n 1) KEYFILE=$(ls -t ~/.ipfs/keystore/ | head -n 1)
fi fi
## IS IT NEW IPNS KEY? ## IS IT NEW IPNS KEY?
if [[ $KEY ]]; then if [[ $KEY ]]; then
# memorize IPNS key filename for easiest exchange echo "CREATING NEW IPNS MEDIAKEY"
echo "$KEYFILE" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename # memorize IPNS key filename for easiest exchange
# Publishing IPNS key echo "$KEYFILE" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename
echo "$KEY" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link # Publishing IPNS key
# CREATE .zen = ZEN economic value echo "$KEY" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link
touch ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.zen # CREATE .zen = ZEN economic value
# CREATE other encrypted copies for friends depending DEFCON & stars touch ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.zen
# > STARGATE 1 - 2 - 3 - 4 - 5 !! # CREATE other encrypted copies for friends depending DEFCON & stars
################ ENCRYPT keystore/$KEYFILE # > STARGATE 1 - 2 - 3 - 4 - 5 !!
################ ENCRYPT keystore/$KEYFILE
else else
## OLD IPNS KEY ## OLD IPNS KEY
KEY=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link) KEY=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link)
KEYFILE=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename) KEYFILE=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename)
fi fi
[[ ! $KEY ]] && echo "FATAL ERROR" && exit 1 [[ ! $KEY ]] && echo "FATAL ERROR" && exit 1
@ -204,9 +205,10 @@ PINnode=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $nodeid)
echo "ASK AUTOPIN to $PINnode" echo "ASK AUTOPIN to $PINnode"
## CREATE $PINnode IPFS communication directory ## CREATE $PINnode IPFS communication directory
[[ ! -d ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode} ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode} [[ ! -d ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode} ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}
## ENCRYPT .ipfsid & .ipfs.filelink ## ENCRYPT .ipfsid & .ipfs.filelink (THESE FILES ARE
$MY_PATH/tools/natools.py encrypt -p $PINnode -i /tmp/.ipfs.filelink -o "~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.ipfs.filelink.encrypt" $MY_PATH/tools/natools.py encrypt -p $PINnode -i /tmp/.ipfs.filelink -o "~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.ipfs.filelink.encrypt"
$MY_PATH/tools/natools.py encrypt -p $PINnode -i /tmp/.ipfsid -o "~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.ipfsid.encrypt" $MY_PATH/tools/natools.py encrypt -p $PINnode -i /tmp/.ipfsid -o "~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/${PINnode}/.ipfsid.encrypt"
# .ipfsid.encrypt is searched by each Station running ./zen/tools/autoPINfriends.sh
######################################################################## ########################################################################
## GREAT natools can convert IPNS MEDIAKEY into .dunikey file ## GREAT natools can convert IPNS MEDIAKEY into .dunikey file
@ -259,7 +261,8 @@ rm /tmp/.ipfsid
######################################################################## ########################################################################
## ADD "ajouter_video.txt" and "video.json" will be SELF IPNS publish data ## ADD "ajouter_video.txt" and "video.json" will be SELF IPNS publish data
[[ -f ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt ]] && cp -f ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ ## ENCRYPT TO STOP CLEAR DATA LEAKING
[[ -f ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt ]] && cp -f ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/
[[ -f ~/astroport/${TYPE}/${REFERENCE}/video.json ]] && cp -f ~/astroport/${TYPE}/${REFERENCE}/video.json ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ [[ -f ~/astroport/${TYPE}/${REFERENCE}/video.json ]] && cp -f ~/astroport/${TYPE}/${REFERENCE}/video.json ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/
######################################################################## ########################################################################
@ -267,11 +270,11 @@ rm /tmp/.ipfsid
## EXPLANATIONS ## EXPLANATIONS
######################################################################## ########################################################################
# What is being in ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ # What is being in ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/
# is published on http://127.0.0.1:8181/ipns/$KEY/ # is published on http://127.0.0.1:8181/ipns/$KEY/ AND ipfs ls /ipns/$KEY/
######################################################################## ########################################################################
######################################################################## ########################################################################
# CONTRACTS, are small App (fulljs or jquery + nginx backend app server) # CONTRACTS, are small App (fulljs or jquery + nginx backend app server)
# They must decrypt IPFS after succeeding a chalenge (, +/- n zen, ...) # They must decrypt IPFS after succeeding a chalenge (, +/- n zen, ...)
######################################################################## ########################################################################
# Contract App Examples (ipns_TAG_refresh.sh makes MEDIAKEY evolution) # Contract App Examples (ipns_TAG_refresh.sh makes MEDIAKEY evolution)
# Counting video views = +1 .views.counter => decrypt key # Counting video views = +1 .views.counter => decrypt key
@ -409,49 +412,49 @@ IPNS=$(ipfs name publish --quieter --key="${MEDIAKEY}" $NEWIPFS)
######################################################################## ########################################################################
######################################################################## ########################################################################
# POST TRAITEMENTS # POST TRAITEMENTS
######################################################################## ########################################################################
# film/serie PUBLISH "ajouter_video.txt" for KODI # film/serie PUBLISH "ajouter_video.txt" for KODI
######################################################################## ########################################################################
if [[ "${CAT}" =~ ^(film|serie|youtube)$ ]] if [[ "${CAT}" =~ ^(film|serie|youtube)$ ]]
then then
## CREATE GCHANGE AD ## CREATE GCHANGE AD
if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad && "${CAT}" != "youtube" ]] if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad && "${CAT}" != "youtube" ]]
then then
GOFFER=$(~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" setoffer -t "${TITLE} #astroport #${MEDIAKEY}" -d "${TITLE} https://tube.copylaradio.com/ipns/$IPNS/ Faites un don à son portefeuille pour le conserver dans le Mediacenter des Amis - https://CopyLaRadio.com - https://astroport.com" -p $HOME/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/QR.png) GOFFER=$(~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" setoffer -t "${TITLE} #astroport #${MEDIAKEY}" -d "${TITLE} https://tube.copylaradio.com/ipns/$IPNS/ Faites un don à son portefeuille pour le conserver dans le Mediacenter des Amis - https://CopyLaRadio.com - https://astroport.com" -p $HOME/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/QR.png)
echo $GOFFER > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad echo $GOFFER > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad
NEWIPFS=$(ipfs add -rHq ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ | tail -n 1 ) NEWIPFS=$(ipfs add -rHq ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ | tail -n 1 )
IPNS=$(ipfs name publish --quieter --key="${MEDIAKEY}" $NEWIPFS) IPNS=$(ipfs name publish --quieter --key="${MEDIAKEY}" $NEWIPFS)
fi fi
echo "Annonce gchange : $(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad)" echo "Annonce gchange : $(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad)"
######################################################################## ########################################################################
# ${PREFIX}ASTRXBIAN FILE : Add Header # ${PREFIX}ASTRXBIAN FILE : Add Header
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN ]] \ [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN ]] \
&& echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN && echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN
# ADD NEW LINE TO INDEX # ADD NEW LINE TO INDEX
if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt ]] if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt ]]
then then
line=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt | sed "s/_IPFSREPFILEID_/$IPFSREPFILEID/g" | sed "s/_IPNSKEY_/$IPNS/g" ) line=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt | sed "s/_IPFSREPFILEID_/$IPFSREPFILEID/g" | sed "s/_IPNSKEY_/$IPNS/g" )
else else
FILE_RES=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "${path}${file}" | cut -d "x" -f 2) FILE_RES=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "${path}${file}" | cut -d "x" -f 2)
RES=${FILE_RES%?}0p RES=${FILE_RES%?}0p
line="$CAT;${REFERENCE};$YEAR;$TITLE;$SAISON;;${IPNS};$RES;/ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME" line="$CAT;${REFERENCE};$YEAR;$TITLE;$SAISON;;${IPNS};$RES;/ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME"
fi fi
echo "-------------------- UPDATE MY INDEX -----------------------------" echo "-------------------- UPDATE MY INDEX -----------------------------"
echo "$line" echo "$line"
echo "$line" >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN echo "$line" >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN
echo "UPDATE IPNS ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ajouter_video.txt" echo "UPDATE IPNS ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ajouter_video.txt"
echo "$line" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt echo "$line" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt
## UPDATE SOURCE ajouter_video.txt FILE ## UPDATE SOURCE ajouter_video.txt FILE
cp -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt cp -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt ~/astroport/${TYPE}/${REFERENCE}/ajouter_video.txt
######################################################################## ########################################################################
## TODO: ACTIVATE SUB DEFCON 4 MODE = encrypt/decrypt file in $G1DEST subdirectory ## TODO: ACTIVATE SUB DEFCON 4 MODE = encrypt/decrypt file in $G1DEST subdirectory
######################################################################## ########################################################################
echo "----------------- REFRESH LOCAL KODI INDEX ----------------------" echo "----------------- REFRESH LOCAL KODI INDEX ----------------------"
cat ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | sort | uniq > ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN cat ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | sort | uniq > ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN
fi fi
######################################################################## ########################################################################
@ -459,21 +462,21 @@ fi
######################################################################## ########################################################################
if [[ "${CAT}" == "video" ]] if [[ "${CAT}" == "video" ]]
then then
## REPLACE IPFS / IPNS REFERENCE IN video.json (Maybe cyphered later) ## REPLACE IPFS / IPNS REFERENCE IN video.json (Maybe cyphered later)
cat ~/astroport/${CAT}/${MEDIAKEY}/video.json | sed "s/_IPFSREPFILEID_/$IPFSREPFILEID/g" | sed "s/_IPNSKEY_/$IPNS/g" >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN cat ~/astroport/${CAT}/${MEDIAKEY}/video.json | sed "s/_IPFSREPFILEID_/$IPFSREPFILEID/g" | sed "s/_IPNSKEY_/$IPNS/g" >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN
fi fi
######################################################################## #########################################################################
# PUBLISH YOUTUBE video to /astroport/wordpress/ # PUBLISH YOUTUBE video to /astroport/wordpress/ DATA NOT USED ANY MORE... semaphore à régler
######################################################################## #########################################################################
if [[ "${CAT}" == "youtube" ]] if [[ "${CAT}" == "youtube" ]]
then then
## CREATE astroport call to Astroport/Wordpress stations ## CREATE astroport call to Astroport/Wordpress stations
if [[ ! -d ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY} ]]; then if [[ ! -d ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY} ]]; then
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY} mkdir -p ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY}
echo "1" > ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY}/do echo "1" > ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY}/do
fi fi
fi fi
######################################################################## ########################################################################

View File

@ -14,34 +14,48 @@ YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail
IPFSNODEID=$(ipfs id -f='<id>\n') IPFSNODEID=$(ipfs id -f='<id>\n')
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
## RUN FROM ./zen/gchange_INIT.sh
# This script is called to manage SWARM autoPIN # This script is called to manage SWARM autoPIN
# Actual behaviour is to accept anything from # Actual behaviour is to accept anything from
# SOURCE: ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipfsid.encrypt (new_file_in_astroport.sh) # SOURCE: ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipfsid.encrypt (new_file_in_astroport.sh)
# MEDIAKEY: ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipns.mediakey.encrypt # MEDIAKEY: ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/${PINnode}/.ipns.mediakey.encrypt
## AUTO PIN FRIENDS ACTIVATION ## AUTO PIN FRIENDS ACTIVATION
## TODO Source should rename ".ipfsid.encrypt" to stop asking for autoPIN
for astrofile in $(ls -dt ~/.zen/ipfs_swarm/.12D*/KEY/*/*/${G1PUB}/.ipfsid.encrypt | shuf); for astrofile in $(ls -dt ~/.zen/ipfs_swarm/.12D*/KEY/*/*/${G1PUB}/.ipfsid.encrypt | shuf);
do do
astrofilelinksec=$(echo "$astrofile" | sed "s/.ipfsid.encrypt/.ipfs.filelink.encrypt/g")
# decrypt $astrofile # decrypt $astrofile
mediakey=$(echo "$astrofile" | cut -d '/' -f 8 ) mediakey=$(echo "$astrofile" | cut -d '/' -f 8 )
keytype=$(echo "$mediakey" | cut -d '_' -f 1 ) keytype=$(echo "$mediakey" | cut -d '_' -f 1 )
mediaid=$(echo "$mediakey" | cut -d '_' -f 2 ) mediaid=$(echo "$mediakey" | cut -d '_' -f 2- )
g1source=$(echo "$astrofile" | cut -d '/' -f 9 ) g1source=$(echo "$astrofile" | cut -d '/' -f 9 )
ipfsnodesource=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1source) ipfsnodesource=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1source)
# CHECK FRIENDSHIP LEVELS
# only talk to 12D not Qm
[[ "${ipfsnodesource:0:2}" == "Qm" ]] && echo "NO COMPATIBLE STATION $ipfsnodesource" && continue
starsin=$(ipfs --timeout=10s cat /ipns/$ipfsnodesource/.$ipfsnodesource/FRIENDS/$G1PUB/stars.level)
starsout=$(ipfs --timeout=10s cat /ipns/$IPFSNODEID/.$IPFSNODEID/FRIENDS/$g1source/stars.level)
## PIN COULD BE ONLY ALLOWED FROM SOME LEVEL FRIENDS ONLY
echo "RX $starsin / TX $starsout (stars)"
echo "$mediakey PINNING ASKED BY $g1source" echo "$mediakey PINNING ASKED BY $g1source"
## VERIFY CONTRACT... TODO ## DECRYPT FINAL IPFS LINKS...
$MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$astrofile" -o "/tmp/ipfslink.txt" $MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$astrofile" -o "/tmp/ipfslink.txt"
astrofile=$(cat /tmp/ipfslink.txt) astrofile=$(cat /tmp/ipfslink.txt) && [[ -d ~/.zen/PIN/${astrofile} ]] && echo "removing old pin reference" && rm -Rf ~/.zen/PIN/${astrofile}/ ## REMOVE OLD PIN REFERENCE to keep directory (easier reading)
# PINNING NEW FILE $MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$astrofilelinksec" -o "/tmp/ipfsfilelink.txt"
echo "SHOULD I PIN ~/.zen/PIN/${astrofile} ??" ipfsrepidfile=$(cat /tmp/ipfsfilelink.txt | rev | cut -d '/' -f 2 | rev)
if [[ ! -d ~/.zen/PIN/${astrofile} ]]; # PINNING NEW DIRECTORY & FILE
echo "SHOULD I PIN ~/.zen/PIN/${ipfsrepidfile} ??"
if [[ ! -d ~/.zen/PIN/${ipfsrepidfile} ]];
then then
echo "PIN : $astrofile" echo "PIN ADD : $ipfsrepidfile"
ipfs pin add /ipfs/$astrofile && mkdir -p ~/.zen/PIN/${astrofile}/ ipfs pin add /ipfs/$ipfsrepidfile && mkdir -p ~/.zen/PIN/${ipfsrepidfile}/
echo "RECORDING MY PIN ~/.zen/PIN/" echo "RECORDING NEW PIN ~/.zen/PIN/${ipfsrepidfile}"
[[ -d ~/.zen/PIN/${astrofile} ]] && echo "0" > ~/.zen/PIN/${astrofile}/$G1PUB [[ -d ~/.zen/PIN/${ipfsrepidfile} ]] && echo "$G1PUB" > ~/.zen/PIN/${ipfsrepidfile}/$ipfsnodesource
## COPY IPNS MEDIAKEY TO ipfs keystore (UPDATE IF STATION OFF) ## COPY IPNS MEDIAKEY TO ipfs keystore (UPDATE IF STATION OFF)
echo "ADD ${mediakey} to my local keystore (SO I CAN UPDATE IPNS LINK LATER with ipns_TAG_refresh.sh)" echo "ADD ${mediakey} to my local keystore (SO I CAN UPDATE IPNS LINK LATER with ipns_TAG_refresh.sh)"
@ -49,9 +63,9 @@ do
$MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/ipfs_swarm/.${ipfsnodesource}/KEY/${mediakey}/${g1source}/${G1PUB}/.ipns.mediakey.encrypt" -o "/tmp/ipns.mediakey" $MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/ipfs_swarm/.${ipfsnodesource}/KEY/${mediakey}/${g1source}/${G1PUB}/.ipns.mediakey.encrypt" -o "/tmp/ipns.mediakey"
if [[ -f /tmp/ipns.mediakey ]]; then if [[ -f /tmp/ipns.mediakey ]]; then
KEYFILE=$($MY_PATH/give_me_keystore_filename.py "${mediakey}") KEYFILE=$($MY_PATH/give_me_keystore_filename.py "${mediakey}")
[[ ! -f ~/.ipfs/keystore/$KEYFILE ]] && mv /tmp/ipns.mediakey ~/.ipfs/keystore/$KEYFILE || ( echo "$KEYFILE already existing in local keystore. EXIT" && continue ) [[ ! -f ~/.ipfs/keystore/$KEYFILE ]] && mv /tmp/ipns.mediakey ~/.ipfs/keystore/$KEYFILE || ( echo "$KEYFILE already existing in local keystore. CONTINUE" )
echo "${mediakey}" > ~/.zen/PIN/${astrofile}/MEDIAKEY echo "${mediakey}" > ~/.zen/PIN/${ipfsrepidfile}/MEDIAKEY
echo "$(ipfs key list -l | grep ${mediakey} | cut -d ' ' -f 1)" > ~/.zen/PIN/${astrofile}/IPNSLINK echo "$(ipfs key list -l | grep ${mediakey} | cut -d ' ' -f 1)" > ~/.zen/PIN/${ipfsrepidfile}/IPNSLINK
## USED BY BOOTSTRAP IN ipns_TAG_refresh.sh TO REFRESH MEDIAKEY publishing ## USED BY BOOTSTRAP IN ipns_TAG_refresh.sh TO REFRESH MEDIAKEY publishing
fi fi
fi fi
@ -60,14 +74,17 @@ do
continue continue
fi fi
########## PIN MAKES YOU OFFICIAL FASTRXBIAN FILM DISTRIBUTOR
############################################ PINNING NODE MAKES ALL HIS FRIENDS MOVIES AVAILABLE TO ALL ############################################ PINNING NODE MAKES ALL HIS FRIENDS MOVIES AVAILABLE TO ALL
## TODO : DECIDE TO ACTIVATE THIS BEHAVIOUR OR NOT ? ## TODO : DECIDE TO ACTIVATE THIS BEHAVIOUR OR NOT ?
## Copy FASTRXBIAN index (makes movies available for ALL) ## Copy FASTRXBIAN index (makes movies available for ALL)
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN ]] && echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN ]] && echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN
[[ "$keytype" == "TMDB" ]] && cat ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/FASTRXBIAN | grep ";$mediaid;" | tail -n 1 >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN if [[ "$keytype" == "TMDB" ]]; then
cat ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/FASTRXBIAN | grep ";$mediaid;" | tail -n 1 >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN
cat ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN | uniq > ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/FASTRXBIAN
fi
# EXIT AFTER ONE PIN ONLY (next PIN in cron_MINUTE time) # EXIT AFTER ONE PIN ONLY (next PIN in cron_MINUTE time)
[[ -f ~/.zen/PIN/${astrofile}/$G1PUB ]] && break [[ -f ~/.zen/PIN/${ipfsrepidfile}/$G1PUB ]] && break
done done
exit 0 exit 0