Compare commits

...

98 Commits

Author SHA1 Message Date
Boris e1a5106c7b ENH: templatisation 2021-09-17 01:49:39 +02:00
Boris bd2c4d29f9 Merge branch 'master' of https://git.p2p.legal/axiom-team/astrXbian 2021-09-16 23:45:24 +02:00
fred 086011ae29 --no-playlist 2021-09-16 22:07:58 +02:00
fred e459f0e0b5 FIND AND CONNECT WITH YOUR FRIENDS 2021-09-14 20:14:11 +02:00
fred 4bfbcfa3b6 AJOUT DANS IPFS new_file_in_astroport.sh 2021-09-14 20:13:55 +02:00
fred 36ac42fb2c SUBNET 4001 port discovery for FOAF stargate replications 2021-09-14 20:13:21 +02:00
fred 2d6acc3735 rm -f /tmp/liking_me ## FILE WILL BE REFRESHED 2021-09-14 20:12:00 +02:00
fred e2e4c61aa5 30 mn swarm refresh 2021-09-14 18:38:33 +02:00
fred c4e2049bdc nmap 2021-09-14 17:01:42 +02:00
fred d0d553df3b geotag france 2021-09-13 22:54:33 +02:00
fred 6b01af45d1 prefered APN 2021-09-13 18:36:24 +02:00
fred 36daeb2077 ipfsnodeid=$(echo "$geodata" | cut -d '/' -f 6 | cut -d '.' -f 2) 2021-09-13 18:15:25 +02:00
fred 23d3bdeeee log 2021-09-13 18:14:11 +02:00
fred e88f343e7b various optimisations 2021-09-13 18:10:35 +02:00
fred 0fe77cef96 CLEAN RUN p4n.swarmscraper.sh 2021-09-13 03:42:03 +02:00
fred c0a02d90c7 reduce ping frequecy to every 4 mn 2021-09-13 03:20:42 +02:00
fred 18152cc009 protect from empty lid 2021-09-13 03:16:43 +02:00
fred 69f52be3b4 check XID from /ipns/ 2021-09-13 03:09:07 +02:00
fred d2c367c2f5 timeout chromium 2021-09-13 02:44:25 +02:00
fred 68561f1a6e --timeout 30000 2021-09-13 02:36:25 +02:00
fred 63bf1f227a RUN p4n scraper 2021-09-13 02:34:17 +02:00
fred a0577990b6 get screenshot.png 2021-09-13 02:29:23 +02:00
fred 50bfa20634 --disable-gpu 2021-09-13 02:27:10 +02:00
fred 47021af263 .$IPFSNODEID/x_ssh-$zuid.sh 2021-09-13 01:09:32 +02:00
fred 411e5931e6 imagemagick ttf-mscorefonts-installer 2021-09-13 01:02:40 +02:00
fred 8a54596433 363 mn ipfs restart (Peering.Peers reload), can be longer 2021-09-13 01:02:13 +02:00
fred 25275d3d1e actions/p4n.swarmscraper.sh 2021-09-13 00:53:49 +02:00
fred 31f16240ee remove older than 8 days swarm data 2021-09-12 23:52:09 +02:00
fred eea656361c getting p4n spots geodata 2021-09-12 19:27:12 +02:00
fred f67ff5b1d8 SYNC SWARM EVERY 21 minutes 2021-09-12 18:19:32 +02:00
fred 348fdc5bd1 astroport swarm easy pace 2021-09-12 18:18:46 +02:00
fred 12c933f532 makers 2021-09-12 17:10:11 +02:00
fred 50309d6833 ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/liking_me 2021-09-12 16:14:19 +02:00
fred 066804f31f wep 2021-09-12 03:04:08 +02:00
fred 30ee0565e8 ping average 2021-09-12 00:35:16 +02:00
fred c3860d80f3 trying to remove... 2021-09-11 02:10:19 +02:00
fred b6e73fded9 IsAlreadythere pb 2021-09-11 01:57:01 +02:00
fred e2dea7e5af peering peers only the one who sync 2021-09-11 01:44:15 +02:00
fred d74b7528b5 ~/.ipfs/config.new Peering.Peers & ipfs daemon restart 2021-09-11 01:35:24 +02:00
fred 57f1ba826a cat ~/.zen/A_peering_peers.txt 2021-09-11 00:08:13 +02:00
fred e3d1085191 ~/.ipfs/config 2021-09-10 01:08:35 +02:00
fred 703b30a9af ~/.ipfs/config.new 2021-09-10 00:15:39 +02:00
fred 85e241fd12 getting Peering.Peers from "ipfs_swarm" and restart ipfs every 6h 2021-09-10 00:07:56 +02:00
fred 4607e7ba3d ## REFRESH ONLY TMDB (level 1), youtube is level 0 2021-09-09 21:29:10 +02:00
fred f7a937b5b1 ## REFRESH ONLY TMDB (level 1), youtube is level 0 2021-09-09 21:27:23 +02:00
fred 980dc12b28 ## CORRECT SWARM FILE ACCESS RIGHTS to www-data 2021-09-08 14:58:40 +02:00
fred 7b38faf703 corrections 2021-09-07 14:03:39 +02:00
fred ee15961eec Remove MP3 option (need mazash infra to be activated) 2021-09-07 14:03:05 +02:00
fred 66585b1bf3 ping friends every 2 mn 2021-09-07 14:02:19 +02:00
fred 282359fb67 going to control Peering.Peers 2021-09-06 17:25:22 +02:00
fred fd47c1bb82 Prefer 4001 port addresses 2021-09-06 11:11:12 +02:00
fred 36f0fbaea2 get further. need more test 2021-09-06 02:19:30 +02:00
fred 1bf1651699 light install ipfs + astroport 2021-09-06 01:35:54 +02:00
fred e9d6159f8c schedule sync on start first 30 mn 2021-09-06 01:07:59 +02:00
fred cdfe5a0bcd Switch ASTROPORT ON / OFF 2021-09-06 01:04:57 +02:00
fred aa3a07e06a ## ACCESS TO www-data FOR www/boris ACCESS 2021-09-06 01:04:19 +02:00
fred a5d21041a1 RUN FROM ./zen/gchange_INIT.sh 2021-09-05 21:15:16 +02:00
fred 56f0ac5e43 TESSERACT 2021-09-05 21:06:39 +02:00
fred afec3684f8 correction 2021-09-04 23:31:39 +02:00
fred d46c623569 x_ssh-$zuid.sh 2021-09-04 23:30:09 +02:00
fred a07c63eafa ~/.zen/ipfs/.$IPFSNODEID/x_ssh-$zuid.sh asking for $PORT 2021-09-04 23:29:32 +02:00
fred b575ff7518 DEBUG 2021-09-04 23:09:29 +02:00
fred d4dadbbf10 Activate SWARM refresh every 20 mn 2021-09-04 22:36:48 +02:00
fred 6946a324bf WILL BE USING ipfs config Peering.Peers 2021-09-04 22:25:29 +02:00
fred 11c594285b STOP DEAD SWARM CONTROL 2021-09-04 22:24:59 +02:00
fred 1ebb9f17ee ## THIS PORT FORWARDING HUB COULD BE MADE MORE CONTROLABLE USING FRIENDSHIP LEVEL & IPFS BALISES 2021-09-04 20:37:26 +02:00
fred feaad9ba8f A_Station_ON doit être dans /tmp pour être effacé au démarrage!! Bad idea to change 2021-09-04 16:25:46 +02:00
fred 36e577dcc7 remove empty directory from ~/.zen/ipfs_swarm/.$ipfsnodeid/ FRIEND 2021-09-04 16:11:49 +02:00
fred e4a8ac945e lighter quicker DEFCON 5 mode 2021-09-04 16:01:37 +02:00
fred c00aaf3e7c echo missing 2021-09-04 14:46:36 +02:00
fred 56d9355e53 NOT FRIEND ## TODO : remove "ipfs pin" in "~/.zen/PIN/" 2021-09-04 14:46:10 +02:00
fred 83fbfeda10 ########## PIN MAKES YOU FASTRXBIAN DISTRIBUTOR 2021-09-04 14:45:42 +02:00
fred e78fa03480 MyCODE = $MyCODE CODE is published as everyday task 2021-09-04 02:17:41 +02:00
fred dbec0e3c15 // HOWTO PASS FILTER Query parameter to bash exec ? 2021-09-04 01:43:25 +02:00
fred 8d097d7a0c NO COMPATIBLE STATION 2021-09-04 00:39:33 +02:00
fred 6ac67826ab stars 2021-09-04 00:33:23 +02:00
fred 491ba1c0b3 mediaid could have _ 2021-09-04 00:11:51 +02:00
fred 91bc17d3cb indicate Source ipfsnodeid 2021-09-04 00:04:27 +02:00
fred 4f5d80cf2d CONTINUE 2021-09-04 00:01:03 +02:00
fred 46d1989cd5 log removal 2021-09-03 23:59:33 +02:00
fred 4775e2afb2 remove empty directories from swarm 2021-09-03 23:55:26 +02:00
fred dd33937301 PIN memorize ipfsfilelink instead of ipfsid 2021-09-03 23:55:08 +02:00
fred e913299a15 $zuid FRIENDS 2021-09-03 20:38:29 +02:00
fred fb5e341092 Show when FRIENDS WIKI page is updated TITLE = $zuid $updated FRIENDS (${IPFSNODEID}) 2021-09-03 20:31:57 +02:00
fred 1d505b8d8b transition to ipfs backend 2021-09-03 17:59:15 +02:00
fred 2aff2ff612 <title>WIKI des Amis de $zuid = ${IPFSNODEID}</title> 2021-09-03 17:58:48 +02:00
fred 9be700d3b0 new cron timing 2021-09-02 22:49:43 +02:00
fred 77b477ec6b cleaning old files and dir from ipfs_swarm 2021-09-02 22:42:57 +02:00
fred d926f2818a add URL support 2021-09-02 22:42:34 +02:00
fred 001a3b90f5 tube.copylaradio.com and gchange link 2021-09-02 15:00:55 +02:00
fred 01968baab4 reset ~/.zen/A_peering_peers.txt 2021-09-02 14:45:49 +02:00
fred 4f9dadbc77 better 2021-09-02 14:37:02 +02:00
fred e036175b32 fixing 2021-09-02 14:36:35 +02:00
fred c3a0dafb10 Copy Video is coming from "Open With" 2021-09-02 14:20:25 +02:00
fred baf5498d21 Now script can be run with "Open With" navigator plugin to copy while surfing 2021-09-02 02:09:46 +02:00
fred 60572c7f02 space cleaning 2021-09-02 01:41:21 +02:00
fred db88990004 LowWater & HighWater = 0 now, will use "Peers.Peering" 2021-09-02 01:40:04 +02:00
fred 47f127f6cc reading from IPNS capsules = lower gchange usage 2021-09-02 01:21:54 +02:00
20 changed files with 963 additions and 410 deletions

View File

@ -23,9 +23,9 @@ err() {
# CHECK if daemon is already running
if [[ $(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) ]]; then
echo "ipfs daemon already running...! Must STOP ipfs AND remove ~/.ipfs to install again !!"
ipfs id && echo "ipfs swarm peers: " && ipfs swarm peers
echo "ipfs bootstrap list: " && ipfs bootstrap list
echo "ipfs daemon already running...! Must STOP ipfs AND remove ~/.ipfs to install again !!"
echo "Please RUN : sudo service ipfs stop"
exit 1
fi
@ -120,8 +120,8 @@ ipfs config Datastore.StorageMax $diskSize
## Activate Rapid "ipfs p2p"
ipfs config --json Experimental.Libp2pStreamMounting true
ipfs config --json Experimental.P2pHttpProxy true
ipfs config --json Swarm.ConnMgr.LowWater 60
ipfs config --json Swarm.ConnMgr.HighWater 180
ipfs config --json Swarm.ConnMgr.LowWater 0
ipfs config --json Swarm.ConnMgr.HighWater 0
######### CLEAN DEFAULT BOOTSTRAP TO STAY INVISIBLE ###########
ipfs bootstrap rm --all
###########################################

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)**
astrXbian est une première façon de programmer Astroport en le connectant avec KODI.
Utilisé de cette façon, il constitue un **Vidéo Club "pair à pair" entre amis**
Utilisé de cette façon, il constitue un **Vidéo Club "pair à pair" entre amis**
Il permet de mettre en partage vos copies privées dans votre essaim au travers du média-center KODI.
Vos relations Gchange s'appliquent comme relations (A-B(-C)) (ami (d'amis)) de votre essaim IPFS et de toutes données à échanger selon le nombre d'étoiles envoyées.
@ -92,7 +92,7 @@ Il contrôle son réseau IPFS en fonction des "étoiles" transmisent par Gchange
ASTROPORT, automate cellulaire sécurisé, prend en compte vos relations pour ouvrir des canaux de partage selon 5 niveaux de confiance.
Ces "stargate" permettent de créer des espaces numériques public ou privés tout en contrôlant l'étendue du partage.
---
---
## INSTALLATION (Debian/Ubuntu/Mint ou Xbian)
@ -130,7 +130,7 @@ Cela tombe bien, parce que tout utilisateur averti de son ordinateur se doit de
Il s'agit des logiciels ipfs et de diverses couches cryptographiques compatible avec toute application du système hote pour en partager les données avec les amis de son essaim
cette distribution permet de facilement relier nos ordinateurs en cloud sans datacenter.
**Ouvrez un terminal puis copiez/collez cette ligne de commande**:
**Ouvrez un terminal puis copiez/collez cette ligne de commande**:
```bash <(wget -qO- https://git.p2p.legal/axiom-team/astrXbian/raw/branch/master/install.sh)```
@ -169,7 +169,7 @@ Ensemble transformons le monde numérique pour qu'il devienne LIBRE P2P et LEGAL
## Installation Image pour Rpi4
Nous avons préparé une image système pré-installée
Nous avons préparé une image système pré-installée
[TELECHARGER IMAGE POUR RPI](https://qo-op.com/astrXbian_2021_03_10.img)
- Copier l'image sur une carte micro-SD. Utiliser un RaspberryPi4 (2 ou 4Go) est recommandé!
@ -181,14 +181,14 @@ NB: Les films placés dans ~/astroport/film/$TMDBID/ sont automatiquement transf
-- Automate Astroport/KODI en demonstration pour Xbian.org --
## PRINCIPE DE FONCTIONNEMENT
## PRINCIPE DE FONCTIONNEMENT ([index des PAD astroport](https://pad.p2p.legal/s/astroport-index))
> Astroport/KODI vous permet de partager les vidéos que vous aimez avec les gens que vous aimez.
Le répertoire ~/astroport sert de sas de transfert de vos fichiers dans IPFS.
Le répertoire ~/astroport sert de sas de transfert de vos fichiers dans IPFS.
Votre essaim de pairs connectés se dessine selon les "étoiles" échangées sur https://gchange.fr
Chaque noeud astXbian possède une identité (paire de clef ed25519) qui correspond à son identité sur https://gchange.fr et un portefeuille sur https://cesium.app
Chaque noeud astXbian possède une identité (paire de clef ed25519) qui correspond à son identité sur https://gchange.fr et un portefeuille sur https://cesium.app
Lorsqu'une identité "like/étoile" un autre compte sur Gchange, elle lui expédie le message "ipfstryme" ```~/.zen/ipfs/.${IPFSNODEID}/tryme.addr``` qui contient les adresses IP/IPFS connues (amis d'ami).
@ -220,7 +220,7 @@ L'essaim se restructure toutes les minutes (code: ```cron_MINUTE.sh```) et activ
Chaque station fabrique 5 clefs qui sont envoyées à tous ses amis en fonction des étoiles attribuées.
Ces "stargate" partagés sur le même espace IPNS sont signés par chaque participant qui le modifie construisant une blockchain (sauvegarde).
En cas de conflit (quand le swarm est trop grand ou désynchronisé), une procédure envoi des messages aux 2 signatures et invite à résoudre de façon manuelle le problème.
En cas de conflit (quand le swarm est trop grand ou désynchronisé), une procédure envoi des messages aux 2 signatures et invite à résoudre de façon manuelle le problème.
# Magic commands
@ -250,7 +250,7 @@ ipfs ls /ipns/k51qzi5uqu5dk1nt1pfbtgfis4bep8pcip78w30xykhgba7y7wk0xyu8nwci5m
MYCODE=$(cat ~/.zen/ipfs_swarm/.$IPFSNODEID/.mycode);
for CODE in $(ls ~/.zen/ipfs_swarm/.12D*/.mycode);
do
echo
echo
ipfsnodeid=$(echo $CODE | cut -d '.' -f 3 | cut -d '/' -f 1 );
code=$(cat $CODE);
IPNSCODE=$(ipfs cat /ipns/$ipfsnodeid/.$ipfsnodeid/.mycode)
@ -272,7 +272,7 @@ for ipfsnodeid in $(ipfs swarm peers | grep -o '[^/]*$'); do ipfs cat /ipns/$ipf
# ANNEXES
## PRESENTATIONS VIDEO
### [Fred présente Astroport à la Ressourcerie](https://tube.p2p.legal/videos/watch/7ff4a8c9-7fb7-44ef-a1ee-bdf8ecc74cfe)
### [Première visite de Astroport/KODI](https://tube.p2p.legal/videos/watch/d74631e9-b1bd-43f4-9db7-5effca1ef46a)
@ -329,7 +329,7 @@ https://forum.monnaie-libre.fr/t/offres-emplois/16903?u=qoop
- 1 DU par compte ouvert sur https://oasis.astroport.com
- 2 DU par article autour du DIY Raspberry Pi sur https://copylaradio.com (+ 1 DU pour l'ouverture du compte)
A la clef un concours des meilleurs articles par activation de la Zen Economie sur Astroport.
A la clef un concours des meilleurs articles par activation de la Zen Economie sur Astroport.
Pour rejoindre l'Astrocrew installez AstrXbian TestNET en cour s de développement et devenez programmateur de cette automate cellulaire (BASH + multilanguage).
Le nouveau JEu du LOVE peut commencer.

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 xdpyinfo) == "" ]] && echo "ERREUR! Installez x11-utils" && echo "sudo apt install x11-utils" && exit 1
URL="$1"
[ $URL ] && echo "URL: $URL" && REVSOURCE="$(echo "$URL" | awk -F/ '{print $3}' | rev)_"\
&& IMPORT=$(zenity --entry --width 640 --title="$URL => Astroport" --text="Choisissez comment copier cette source" --entry-text="Video" MP3 Web) \
&& [[ $IMPORT == "Video" ]] && IMPORT="Youtube" \
&& CHOICE="$IMPORT"
[[ $CHOICE == "Web" ]] && CHOICE=$(zenity --entry --width 640 --title="$URL => Astroport" --text="Cette source WEB est à encrigistrer comme " --entry-text="Page" WebSite)
# REMOVE GtkDialog errors for zenity
shopt -s expand_aliases
alias zenity='zenity 2> >(grep -v GtkDialog >&2)'
@ -43,7 +53,7 @@ IPFSNODEID=$(ipfs id -f='<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/_xbian.zuid ]] && AXID=$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)
zenity --warning --width 300 --text "Ajoutez un MEDIA dans ASTROPORT"
# zenity --warning --width 300 --text "Ajoutez un MEDIA dans ASTROPORT"
########################################################################
@ -76,7 +86,7 @@ fi
########################################################################
# CHOOSE CATEGORY (remove anime, not working!)
CHOICE=$(zenity --entry --width 300 --title="Catégorie" --text="Choisissez la catégorie de votre vidéo" --entry-text="Film" Serie Video KODI Youtube MP3)
[[ $CHOICE == "" ]] && CHOICE=$(zenity --entry --width 300 --title="Catégorie" --text="Choisissez la catégorie de votre media" --entry-text="Film" Serie Youtube Video)
[[ $CHOICE == "" ]] && exit 1
# LOWER CARACTERS
@ -84,7 +94,7 @@ CAT=$(echo "${CHOICE}" | awk '{print tolower($0)}')
# UPPER CARACTERS
CHOICE=$(echo "${CAT}" | awk '{print toupper($0)}')
PREFIX=$(echo "${CAT}" | head -c 1 | awk '{ print toupper($0) }' ) # ex: F, S, A, Y, M ...
PREFIX=$(echo "${CAT}" | head -c 1 | awk '{ print toupper($0) }' ) # ex: F, S, A, Y, M ... P W
[[ $PREFIX == "" ]] && exit 1
########################################################################
@ -101,9 +111,8 @@ case ${CAT} in
########################################################################
youtube)
zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Envoyez le LOG : https://git.p2p.legal .DEVELOPPEMENT'
YTURL=$(zenity --entry --width 300 --title "Lien ou identifiant à copier" --text "Indiquez le lien (URL) ou l'ID de la vidéo" --entry-text="")
YTURL="$URL"
[[ $YTURL == "" ]] && YTURL=$(zenity --entry --width 300 --title "Lien ou identifiant à copier" --text "Indiquez le lien (URL) ou l'ID de la vidéo" --entry-text="")
[[ $YTURL == "" ]] && exit 1
# Create TEMP directory to copy $YID_$TITLE.$FILE_EXT
@ -113,7 +122,7 @@ mkdir -p ${YTEMP}
# youtube-dl $YTURL
echo "VIDEO $YTURL"
/usr/local/bin/youtube-dl -f '[height=720]/best' \
--write-info-json --write-annotations \
--no-playlist --write-info-json --write-annotations \
--no-mtime -o "${YTEMP}/%(id)s&%(title)s.%(ext)s" $YTURL
# Get filename, extract ID, make destination dir and move copy.
@ -126,7 +135,7 @@ JSON_FILE=$(echo ${FILE_NAME} | sed "s/${FILE_EXT}/json/g")
YID=$(echo "${FILE_NAME}" | cut -d "&" -f 1)
YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | sed "s/[(][^)]*[)]//g" | sed -e 's/[^A-Za-z0-9._-]/_/g' | sed -e 's/__/_/g' ) # Remove YoutubeID_ and (what is in perentheses)
[[ $(which detox) ]] && YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | detox --inline)
MEDIAID="${YID}"
MEDIAID="$REVSOURCE${YID}"
TITLE="${YNAME%.*}"
MEDIAKEY="YOUTUBE_${MEDIAID}"
## CORRECT PARAMETERS to Make Kodi compatible YASTRXBIAN FILE
@ -152,7 +161,7 @@ GENRES=$(zenity --list --checklist --title="GENRE" --height=${haut} \
# FORMAT GENRES genre1|genre2|genre3
FILE_PATH="$HOME/astroport/youtube/$YID"
FILE_PATH="$HOME/astroport/youtube/$MEDIAID"
mkdir -p ${FILE_PATH} && mv -f ${YTEMP}/* ${FILE_PATH}/
# rename FILE_NAME to YNAME (URL clean)
mv "${FILE_PATH}/${FILE_NAME}" "${FILE_PATH}/${YNAME}" && FILE_NAME="${YNAME}"
@ -175,6 +184,43 @@ rm -Rf ${YTEMP}
;;
########################################################################
# CASE ## WEB
web)
zenity --warning --width 600 --text 'DEVELOPPEMENT . ZONE . Please Participate https://git.p2p.legal'
## httrack all web site
[[ ! $(which httrack) ]] && zenity --warning --width ${large} --text "Utilitaire de copie de site web absent.. Lancez la commande 'sudo apt install httrack'" && exit 1
echo "httrack --mirror $URL"
;;
########################################################################
# CASE ## PAGE
page)
zenity --warning --width 600 --text 'DEVELOPPEMENT . ZONE . Please Participate https://git.p2p.legal'
## record one page only
[[ ! $(which chromium) ]] && zenity --warning --width ${large} --text "Utilitaire de copie de page web absent.. Lancez la commande 'sudo apt install chromium'" && exit 1
cd /tmp/ && rm output.pdf && chromium --headless --no-sandbox --print-to-pdf $URL
TITLE=$(zenity --entry --width 480 --title "Titre" --text "Indiquez le titre de la vidéo" --entry-text="${URL}")
[[ $TITLE == "" ]] && exit 1
FILE_NAME="$(echo "${TITLE}" | detox --inline).pdf" ## TODO make it better
MEDIAID="$REVSOURCE$(echo "${TITLE}" | detox --inline)"
MEDIAKEY="PAGE_${MEDIAID}"
FILE_PATH="$HOME/astroport/youtube/$MEDIAID"
mkdir -p ${FILE_PATH} && mv -f output.pdf ${FILE_PATH}/${FILE_NAME}
echo "page;${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};_IPNSKEY_;${RES};/ipfs/_IPFSREPFILEID_/$FILE_NAME" > ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt
;;
########################################################################
# CASE ## MP3
# _____
@ -186,7 +232,7 @@ rm -Rf ${YTEMP}
########################################################################
mp3)
zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Envoyez le LOG : https://git.p2p.legal .DEVELOPPEMENT'
zenity --warning --width 600 --text 'DEVELOPPEMENT . ZONE . Please Participate https://git.p2p.legal'
# Create TEMP directory
YTEMP="/tmp/$(date -u +%s%N | cut -b1-13)"
@ -222,7 +268,7 @@ FILE_EXT="${FILE_NAME##*.}"
YID=$(echo "${FILE_NAME}" | cut -d "&" -f 1)
YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | sed "s/[(][^)]*[)]//g" | sed -e 's/[^A-Za-z0-9._-]/_/g' | sed -e 's/__/_/g') # Remove YoutubeID_ and (what is in perentheses)
[[ $(which detox) ]] && YNAME=$(echo "${FILE_NAME}" | cut -d "&" -f 2- | detox --inline)
[[ $(which detox) ]] && YNAME="$(echo "${FILE_NAME}" | cut -d "&" -f 2- | detox --inline)"
[[ ! $islink && "$song" != "" ]] && FILE_PATH="$HOME/astroport/$CAT/$artist/_o-o_" \
|| FILE_PATH="$HOME/astroport/$CAT/${YID}"
@ -384,7 +430,7 @@ echo "${CAT};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/
video)
zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Envoyez le LOG : https://git.p2p.legal .DEVELOPPEMENT'
zenity --warning --width 600 --text 'DEVELOPPEMENT. SVP. Inscrivez-vous sur https://git.p2p.legal'
## GENERAL MEDIAKEY for uploaded video. Title + Decription + hashtag + hashipfs
# SELECT FILE TO ADD TO ASTROPORT/KODI
@ -427,9 +473,11 @@ echo "${CAT};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/
#| < (_) | (_| | |
#|_|\_\___/ \__,_|_|
# COPY UQLOAD LINKS DETECTED IN KODI LOG
##############################################
### TODO INSTALL FROM START and AUTO SCRAPE KODI LOG
##############################################
kodi)
# OPTION REMOVED
if [[ ! -f $HOME/.local/bin/uqload_downloader ]]; then
cd /tmp
git clone https://github.com/papiche/uqload_downloader.git
@ -442,8 +490,6 @@ echo "${CAT};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/
zenity --warning --width ${large} --text "UTILISEZ download_from_kodi_log.sh en ligne de commande..."
exit 0
fi
;;
########################################################################
@ -462,12 +508,13 @@ esac
# ADD $FILE to IPFS / ASTROPORT / KODI
echo "new_file_in_astroport.sh \"$HOME/astroport/${CAT}/${MEDIAID}/\" \"${FILE_NAME}\""
[[ -f ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt ]] && cat ~/astroport/${CAT}/${MEDIAID}/ajouter_video.txt
[[ -f ~/astroport/${CAT}/${MEDIAID}/video.json ]] && cat ~/astroport/${CAT}/${MEDIAID}/video.json
########################################################################
# LOG NOISE # [[ -f ~/astroport/${CAT}/${MEDIAID}/video.json ]] && cat ~/astroport/${CAT}/${MEDIAID}/video.json
########################################################################
## CREATION DU FICHIER ajouter_video.txt OK
########################################################################
### AJOUT DANS IPFS #######################################################
########################################################################
####################################new_file_in_astroport.sh##################
########################################################################
[[ "$CAT" == "film" || "$CAT" == "serie" ]] && CHOICE="TMDB"

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)
if [[ ! ${YOU} ]]; then
# reduice water levels for swarm
ipfs config --json Swarm.ConnMgr.LowWater 200
ipfs config --json Swarm.ConnMgr.HighWater 400
ipfs config --json Swarm.ConnMgr.LowWater 50
ipfs config --json Swarm.ConnMgr.HighWater 100
[[ "${USER}" == "xbian" ]] && sudo service ipfs restart || sudo systemctl restart ipfs
echo "ERROR! ipfs daemon was not running. RELAUNCHING."
exit 1
@ -36,7 +36,7 @@ fi
########################################################################
# CORRECT VSTREAM ASTROPORT SITE/ART REMOVED AFTER PLUGIN UPDATE
[[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py ]] && [[ -f ~/.zen/astroport.py ]] && cp -f ~/.zen/astroport.py ~/.kodi/addons/plugin.video.vstream/resources/sites/
[[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ]] && cp ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ~/.kodi/addons/plugin.video.vstream/resources/art/
[[ ! -f ~/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ]] && cp ~/.zen/astrXbian/.install/.kodi/addons/plugin.video.vstream/resources/art/astroport.png ~/.kodi/addons/plugin.video.vstream/resources/art/ 2>/dev/null
########################################################################
### NO IP GATEWAY : EXIT
@ -77,11 +77,11 @@ dayofthemonth=$(date +%d)
weeknumber=$(date +%V)
# WAKEUP TIME
if [[ ! -f /home/$YOU/.zen/A_Station_ON ]]; then
echo "onheure=$heure; onminute=$minute; ontimebar=$timebar" > /home/$YOU/.zen/A_Station_ON
[[ -f /tmp/A_Station_ON ]] && cp /tmp/A_Station_ON /home/$YOU/.zen/A_Station_ON
if [[ ! -f /tmp/A_Station_ON ]]; then
echo "onheure=$heure; onminute=$minute; ontimebar=$timebar" > /tmp/A_Station_ON
[[ -f /home/$YOU/.zen/A_Station_ON ]] && cp /home/$YOU/.zen/A_Station_ON /tmp/A_Station_ON && rm /home/$YOU/.zen/A_Station_ON
else
source /home/$YOU/.zen/A_Station_ON
source /tmp/A_Station_ON
old=$ontimebar
new=$timebar
# feeding variables by using read and splitting with IFS
@ -103,7 +103,10 @@ echo "RUNTIME $runtime mn ($timebar)"
if [[ $(($runtime % 4)) == 0 ]]; then
## PING ALL MY FRIENDS TO ENHANCE SWARM CONNECTIVITY
echo "## FRIENDS IPFS PINGing"
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do [[ $g1pub ]] && ipfs ping --timeout=5s -n 3 /ipfs/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
for g1pub in $(ls -t ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/); do
[[ $g1pub ]] && latency=$(ipfs ping --timeout=2s -n 3 /p2p/$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null | grep "Average" | cut -d ':' -f 2);
[[ $latency ]] && echo $latency > ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1pub/ping.average.txt
done
fi
########################################################################
## CHECK & (RE)ACTIVATE ipfs p2p tunnels
@ -187,12 +190,17 @@ fi
#
##################################################################
# TODO: IDEA make gchange/ipfs/ipns refresh speed depending on ipfs swarm size and DEFCON level !
## SYNC GCHANGE EVERY 2 hours runtime
[[ $(($runtime % 97)) == 0 ]] && $MY_PATH/zen/gchange_INIT.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_INIT.txt
## SYNC SWARM EVERY 20 mn runtime
[[ $(($runtime % 17)) == 0 ]] && $MY_PATH/zen/gchange_IPFS_swarm.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_IPFS_swarm.txt
# QUICK SYNC SWARM EVERY 12 minutes
[[ $(($runtime % 11)) == 0 ]] && $MY_PATH/zen/ipfs_FRIENDS_refresh.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.ipfs_FRIENDS_refresh.txt
## SYNC GCHANGE EVERY 12 hours runtime
[[ $(($runtime % 725)) == 0 || "$runtime" == "5" ]] && $MY_PATH/zen/gchange_INIT.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_INIT.txt
## SYNC SWARM EVERY 6h runtime
[[ $(($runtime % 370)) == 0 || "$runtime" == "10" ]] && $MY_PATH/zen/gchange_IPFS_swarm.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.gchange_IPFS_swarm.txt
# QUICK SYNC SWARM EVERY 30 minutes
## CLEAN OLD SESSION
if [[ $(($runtime % 30)) == 0 ]]; then
kill -9 $(ps auxf --sort=+utime | grep -w p4n.swarmscraper.sh | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
killall chromium
$MY_PATH/zen/ipfs_SWARM_refresh.sh 2>&1 > /home/${YOU}/.zen/ipfs/.${IPFSNODEID}/.log.ipfs_SWARM_refresh.txt
fi
## TODO ACTIVATE/DESACTIVATE LOG
########################################################################
# ACTIVATE ~/astroport directory monitoring (xbian only)
@ -228,9 +236,6 @@ fi
#
# REFRESHing MEDIAKEY / ZenTAG nano DHTs => Zen File ECONOMY wallet cycle
if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || "$timebar" == "03:03" || $(($runtime % 720)) == 0 || $runtime == 12 ]]; then
# Every 12h runtime restarting IPFS daemon
[[ "$timebar" == "03:03" ]] && [[ -f /etc/sudoers.d/systemctl ]] && sudo systemctl restart ipfs && exit 0
[[ "$timebar" == "03:03" ]] && [[ ${YOU} == "xbian" ]] && sudo service ipfs restart && exit 0
#### Refresh & publish MEDIAKEYs
$MY_PATH/zen/ipns_TAG_refresh.sh
@ -239,12 +244,17 @@ if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || "$timebar" == "03:03" ||
rm -f ~/.zen/A_dead_swarm.txt
fi
# At 03:03 and every 6h runtime restarting IPFS daemon
[[ "$timebar" == "03:03" || $(($runtime % 363)) == 0 ]] && [[ -f ~/.ipfs/config.new ]] && cp ~/.ipfs/config.new ~/.ipfs/config
[[ "$timebar" == "03:03" || $(($runtime % 363)) == 0 ]] && [[ -f /etc/sudoers.d/systemctl ]] && sudo systemctl restart ipfs && exit 0
[[ "$timebar" == "03:03" || $(($runtime % 363)) == 0 ]] && [[ ${YOU} == "xbian" ]] && sudo service ipfs restart && exit 0
##################################################################
##################################################################
# 5 mn / 24h REBOOT & MIDNIGHT:01 : CLEANING & UPDATE
##################################################################
##################################################################
if [[ "$timebar" == "00:01" || "$runtime" == "5" || $(($runtime % 1380)) == 0 ]]; then
if [[ "$timebar" == "00:01" || "$runtime" == "30" || $(($runtime % 1380)) == 0 ]]; then
echo '
# ____ ____ ____ ___
# / __ \/ __ \ _ / __ < /
@ -305,6 +315,20 @@ echo '
# RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh
$MY_PATH/zen/manage_stargates.sh
########################################################################
# ACTIVATE TO CONTROL SWARM STATION SAME CODE VERSION
########################################################################
## myCODE is a SECURITY about code SIMILARITY
## EACH NODE CAN CHECK IF ANOTHER HAS SAME IPFS CODE HASH
MyCODE=$(ipfs add -rq --ignore="__pycache__" ~/.zen/astrXbian/ | tail -n 1)
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/.mycode ]] && echo $MyCODE > ~/.zen/ipfs/.${IPFSNODEID}/.mycode
[[ "$(cat ~/.zen/ipfs/.${IPFSNODEID}/.mycode)" != "$MyCODE" ]] && echo $MyCODE > ~/.zen/ipfs/.${IPFSNODEID}/.mycode
echo "MyCODE = $MyCODE CODE is ready to be published"
########################################################################
# MEAN CONTROL SWARM STATION HAVE SAME CODE VERSION
########################################################################
fi
### DISAPEAR ONE HOUR FROM IPFS SWARM ZOMBIES > 300 peers in swarm

View File

@ -2,7 +2,7 @@
* https://git.p2p.legal/axiom-team/astrXbian
* https://oasis.astroport.com
* https://colibris-wiki.org/astroport
* https://colibris-wiki.org/astroport
# Liens annexes
@ -23,7 +23,7 @@
# jaklis : commandes de messaging / like
```
## GET ALERT MESSAGES
## GET ALERT MESSAGES
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$G1PUB" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ALERT")' | jq -r '.id'
## SEND MONITORING MESSAGE TO onelove
@ -32,3 +32,15 @@
## LINKING ME PEOPLE
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer'
```
# EXEMPLES DE COMMANDES BALISES
```
## CHECK SWARM STATIONS TIMESTAMPS
for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS); do echo $g1id; [[ "$g1id" == "index.html" ]] && continue; ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id); ts=$(ipfs --timeout=10s cat /ipns/$ipfsnodeid/.$ipfsnodeid/.timestamp); echo $(date -ud @$ts); done
for ts in $(cat ~/.zen/ipfs_swarm/.*/.timestamp); do echo $(date -ud @$ts); done
```

View File

@ -21,7 +21,7 @@ for i in git fail2ban inotify-tools curl net-tools libsodium* python3-dev python
done
#sudo apt-get install build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox httrack html2text ssmtp sudo -y
for i in build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox httrack html2text ssmtp sudo; do
for i in build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox nmap httrack html2text ssmtp imagemagick ttf-mscorefonts-installer; do
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
sudo apt install -y $i
fi
@ -47,7 +47,7 @@ python3 -m pip install -U pip
python3 -m pip install -U setuptools wheel
python3 -m pip install -U cryptography Ed25519 base58 google protobuf duniterpy
if [[ "$USER" == "pi" ]]; then ## PROPOSE QR_CODE PRINTER
echo "INSTALLER ACCES SMS ET IMPRIMANTE A QR CODE? saisissez OUI, sinon tapez sur ENTREE"
echo "SOUHAITEZ VOUS AJOUTER UNE IMPRIMANTE A QR CODE? saisissez OUI, sinon tapez sur ENTREE"
read saisie
if [[ $saisie != "" ]]; then
sudo apt install printer-driver-all cups -y
@ -78,7 +78,7 @@ echo "Installation de IPFS https://ipfs.io"
~/.zen/astrXbian/.install/ipfs_alone.sh
########################################################################
echo "Configuration jaklis: Centre de communication GCHANGE+"
echo "Configuration jaklis: Centre de communication CESIUM+ GCHANGE+ & MONNAIE LIBRE (gva protocole)"
cd ~/.zen/astrXbian/zen/jaklis
./setup.sh
@ -117,19 +117,16 @@ fi
mkdir -p ~/astroport/film
mkdir -p ~/astroport/serie
mkdir -p ~/astroport/anime
echo '${TYPE};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/ipfs/_IPFSREPFILEID_/$URLENCODE_FILE_NAME' > ~/astroport/ajouter_video.modele.txt
## PREPARE www EXCHANGE ZONE ~/astroport/www
wwwuser=$(ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1) || wwuser="www-data"
mkdir -p ~/astroport/www
mkdir -p ~/astroport/www/audio
mkdir -p ~/astroport/www/video
mkdir -p ~/astroport/www/site
sudo chown -R $USER:$wwwuser ~/astroport/www
sudo chmod -R g+rw ~/astroport/www
#######################################################################
## CREATE symlinks for ~/.zen/www/swarm & me
sudo chown -R $USER:www-data /.zen/astrXbian/www/boris
sudo chmod -R g+rw /.zen/astrXbian/www/boris
sudo chown -R $USER:www-data ~/.zen/astrXbian/www/boris
sudo chmod -R g+rw ~/.zen/astrXbian/www/boris
ln -s /home/$USER/.zen/ipfs_swarm ~/.zen/astrXbian/www/boris/swarm
ln -s /home/$USER/.zen/ipfs ~/.zen/astrXbian/www/boris/me

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();
// HOWTO PASS Query parameters to exec ?
exec("/bin/bash -c './get_astrxbian_index.sh F'", $videos);
exec("/bin/bash -c './check_my_wallet.sh'", $gg1);

View File

@ -5,8 +5,10 @@
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
PREFIX="$1"
[[ $PREFIX == "" ]] && PREFIX="Y"
FILTER="$2"
[[ $PREFIX == "" ]] && PREFIX="*"
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1
# Filter no ipns link
cat ./{me,swarm}/.*/astroport/kodi/vstream/*ASTRXBIAN | grep -Ev "];;" | sort | uniq | tail -n +2
[[ ! $FILTER ]] && cat /home/$YOU/.zen/{ipfs,ipfs_swarm}/.*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | grep -Ev "];;" | sort | uniq | tail -n +2 && exit 0
cat /home/$YOU/.zen/{ipfs,ipfs_swarm}/.*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | grep -Ev "];;" | grep "$FILTER" | sort | uniq | tail -n +2

View File

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

View File

@ -41,20 +41,20 @@ cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
########################################################################
GCHANGE="https://data.gchange.fr"
## GET LATEST GCHANGE PROFILE
curl -s ${GCHANGE}/user/profile/${G1PUB} > /tmp/A_${G1PUB}.cache
curl -s ${GCHANGE}/user/profile/${G1PUB} > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange.json
# UPDATE _g1.gchange_title
title=$(cat /tmp/A_${G1PUB}.cache | jq -r '._source.title')
title=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange.json | jq -r '._source.title')
[[ $title ]] && echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title
# UPDATE _g1.astroport_title with city
title="Station $YOU@$XZUID"
city=$(cat /tmp/A_${G1PUB}.cache | jq -r '._source.city')
city=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange.json | jq -r '._source.city')
[[ "$city" != "null" ]] && title="$title in $city"
echo "$title" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.astroport_title
# UPDATE _g1.gchange_avatar.png
cat /tmp/A_${G1PUB}.cache | jq -r '._source.avatar._content' | base64 -d > "/home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_avatar.png"
cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange.json | jq -r '._source.avatar._content' | base64 -d > "/home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_avatar.png"
# CREATE _nodename
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename ]] && nodename=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename)
@ -78,7 +78,7 @@ export LANG=C.UTF-8 #attipix
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/.ipfsnodeid ]] && echo ${IPFSNODEID} > ~/.zen/ipfs/.${IPFSNODEID}/.ipfsnodeid
########################################################################
# NODE DISK PERFORMANCE, manual remove ~/.ipfs/test.disk to run again
# NODE DISK PERFORMANCE, manual remove ~/.ipfs/test.disk (every week in cron_MINUTE) then run again
if [[ ! -f ~/.ipfs/test.disk ]]; then
diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4)
echo "DISK PERFORMANCE TESTING : $diskperf"
@ -103,8 +103,8 @@ fi
########################################################################
echo "####################################################
Customisation TiddlyWiki"
# [[ ! -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID} && cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
[[ ! $(cat ~/.zen/ipfs/.${IPFSNODEID}/index.html | grep ${IPFSNODEID}) ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID} && cp ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
# cp -f ~/.zen/astrXbian/.install/templates/tiddlyone/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)"
wiki="/home/$YOU/.zen/ipfs/.$IPFSNODEID/index.html"
@ -154,11 +154,11 @@ ipfsnodeid=${IamINBOOTSTRAP##*/}
################## SEND ipfstryme MESSAGES to FRIENDS
rm -f /tmp/friend_of_mine
## Getting Gchange liking_me list
~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me
~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/liking_me
## Adding random bootstrap to liking_me list
~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#" | rev | cut -d '/' -f 1 | rev | shuf | head -n 1) >> /tmp/liking_me
~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#" | rev | cut -d '/' -f 1 | rev | shuf | head -n 1) >> ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/liking_me
for liking_me in $(cat /tmp/liking_me | sort | uniq);
for liking_me in $(cat ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/liking_me | sort | uniq);
do
[[ "$liking_me" == "" ]] && continue ## Protect from empty line !!
##### BOOTSTRAP AUTO LIKE BACK (NOT liking Myself)
@ -174,6 +174,12 @@ do
fi
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $liking_me)
echo "Reading stars.level from Stations IPNS Capsules."
starsin=$(ipfs --timeout=10s cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/stars.level)
starsout=$(ipfs --timeout=10s cat /ipns/$IPFSNODEID/.$IPFSNODEID/FRIENDS/$liking_me/stars.level)
echo "I received $starsin stars while I sent $starsout stars."
##### CHECKING IF WE LIKE EACH OTHER (AVOID LIKING MYSELF)
~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me > /tmp/Gstars.json
@ -189,7 +195,12 @@ do
# REFRESH & PUBLISH stars friends map
stars="$(cat /tmp/Gstars.json | jq -r '.yours.level')"
[[ "$stars" == "null" || "$stars" == "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me && echo "$friend_of_mine NO STAR !! Removing $liking_me" && continue ## REMOVE NO GOOD FRIENDS (no star)
if [[ "$stars" == "null" || "$stars" == "" ]]; then
rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me
echo "$friend_of_mine NO STAR !! Removing $liking_me"
## TODO : remove "ipfs pin" in "~/.zen/PIN/"
continue ## REMOVE NO GOOD FRIENDS (no star)
fi
cp /tmp/Gstars.json ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ && rm -f /tmp/Gstars.json
echo "$stars" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/stars.level && echo "***** $stars STARS *****"
@ -200,22 +211,26 @@ do
# zuid=$(ipfs --timeout=10s cat /ipns/${ipfsnodeid}/.${ipfsnodeid}/_xbian.zuid)
# [[ ${zuid} ]] && touch ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/${zuid}
## NOT USEFULL TRYING
# SEND jaklis message if tryme.addr is different from last one
if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]]
then
echo "I AM $G1PUB"
echo "Sending IPFSTRYME message to $liking_me"
if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then
~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
else
echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr'
fi
echo "$friend_of_mine" >> /tmp/friend_of_mine
else
echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me"
fi
# MEMORIZE actual tryme.addr
# if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]]
# then
# echo "I AM $G1PUB"
# echo "Sending IPFSTRYME message to $liking_me"
#
# if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then
# ~/.zen/astrXbian/zen/tools/timeout.sh -t 20 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
# else
# echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr'
# fi
# echo "$friend_of_mine" >> /tmp/friend_of_mine
# else
# echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me"
# fi
# MEMORIZE actual tryme.addr (gchange_IPFS_swarm.sh is getting it from IPNS capsule)
cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/
fi
sleep $((1 + RANDOM % 2)) # SLOW DOWN

View File

@ -32,26 +32,44 @@ echo $(date)
########################################################################
# Let's look for Friends and "IPFS swarm connect" with them
########################################################################
# 1. Get Gchange "liking_me" people list (made by gchange_INIT.sh)
[[ ! -f /tmp/liking_me ]] && ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me
rm -f /tmp/liking_me ## FILE WILL BE REFRESHED
for liking_me in $(cat /tmp/liking_me | sort | uniq);
# Check liking_me station in my swarm FRIENDS
for swarm_frof in $(ls ~/.zen/ipfs_swarm/.*/FRIENDS/$G1PUB/stars.level | cut -d '/' -f 6 | cut -d '.' -f 2); ## FROM IPFS
do
liking_me=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $swarm_frof)
## PUBLISH /tmp/liking_me for ./tools/add_externIP_to_ipfstryme.sh
echo "$liking_me" >> /tmp/liking_me
do_I_like=$(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$liking_me 2>/dev/null)
# Get Gchange "liking_me" people list (made by gchange_INIT.sh)
# [[ ! -f /tmp/liking_me ]] && ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me.try && [ ! -s /tmp/liking_me.try ] && cp /tmp/liking_me.try /tmp/liking_me && rm /tmp/liking_me.try
#for liking_me in $(cat /tmp/liking_me | sort | uniq); ## FROM GCHANGE
#do
[[ "$liking_me" == "" || "$liking_me" == "$G1PUB" ]] && continue
# DE TOUS CEUX QUI M'AIMENT JE VAIS LIRE LES MESSAGES pour collecter leurs ipfstryme vers ~/.zen/A_swarm_map.txt
# SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt
# Check if my like is reverse
liking_me_count=$((liking_me_count+1))
echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me"
## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me
echo ">>>>>> CHECKING liking_me n° $liking_me_count "
## IPFS WAY TO DO IT (LESS STRESS ON GCHANGE)
rm /tmp/ipfstryme.$liking_me 2>/dev/null
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $liking_me)
echo "Getting /ipns/$ipfsnodeid/.$ipfsnodeid/tryme.addr ..."
ipfs --timeout=30s cat /ipns/$ipfsnodeid/.$ipfsnodeid/tryme.addr > /tmp/ipfstryme.$liking_me
if [[ ! -f /tmp/ipfstryme.$liking_me ]]; then
echo ": READING 'ipfstryme' message from $liking_me"
## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me
fi
## ZOMBIE NODE sends more that 300 ipfstryme ?
## [[ $(cat /tmp/ipfstryme.$liking_me | sort | uniq | wc -l) -gt 300 ]] && echo "THIS NODE IS A ZOMBIE..." && rm -f /tmp/ipfstryme.$liking_me && continue
# CLEAN /tmp/ipfstryme.$liking_me
> /tmp/ipfstryme.clean
for line in $(cat /tmp/ipfstryme.$liking_me);
for line in $(cat /tmp/ipfstryme.$liking_me | shuf);
do
ipfsnodeid=$(echo $line | rev | cut -d '/' -f 1 | rev)
[[ $ipfsnodeid == "" ]] && break
@ -63,7 +81,6 @@ do
echo "__________________________________________"
done
for peerline in $(cat /tmp/ipfstryme.* | sort | uniq);
do
echo "======================================================"
@ -77,7 +94,7 @@ do
[[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
[[ ! $whoisg1 ]] && continue
# KEEPING LAST ipfstryme MESSAGES only
# KEEPING LAST ipfstryme MESSAGES only (CAN BE REMOVED SOON WHEN FULL IPFS)
nbmessage=0
for messageid in $(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$whoisg1" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
do
@ -88,6 +105,10 @@ do
[[ $nbmessage == 0 ]] && echo "NO ipfstryme MESSAGE from $whoisg1" && echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt && continue
# SEND MESSAGE ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $whoisg1 -t 'Astroport' -m 'Aucun message de ta part https://copylaradio.com'"
## CHECKING VALUE CAPSULE
starsin=$(ipfs --timeout=10s cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/stars.level)
starsout=$(ipfs --timeout=10s cat /ipns/$IPFSNODEID/.$IPFSNODEID/FRIENDS/$whoisg1/stars.level)
# REFRESH A_swarm_map.txt
echo $peerline >> ~/.zen/A_swarm_map.txt
cat ~/.zen/A_swarm_map.txt | sort | uniq > /tmp/A_swarm_map.txt
@ -95,20 +116,27 @@ do
# FRIEND ADDRESS DISCOVERY
echo "Am I friend with my FRIEND friend $whoisg1 ?"
friend_of_mine=$(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID
if [[ "$friend_of_mine" != "null" ]]; then
# ipfs cat /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/tryme.addr # IS my own /ipns/$IPFSNODEID/.$IPFSNODEID/tryme.addr
# GCHANGE : friend_of_mine=$(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID
## LOOKING IN SWARM CACHE
friend_of_mine=$(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$whoisg1 2>/dev/null)
if [[ $friend_of_mine ]]; then
if [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]]
then
echo "OK FRIEND"
# COUNT UNIQ FRIENDS
friend_of_mine_count=$((friend_of_mine_count+1))
echo "$peerline" >> ~/.zen/A_my_swarm.txt
ipfs bootstrap add "$peerline"
# ipfs bootstrap add "$peerline"
## NOW WILL BE USING Peering.Peers config
else
echo "ALREADY RECORDED FRIEND"
fi
## Sync ipfs_swarm
ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
else
## REMOVE FRIENDS DIRECTORY (should be removed from Astroport App)
echo "NOT FULL FRIEND $ipfsnodeid / $whoisg1"
[[ "$liking_me" != "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me
# SEND ME A MESSAGE TO DECIDE WHAT TO DO ?
@ -127,17 +155,19 @@ echo "####################################################
I have $friend_of_mine_count friends amoung $liking_me_count liking me people
__________________________________________
My actual #SWARM0"
ipfs swarm peers
# ipfs swarm peers
echo $(date)
echo "####################################################"
# ipfs SWARM shaping
# ipfs_SWARM_refresh
[[ $(cat ~/.zen/A_my_swarm.txt | wc -l) -gt 0 ]] && ~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh && exit 0 || echo "SWARM LOST !! "
## SHOULD HAVE exit 0 before !!
########################################################################
## SWARM LOST !! EMERGENCY RECOVERY !! TEST CODE
########################################################################
## ERROR !! SHOULD HAVE exit 0 before !!
########################################################################
## SWARM LOST !! EMERGENCY RECOVERY CODE !!!
########################################################################
ipfs bootstrap > /tmp/ipfs_bootstrap

View File

@ -32,14 +32,24 @@ IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n')
for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS | shuf);
do
[[ "$g1id" == "index.html" ]] && continue
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id)
[ -d ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1id ] && ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id) || continue
echo "=============================================="
echo "$ipfsnodeid"
echo "=============================================="
# Try to ping my friend OR continue
ipfs --timeout=10s ping -n 3 /p2p/$ipfsnodeid || continue
#ipfs --timeout=10s ping -n 3 /p2p/$ipfsnodeid || continue
echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
ipfs --timeout=90s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
[[ -f /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && cat /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid || echo "NO ZUID"
#echo "REFRESHING Friend /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
#ipfs --timeout=90s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
#[[ -f /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && cat /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid || echo "NO ZUID"
echo "This is the list of your friend $g1id friends liking you"
ls -d ~/.zen/ipfs_swarm/.$ipfsnodeid/FRIENDS/*/ 2>/dev/null | rev | cut -d '/' -f 2 | rev
echo "LIKING YOU?"
ls -d ~/.zen/ipfs_swarm/.$ipfsnodeid/FRIENDS/$G1PUB/ 2>/dev/null | rev | cut -d '/' -f 2 | rev
done
exit 0

View File

@ -67,3 +67,13 @@ fi
ipfs p2p ls
## CONNECT WITH COMMAND
## ipfs cat /ipns/$IPFSNODEID/.$IPFSNODEID/x_ssh-$zuid.sh | bash
rm ~/.zen/ipfs/.$IPFSNODEID/x_ssh-$zuid.sh ## DEBUG
if [[ ! -f ~/.zen/ipfs/.$IPFSNODEID/x_ssh-$zuid.sh ]]; then
echo "echo 'Choix du port local pour ssh-$zuid ?'; read PORT; [[ ! \$(ipfs p2p ls | grep x/ssh-$zuid) ]] && ipfs --timeout=5s ping -n 1 /p2p/$IPFSNODEID && ipfs p2p forward /x/ssh-$zuid /ip4/127.0.0.1/tcp/\$PORT /p2p/$IPFSNODEID && ssh $YOU@127.0.0.1 -p \$PORT" > ~/.zen/ipfs/.$IPFSNODEID/x_ssh-$zuid.sh
fi
## THIS PORT FORWARDING HUB COULD BE MADE MORE CONTROLABLE USING FRIENDSHIP LEVEL & IPFS BALISES

View File

@ -19,9 +19,10 @@ IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n')
# This script is controling IPFS swarm
# Sync friends peers ~/.zen/ipfs/ into ~/.zen/ipfs_swarm/.IPFSNODEID's/ directories
# add not friend_of_mine IPs to fail2ban
## CREATES index.html to web publish
########################################################################
########################################################################
mkdir -p ~/.zen/ipfs_swarm
[ ! -d ~/.zen/ipfs_swarm ] && mkdir -p ~/.zen/ipfs_swarm
echo '
___ _ _ __ __ _ _ _ _ _ _ __
| |_)|_(_ (_\ //\ |_)|\/| |_)|_|_|_)|_(_ |_|
@ -45,36 +46,44 @@ touch /tmp/treated.ipfs.swarm
########################################################################
########################################################################
echo "******************************************************************"
echo "RETRIEVING MY OWN DATA FROM IPNS TO ~/.zen/ipfs_swarm"
#ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID
echo "REFRESHING MY OWN DATA FROM IPNS TO ~/.zen/ipfs_swarm"
find /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/ -type f -mtime +8 -exec rm '{}' \;
find /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/ -empty -type d -delete;
ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID
########################################################################
count=1
ipfs bootstrap > /tmp/ipfs_swarm_peers
ipfs swarm peers >> /tmp/ipfs_swarm_peers
for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq);
rm ~/.zen/A_peering_peers.txt
[[ ! -f ~/.ipfs/config.bak ]] && cp ~/.ipfs/config ~/.ipfs/config.bak ## Backup previous original
cp ~/.ipfs/config ~/.ipfs/config.new ## Prepare Peering.Peers changes
# for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq); ## TODO ACTIVATE IN DEFCON 4
for ipfsnodeid in $(cat ~/.zen/ipfs_swarm/.*/tryme.addr | grep -o '[^/]*$' | sort | uniq);
do
## $ipfsnodeid already Treated ?
[[ "$ipfsnodeid" == "$IPFSNODEID" ]] && continue
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && XID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid) || XID=''
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title ]] && XZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || XZUID=''
[[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT STATION
# [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue
[[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && echo "DEAD SWARM" && continue
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && XID=$(ipfs --timeout=20s cat /ipns/$ipfsnodeid/.$ipfsnodeid/_xbian.zuid) || XID=''
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title ]] && GZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || GZUID=''
# [[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT FRIEND STATION
# [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue ## TODO ACTIVATE IN DEFCON 4
# [[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && echo "DEAD SWARM" && continue ## TODO ACTIVATE IN DEFCON 4
# control ip isLAN?
peerline=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | tail -n 1)
peerline=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | grep '/quic/' | head -n 1) ## Prefer quic protocol addresses
[[ ! $peerline ]] && peerline=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | tail -n 1)
ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | tail -n 1) && [[ ! $ip ]] && continue
ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | grep '/quic/' | head -n 1 | awk -F '/' '{print $3}') && [[ ! $ip ]] && continue
isLAN=$(echo $ip | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
nowdate=$(date)
# Convert ipfsnodeid into g1pub
# Convert ipfsnodeid into g1pub (only for 12D adresses, others are not Astroport)
[[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt
echo "#############################################################"
echo "### ANALYZING $ipfsnodeid ($ip) $XID $XZUID ###"
echo "### ANALYZING $ipfsnodeid ($ip) $XID $GZUID ###"
echo "$peerline"
myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid )
if [[ "$myfriendpeer" != "" ]];
@ -92,8 +101,8 @@ do
if [ $? != 0 ]; then
grep -vEi $ip ~/.zen/A_my_swarm.txt
echo $ipfsnodeid >> ~/.zen/A_dead_swarm.txt
echo "SEND MESSAGE ABOUT UNREACHABLE FRIEND $whoisg1 ($XID) ($XZUID)"
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $G1PUB -t "ALERT" -m "Impossible de se synchroniser avec $whoisg1 ($XID) ($XZUID)"
echo "SEND MESSAGE ABOUT UNREACHABLE FRIEND $whoisg1 ($XID) ($GZUID)"
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $G1PUB -t "ALERT" -m "Impossible de se synchroniser avec $whoisg1 ($XID) ($GZUID)"
# KEEPING LAST 10 ALERT MESSAGES
nbmessage=0
for messageid in $(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$G1PUB" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ALERT")' | jq -r '.id')
@ -104,26 +113,50 @@ do
continue
fi
fi
## Add to bootstrap if XID exists
[[ "$XID" != "" ]] && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline"
echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
if [ $? != 0 ];
then
echo "TIMEOUT REACHED ___ REMOVE $ipfsnodeid FROM ~/.zen/A_my_swarm.txt";
else
################################################################
## Refresh bootstrap if XID exists
if [[ "$XID" != "" ]]; then
ipfs bootstrap rm "/ipfs/$ipfsnodeid" && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline"
################################################################
## REFRESH stargates keys from my friend
################################################################
mkdir -p ~/.zen/key/stargates/$whoisg1
ipfs --timeout=60s get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/
## DECRYPT
if [[ $? == 0 ]]; then
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate1"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate2"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate3"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate4"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate5"
echo "Removing 8 days older data from ~/.zen/ipfs_swarm/.$ipfsnodeid/"
find /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/ -type f -mtime +8 -exec rm '{}' \;
find /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/ -empty -type d -delete;
################################################################
echo "OK Friend SWARM REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
################################################################
if [ $? != 0 ];
then
echo "TIMEOUT REACHED ___ REMOVE FROM .Peering.Peers ";
# jq '.Peering.Peers |= map( if .ID=="'$ipfsnodeid'" then del(.) else . end )' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
else
################################################################
echo "@@ CREATING Peering.Peer @@"
echo ".Peering.Peers += { \"Addrs\": [], \"ID\": \"'$ipfsnodeid'\" }"
################################################################
Addr=$(echo "$peerline" | rev | cut -d '/' -f 2- | rev )
IsAlreadythere=$(cat ~/.ipfs/config.new | grep \"$ipfsnodeid\") && echo $IsAlreadythere
if [[ ! $IsAlreadythere ]]; then
echo '{ "ID": "'$ipfsnodeid'", "Addrs": [] }' >> ~/.zen/A_peering_peers.txt
#jq '.Peering.Peers? += { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
jq '.Peering.Peers[.Peering.Peers| length] |= . + { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
fi
################################################################
echo "## REFRESH stargates keys from my friend"
################################################################
mkdir -p ~/.zen/key/stargates/$whoisg1
ipfs --timeout=60s get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/
## DECRYPT STARGATE KEYS
if [[ $? == 0 ]]; then
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate1"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate2"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate3"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate4"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate5"
## KEYS COULD BE ADDED TO ~/.ipfs/keystore/ ?
fi
fi
fi
else # if [[ "$myfriendpeer" != "" ]];
@ -135,7 +168,7 @@ do
#
[[ -f ~/.zen/DEFCON ]] && export DEFCON=$(cat ~/.zen/DEFCON) || export DEFCON=$(cat ~/.zen/astrXbian/DEFCON) # like in crom_MINUTE.sh
echo "!!! UNKNOWN FRIEND !!! $ip ___ $ipfsnodeid ________ # DEFCON : $DEFCON "
[[ -d ~/.zen/ipfs_swarm/.$ipfsnodeid ]] && rm -Rf ~/.zen/ipfs_swarm/.$ipfsnodeid && "REMOVE ipfs_swarm DIRECTORY"
[[ -d ~/.zen/ipfs_swarm/.$ipfsnodeid ]] && rm -Rf ~/.zen/ipfs_swarm/.$ipfsnodeid && echo "REMOVE ipfs_swarm DIRECTORY"
ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | head -n 1)
isLAN=$(echo $ip | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
@ -178,7 +211,19 @@ do
done
if [[ $DEFCON -eq 3 ]];
########################################################################
## FIND LOCAL IPFS NODE - SERACH FOR FOAF stargate replications
########################################################################
# SUBNET=$(ip route | tail -n 3 | cut -d ' ' -f 1)
# [[ ! $(which nmap) ]] && sudo apt-get install nmap -y && nmap --open -p 4001 $SUBNET
########################################################################
########################################################################
########################################################################
if [[ $DEFCON -eq 3 ]];#########################################################
########################################################################
then ## DEFCON 3
# ACTIVATE PRIVATE SMARM !! 1ST BOOTSRAP creates and send a key to every level3 friends he knows (PUB)
# RUN ONCE ONLY
@ -218,6 +263,8 @@ then ## DEFCON 3
fi
fi
fi
########################################################################
# REFRESH Film Serie Anime Youtube ${PREFIX}ASTRXBIAN index
########################################################################
@ -231,25 +278,36 @@ do
echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN
cat ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | sed "s/anime;/film;/g" | sed '/^[[:space:]]*$/d' | grep -Ev "CAT;TMDB" | sort | uniq >> ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN
done
## ACCESS TO www-data FOR www/boris ACCESS
chown $YOU:www-data ~/.zen/ipfs/.$IPFSNODEID/*ASTRXBIAN
chmod 664 ~/.zen/ipfs/.$IPFSNODEID/*ASTRXBIAN
## CORRECT SWARM FILE ACCESS RIGHTS to www-data
chmod 644 /home/$YOU/.zen/ipfs_swarm}/.*/astroport/kodi/vstream/*ASTRXBIAN
# Remove old database
# rm ~/.kodi/userdata/addon_data/plugin.video.vstream/astroport_cache.db
########################################################################
# REFRESH tiddlywiki WALL OF FRIENDS
## RENEW LIST OF FRIENDS index.html
########################################################################
# REFRESH tiddlywiki WALL OF FRIENDS /ipns/${IPFSNODEID}/.${IPFSNODEID}/FRIENDS/index.html
########################################################################
zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)"
updated="$(date +"%Y-%m-%d_%H:%M")"
echo "******************************************************************"
echo "### PUBLISH tiddlywiki WALL OF FRIENDS ###"
echo "<html>
<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='icon' type='image/png' href='https://tube.copylaradio.com/astrocrowdbunker.png' />
</head>
<body><header>
<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>
</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)
whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
echo "<li>
<a href=\"https://oasis.astroport.com/ipns/$ipfsnodeid/.$ipfsnodeid/index.html\">
<img src=\"https://oasis.astroport.com/ipns/$ipfsnodeid/.$ipfsnodeid/QR.png\" alt=\"$whoisg1\" />
<a target=\"gchange\" href=\"https://www.gchange.fr/#/app/user/$whoisg1/\">
<img src=\"https://tube.copylaradio.com/ipns/$ipfsnodeid/.$ipfsnodeid/QR.png\" alt=\"$whoisg1\" />
</a>
<p class='video-title'>
<a href=\"https://oasis.astroport.com/ipns/$ipfsnodeid/.$ipfsnodeid/index.html\">
\"$ipfsnodeid\"
<a href=\"https://tube.copylaradio.com/ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/index.html\">
$ipfsnodeid
</a>
</p>
<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
# 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
########################################################################

View File

@ -30,20 +30,7 @@ G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
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
########################################################################
# 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 "
_ _ _ _
/ \ / \ / \ / \
@ -66,6 +53,7 @@ count=0
for mediakey in $(ls ~/.zen/ipfs/.${IPFSNODEID}/KEY/); # Alternative search
do
[[ "${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}" == "" ]] && continue ## prevent empty IPNSLINK
count=$((count+1)) && echo "$count) "
@ -177,7 +165,7 @@ do
<source src=\"$TUBELINK\" type=\"$MIMETYPE\">
</$HTMLTAG>
<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>
</main>
<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)
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
## GET ACTUAL IPNS .chain VALUE

View File

@ -5,11 +5,12 @@ 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
########################################################################
IPFSNODEID=$(ipfs --timeout=30s id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "ipfs TIMEOUT" && exit 1
########################################################################
## TESSERACT DOUBLE ACTION
########################################################################
echo "Adding ~/.zen/ipfs to IPFS"
MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
@ -21,7 +22,7 @@ then
echo $MIPFS > ~/.zen/ipfs/.${IPFSNODEID}/.chain
MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
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
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"
# Add trailing / if needed
length=${#path}
length=${#path}
last_char=${path:length-1:1}
[[ $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 ?
if [[ $PREFIX == "" ]]
then
[[ "$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
[[ "$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
fi
[[ ! -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 )
########################################################################
case ${CAT} in
video)
INDEXPREFIX="VIDEO_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE="${file%.*}"
;;
youtube)
INDEXPREFIX="YOUTUBE_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE="${file%.*}"
;;
mp3)
## DIFFERENT TREATMENT
INDEXPREFIX="MP3_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE=$(echo "$file" | cut -d "&" -f 2-)
er="$er | Please use new_mp3_in_astroport.sh ... EXIT"
echo "$er"
exit 1
;;
film | serie)
INDEXPREFIX="TMDB_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) # Path contains TMDB id
if ! [[ "$REFERENCE" =~ ^[0-9]+$ ]] # ${REFERENCE} NOT A NUMBER
then
er="$er | ERROR: $path BAD TMDB code. Get it from https://www.themoviedb.org/ or use your 06 phone number"
echo "$er"
exit 1
fi
;;
## TODO ADD "httrack" for website copying
## httrack "https://wiki.lowtechlab.org" -O "./wiki.lowtechlab.org" "+*.lowtechlab.org/*" -v -%l "fr"
##
*)
er="$CAT inconnu" && echo "$er" && exit 1
;;
video)
INDEXPREFIX="VIDEO_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE="${file%.*}"
;;
youtube)
INDEXPREFIX="YOUTUBE_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE="${file%.*}"
;;
mp3)
## DIFFERENT TREATMENT
INDEXPREFIX="MP3_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 )
TITLE=$(echo "$file" | cut -d "&" -f 2-)
er="$er | Please use new_mp3_in_astroport.sh ... EXIT"
echo "$er"
exit 1
;;
film | serie)
INDEXPREFIX="TMDB_"
REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) # Path contains TMDB id
if ! [[ "$REFERENCE" =~ ^[0-9]+$ ]] # ${REFERENCE} NOT A NUMBER
then
er="$er | ERROR: $path BAD TMDB code. Get it from https://www.themoviedb.org/ or use your 06 phone number"
echo "$er"
exit 1
fi
;;
## TODO ADD "httrack" for website copying
## httrack "https://wiki.lowtechlab.org" -O "./wiki.lowtechlab.org" "+*.lowtechlab.org/*" -v -%l "fr"
##
*)
er="$CAT inconnu" && echo "$er" && exit 1
;;
esac
MEDIAKEY="${INDEXPREFIX}${REFERENCE}"
@ -102,28 +102,28 @@ MEDIAKEY="${INDEXPREFIX}${REFERENCE}"
########################################################################
echo "SEARCH for ;$REFERENCE; in ${PREFIX}ASTRXBIAN"
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 )
if [[ ${isREFERENCEinINDEX} ]]
then
if [[ -d ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB} ]]
then
# FILE IS MINE, NEW VERSION?! replacing it in INDEX
ipnslink=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link)
echo "FOUND IPNS ${MEDIAKEY} = $ipnslink"
isREFERENCEinINDEX=$(grep ";$REFERENCE;" ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN )
if [[ ${isREFERENCEinINDEX} ]]
then
if [[ -d ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB} ]]
then
# FILE IS MINE, NEW VERSION?! replacing it in INDEX
ipnslink=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link)
echo "FOUND IPNS ${MEDIAKEY} = $ipnslink"
# DELETING GCHANGE AD, WILL BE CREATED AGAIN
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
rm ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad
else
er="$er | FILE IS ALREADY EXISTING FROM ANOTHER FRIEND" && echo "$er"
## 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)
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..."
##
fi
fi
# DELETING GCHANGE AD, WILL BE CREATED AGAIN
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
rm ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad
else
er="$er | FILE IS ALREADY EXISTING FROM ANOTHER FRIEND" && echo "$er"
## 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)
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..."
##
fi
fi
fi
@ -148,30 +148,31 @@ URLENCODE_FILE_NAME=$(echo ${file} | jq -Rr @uri)
## CREATE NEW ipns KEY : ${MEDIAKEY}
########################################################################
## IPFS SELF IPNS DATA STORAGE
## ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/
## ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/
########################################################################
if [[ ! $(ipfs key list | grep "${MEDIAKEY}") ]]; then
## IPNS KEY CREATION
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}
KEY=$(ipfs key gen "${MEDIAKEY}")
KEYFILE=$(ls -t ~/.ipfs/keystore/ | head -n 1)
## IPNS KEY CREATION
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}
KEY=$(ipfs key gen "${MEDIAKEY}")
KEYFILE=$(ls -t ~/.ipfs/keystore/ | head -n 1)
fi
## IS IT NEW IPNS KEY?
if [[ $KEY ]]; then
# memorize IPNS key filename for easiest exchange
echo "$KEYFILE" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename
# Publishing IPNS key
echo "$KEY" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link
# CREATE .zen = ZEN economic value
touch ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.zen
# CREATE other encrypted copies for friends depending DEFCON & stars
# > STARGATE 1 - 2 - 3 - 4 - 5 !!
################ ENCRYPT keystore/$KEYFILE
echo "CREATING NEW IPNS MEDIAKEY"
# memorize IPNS key filename for easiest exchange
echo "$KEYFILE" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename
# Publishing IPNS key
echo "$KEY" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link
# CREATE .zen = ZEN economic value
touch ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.zen
# CREATE other encrypted copies for friends depending DEFCON & stars
# > STARGATE 1 - 2 - 3 - 4 - 5 !!
################ ENCRYPT keystore/$KEYFILE
else
## OLD IPNS KEY
KEY=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link)
KEYFILE=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename)
KEY=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.link)
KEYFILE=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.ipns.key.keystore_filename)
fi
[[ ! $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"
## CREATE $PINnode IPFS communication directory
[[ ! -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/.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
@ -259,7 +261,8 @@ rm /tmp/.ipfsid
########################################################################
## 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}/
########################################################################
@ -267,11 +270,11 @@ rm /tmp/.ipfsid
## EXPLANATIONS
########################################################################
# 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)
# 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)
# Counting video views = +1 .views.counter => decrypt key
@ -291,100 +294,25 @@ IPNSLINK=$(ipfs key list -l | grep ${MEDIAKEY} | cut -d ' ' -f 1)
## FIRST REDIRECT PAGE ${MEDIAKEY}/index.html
# https://tube.copylaradio.com/ipns/$IPNSLINK
#envsubst < ./www/boris/youtube_watch_step2.html > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/index.html
cat >~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/index.html <<EOF
<!DOCTYPE html>
<html>
<head>
<title>$TITLE in Astroport</title>
<meta charset="UTF-8">
<meta http-equiv="Refresh" content="7;URL=http://astroport/ipns/$IPNSLINK/${G1PUB}/">
<link rel='stylesheet' href='/styles/astroport/style.css' type='text/css' />
<link rel='icon' type='image/png' href='/styles/astroport/logo.png' />
</head>
<body>
<header>
<h6>
<a href='/'><span>ASTROPORT</span> <q>${XZUID}</q></a>
</h6>
</header>
<main>
<article>
<h1>$TITLE</h1>
<p>Lancement de la video dans 7 secondes...</p>
<p class="pubkey-and-copy-button">
Ce fichier vous est servi par une station amie. Faites lui un don pour la remercier&nbsp;:
<input type="text" id="pubkey" readonly value="${G1PUB}" />
<button id="copy">Tip !</button>
</p>
<p id="successMsg">
La clef de la station amie est maintenant copiée dans le presse-papier. Vous pouvez la coller dans le client Ğ1 de votre choix (Cesium par exemple) afin de faire votre don 😉
</p>
<script>
function copy() {
var copyText = document.querySelector("input#pubkey");
copyText.select();
document.execCommand("copy");
cat /home/$YOU/.zen/astrXbian/www/boris/youtube_watch_step2.html \
| sed "s/\${IPNSLINK}/$IPNSLINK/g" \
| sed "s/\${XZUID}/$XZUID/g" \
| sed "s/\${G1PUB}/$G1PUB/g" \
| sed "s/\${TITLE}/$TITLE/g" \
> ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/index.html
var successMsg = document.querySelector("#successMsg");
successMsg.style.opacity = "1";
var copyButton = document.querySelector("button#copy");
copyButton.style.animation = "none";
}
document.querySelector("button#copy").addEventListener("click", copy);
</script>
</article>
</main>
</body>
</html>
EOF
## SECOND REDIRECT PAGE ${MEDIAKEY}/${G1PUB}/index.html
# https://tube.copylaradio.com/ipns/$IPNSLINK/${G1PUB}/
#envsubst < ./www/boris/youtube_watch_step3.html > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/index.html
cat > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/index.html <<EOF
<!DOCTYPE html>
<html>
<head>
<title>$TITLE in Astroport</title>
<meta charset="UTF-8">
<link rel='stylesheet' href='/styles/astroport/style.css' type='text/css' />
<link rel='icon' type='image/png' href='/styles/astroport/logo.png' />
</head>
<body>
<header>
<h6>
<a href='http://astroport/'><span>ASTROPORT</span> <q>${XZUID}</q></a>
</h6>
</header>
<main>
<article>
<video autoplay="autoplay" controls>
<source src="/ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME">
<a href="/ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME">$TITLE</a>
</video>
<h1 class="video-title">
$TITLE
</h1>
</article>
</main>
</body>
</html>
EOF
#envsubst < ../www/boris/youtube_watch_step3.html > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/index.html
cat /home/$YOU/.zen/astrXbian/www/boris/youtube_watch_step3.html \
| sed "s/\${TITLE}/$TITLE/g" \
| sed "s/\${XZUID}/$XZUID/g" \
| sed "s/\${IPFSREPFILEID}/$IPFSREPFILEID/g" \
| sed "s/\${URLENCODE_FILE_NAME}/$URLENCODE_FILE_NAME/g" \
> ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/index.html
# echo "<meta http-equiv=\"Refresh\" content=\"0;URL=http://127.0.0.1:8181/ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/index.html
@ -409,49 +337,49 @@ IPNS=$(ipfs name publish --quieter --key="${MEDIAKEY}" $NEWIPFS)
########################################################################
########################################################################
# POST TRAITEMENTS
# POST TRAITEMENTS
########################################################################
# film/serie PUBLISH "ajouter_video.txt" for KODI
########################################################################
if [[ "${CAT}" =~ ^(film|serie|youtube)$ ]]
then
## CREATE GCHANGE AD
if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad && "${CAT}" != "youtube" ]]
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)
echo $GOFFER > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad
NEWIPFS=$(ipfs add -rHq ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ | tail -n 1 )
IPNS=$(ipfs name publish --quieter --key="${MEDIAKEY}" $NEWIPFS)
fi
echo "Annonce gchange : $(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad)"
## CREATE GCHANGE AD
if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad && "${CAT}" != "youtube" ]]
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)
echo $GOFFER > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad
NEWIPFS=$(ipfs add -rHq ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ | tail -n 1 )
IPNS=$(ipfs name publish --quieter --key="${MEDIAKEY}" $NEWIPFS)
fi
echo "Annonce gchange : $(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/.gchange.ad)"
########################################################################
# ${PREFIX}ASTRXBIAN FILE : Add Header
[[ ! -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
########################################################################
# ${PREFIX}ASTRXBIAN FILE : Add Header
[[ ! -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
# ADD NEW LINE TO INDEX
if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt ]]
then
line=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt | sed "s/_IPFSREPFILEID_/$IPFSREPFILEID/g" | sed "s/_IPNSKEY_/$IPNS/g" )
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)
RES=${FILE_RES%?}0p
line="$CAT;${REFERENCE};$YEAR;$TITLE;$SAISON;;${IPNS};$RES;/ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME"
fi
echo "-------------------- UPDATE MY INDEX -----------------------------"
echo "$line"
echo "$line" >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN
echo "UPDATE IPNS ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ajouter_video.txt"
echo "$line" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt
## UPDATE SOURCE ajouter_video.txt FILE
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
########################################################################
# ADD NEW LINE TO INDEX
if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt ]]
then
line=$(cat ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt | sed "s/_IPFSREPFILEID_/$IPFSREPFILEID/g" | sed "s/_IPNSKEY_/$IPNS/g" )
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)
RES=${FILE_RES%?}0p
line="$CAT;${REFERENCE};$YEAR;$TITLE;$SAISON;;${IPNS};$RES;/ipfs/$IPFSREPFILEID/$URLENCODE_FILE_NAME"
fi
echo "-------------------- UPDATE MY INDEX -----------------------------"
echo "$line"
echo "$line" >> ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/${PREFIX}ASTRXBIAN
echo "UPDATE IPNS ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/ajouter_video.txt"
echo "$line" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${MEDIAKEY}/${G1PUB}/ajouter_video.txt
## UPDATE SOURCE ajouter_video.txt FILE
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
########################################################################
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
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
fi
########################################################################
@ -459,21 +387,21 @@ fi
########################################################################
if [[ "${CAT}" == "video" ]]
then
## 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
## 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
fi
########################################################################
# PUBLISH YOUTUBE video to /astroport/wordpress/
########################################################################
#########################################################################
# PUBLISH YOUTUBE video to /astroport/wordpress/ DATA NOT USED ANY MORE... semaphore à régler
#########################################################################
if [[ "${CAT}" == "youtube" ]]
then
## CREATE astroport call to Astroport/Wordpress stations
if [[ ! -d ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY} ]]; then
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY}
echo "1" > ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY}/do
fi
## CREATE astroport call to Astroport/Wordpress stations
if [[ ! -d ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY} ]]; then
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY}
echo "1" > ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${MEDIAKEY}/do
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')
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
# Actual behaviour is to accept anything from
# 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
## 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);
do
astrofilelinksec=$(echo "$astrofile" | sed "s/.ipfsid.encrypt/.ipfs.filelink.encrypt/g")
# decrypt $astrofile
mediakey=$(echo "$astrofile" | cut -d '/' -f 8 )
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 )
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"
## 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"
astrofile=$(cat /tmp/ipfslink.txt)
# PINNING NEW FILE
echo "SHOULD I PIN ~/.zen/PIN/${astrofile} ??"
if [[ ! -d ~/.zen/PIN/${astrofile} ]];
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)
$MY_PATH/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$astrofilelinksec" -o "/tmp/ipfsfilelink.txt"
ipfsrepidfile=$(cat /tmp/ipfsfilelink.txt | rev | cut -d '/' -f 2 | rev)
# PINNING NEW DIRECTORY & FILE
echo "SHOULD I PIN ~/.zen/PIN/${ipfsrepidfile} ??"
if [[ ! -d ~/.zen/PIN/${ipfsrepidfile} ]];
then
echo "PIN : $astrofile"
ipfs pin add /ipfs/$astrofile && mkdir -p ~/.zen/PIN/${astrofile}/
echo "RECORDING MY PIN ~/.zen/PIN/"
[[ -d ~/.zen/PIN/${astrofile} ]] && echo "0" > ~/.zen/PIN/${astrofile}/$G1PUB
echo "PIN ADD : $ipfsrepidfile"
ipfs pin add /ipfs/$ipfsrepidfile && mkdir -p ~/.zen/PIN/${ipfsrepidfile}/
echo "RECORDING NEW PIN ~/.zen/PIN/${ipfsrepidfile}"
[[ -d ~/.zen/PIN/${ipfsrepidfile} ]] && echo "$G1PUB" > ~/.zen/PIN/${ipfsrepidfile}/$ipfsnodesource
## 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)"
@ -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"
if [[ -f /tmp/ipns.mediakey ]]; then
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 )
echo "${mediakey}" > ~/.zen/PIN/${astrofile}/MEDIAKEY
echo "$(ipfs key list -l | grep ${mediakey} | cut -d ' ' -f 1)" > ~/.zen/PIN/${astrofile}/IPNSLINK
[[ ! -f ~/.ipfs/keystore/$KEYFILE ]] && mv /tmp/ipns.mediakey ~/.ipfs/keystore/$KEYFILE || ( echo "$KEYFILE already existing in local keystore. CONTINUE" )
echo "${mediakey}" > ~/.zen/PIN/${ipfsrepidfile}/MEDIAKEY
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
fi
fi
@ -60,14 +74,17 @@ do
continue
fi
########## PIN MAKES YOU OFFICIAL FASTRXBIAN FILM DISTRIBUTOR
############################################ PINNING NODE MAKES ALL HIS FRIENDS MOVIES AVAILABLE TO ALL
## TODO : DECIDE TO ACTIVATE THIS BEHAVIOUR OR NOT ?
## 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
[[ "$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)
[[ -f ~/.zen/PIN/${astrofile}/$G1PUB ]] && break
[[ -f ~/.zen/PIN/${ipfsrepidfile}/$G1PUB ]] && break
done
exit 0