2020-12-12 01:26:39 +01:00
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.04.28
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH = " `dirname \" $0 \"` " # relative
MY_PATH = " `( cd \" $MY_PATH \" && pwd )` " # absolutized and normalized
ME = " ${ 0 ##*/ } "
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# SYNC IPFS SWARM PEERS SHARED DATA .12D3KooW****
########################################################################'
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
########################################################################
2021-06-03 02:53:56 +02:00
IPFSNODEID = $( ipfs --timeout= 5s id -f= '<id>\n' )
2020-12-12 01:26:39 +01:00
[ [ $IPFSNODEID = = "" ] ] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
########################################################################
2021-02-28 23:41:58 +01:00
[ [ ! -f ~/.zen/secret.dunikey ] ] && exit 1
G1PUB = $( cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
2020-12-12 01:26:39 +01:00
########################################################################
2021-06-16 00:37:09 +02:00
echo "## FRIENDS IPFS PINGing"
2021-06-16 01:06:01 +02:00
for g1pub in $( ls -t ~/.zen/ipfs/.$IPFSNODEID /FRIENDS/) ; do [ [ $g1pub ] ] && ipfs ping --timeout= 7s -n 5 /ipfs/$( ~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1pub 2>/dev/null) 2>/dev/null; done
2021-06-16 00:37:09 +02:00
2021-06-15 20:23:07 +02:00
########################################################################
# ACTIVATE TO CONTROL SWARM STATION SAME CODE VERSION
########################################################################
2021-03-18 01:52:15 +01:00
## myCODE is a SECURITY about code SIMILARITY
2021-03-02 11:19:04 +01:00
## EACH NODE CAN CHECK IF ANOTHER HAS SAME IPFS CODE HASH
2021-06-15 20:23:07 +02:00
# 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 "
2020-12-12 01:26:39 +01:00
_ _ _ _
/ \ / \ / \ / \
( I | P | N | S )
\_ / \_ / \_ / \_ /
2021-06-15 20:23:07 +02:00
ZENTAG / MEDIAKEY : IPNS REFRESH
2021-03-02 18:56:33 +01:00
"
2021-03-31 01:19:41 +02:00
echo " I am /ipns/ $IPFSNODEID controling and refreshing my MEDIAKEY IPNS "
########################################################################
# REFRESH IPNS SELF PUBLISH
########################################################################
~/.zen/astrXbian/zen/ipns_self_publish.sh
########################################################################
2020-12-12 01:26:39 +01:00
count = 0
2021-03-17 18:17:42 +01:00
[ [ ! -d ~/.zen/ipfs/.${ IPFSNODEID } /KEY/ ] ] && exit 0
2020-12-12 01:26:39 +01:00
2021-06-14 16:35:38 +02:00
## TAKE CARE OF MY KEY
2021-03-17 16:41:56 +01:00
for id in $( ls ~/.zen/ipfs/.${ IPFSNODEID } /KEY/) ; # Alternative search
2020-12-12 01:26:39 +01:00
do
2021-03-31 01:19:41 +02:00
count = $(( count+1)) && echo " $count ) "
2021-02-28 23:41:58 +01:00
IPNSLINK = $( ipfs key list -l | grep ${ id } | cut -d ' ' -f 1)
2021-03-17 16:41:56 +01:00
FILE_NAME = $( cat ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.ipfs.filename)
TITLE = $( cat ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.title)
2021-06-14 16:35:38 +02:00
2021-03-20 01:33:02 +01:00
source = $( echo $id | cut -d '_' -f 1)
2021-04-23 21:41:13 +02:00
ANNONCE = $( cat ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.gchange.ad)
2021-05-13 01:50:09 +02:00
## CRYPTO EXAMPLE, use natools to decrypt (could also verify signature)
[ [ -f ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.ipfs.filelink.natools.encrypt ] ] && $MY_PATH /tools/natools.py decrypt -f pubsec -k " $HOME /.zen/secret.dunikey " -i " $HOME /.zen/ipfs/. ${ IPFSNODEID } /KEY/ ${ id } / ${ G1PUB } /.ipfs.filelink.natools.encrypt " -o " /tmp/ ${ id } _filelink.txt "
2021-06-15 20:16:52 +02:00
# file=$(cat /tmp/${id}_filelink.txt | rev | cut -d '/' -f 1 | rev)
2021-06-17 19:41:02 +02:00
TUBELINK = " https://tube.copylaradio.com $( cat /tmp/${ id } _filelink.txt) "
LOCALTUBELINK = " http://127.0.0.1:8181 $( cat /tmp/${ id } _filelink.txt) "
MIMETYPE = " video/ ${ LOCALTUBELINK ##*. } "
2021-06-15 19:08:20 +02:00
[ [ " $MIMETYPE " = = "video/avi" ] ] && MIMETYPE = "video/x-msvideo"
2021-05-13 01:50:09 +02:00
2021-06-16 01:06:01 +02:00
### IPNS LINK CAN EVOLVE (REFRESH EVERY 12 H TO MAINTAIN ALIVE IN THE SWARM) # TODO : Use templating
### This index.html is ipns link root, 1st welcome page for MEDIAKEY -> *** Redirect to CONTRACTS processing HERE ***
2021-06-17 21:39:14 +02:00
echo " <!DOCTYPE html>
<html>
<head>
<title>$TITLE in Astroport</title>
<meta charset = \" UTF-8\" >
<meta http-equiv= \" Refresh\" content = \" 10; URL = https://tube.copylaradio.com/ipns/$IPNSLINK /${ G1PUB } /\" >
<link rel = 'stylesheet' href = '/crowdbunker.css' type = 'text/css' />
<link rel = 'icon' type = 'image/png' href = '/astrocrowdbunker.png' />
</head>
<body>
<header>
<h6>
<a href = 'https://astroport.com' ><span>ASTROPORT/KODI</span> × <span> DEMO</span></a>
</h6>
</header>
<main>
<article>
<a href = \" $LOCALTUBELINK \" >LECTURE LOCALHOST</a>! Lancement de la video dans 10 secondes ...<br>
<h1 class = 'video-title' >Essayez <a href = 'https://copylaradio.com' >astrXbian</a> BETA Live TEstNET</h1>
</article>
</main>
<center><br>Démonstration du service Video Club du Datacenter P2P Libre et Légal.<br>
2021-06-17 21:40:35 +02:00
<br>Les dons au portefeuille du Media ( ${ id } ) rapportent à son Auteur, et payent son hébergement.
2021-06-17 21:39:14 +02:00
<br><a target = 'tube' href = \" https://www.gchange.fr/#/app/user/${ G1PUB } /\" ><img width = 222 src = \" https://tube.copylaradio.com/ipns/$IPNSLINK /QR.png\" ></a></center>
</body>
</html>" > ~/.zen/ipfs/. ${ IPFSNODEID } /KEY/ ${ id } /index.html
2021-03-01 01:53:42 +01:00
2021-03-18 02:24:41 +01:00
########################################################################
2021-06-16 01:06:01 +02:00
### Scenario are G1PUB subdivized. Thus each friend can establish own contract
2021-03-18 02:24:41 +01:00
# ~/.zen/ipfs/.${IPFSNODEID}/KEY/${INDEXPREFIX}${REFERENCE}/${G1PUB}/index.html
########################################################################
2021-06-16 01:06:01 +02:00
2021-03-18 02:24:41 +01:00
## Write KEY id (provide verification)
2021-03-17 16:41:56 +01:00
[ [ ! -f ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.id ] ] && echo ${ id } > ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.id
2021-05-07 02:31:22 +02:00
2021-06-16 01:06:01 +02:00
## THIS MAKES FRENCH COPY RIGHT LAW RESPECT
## LOCALHOST REDIRECT FOR INTERNAL KODI DEFCON 3 (swarm.key) ASTROPORT STATION MODE
2021-06-15 20:16:52 +02:00
# echo "<meta charset=\"UTF-8\"><meta http-equiv=\"Refresh\" content=\"0;URL=http://127.0.0.1:8181$(cat /tmp/${id}_filelink.txt)\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/index.html
2021-06-15 19:01:58 +02:00
# echo "<meta charset=\"UTF-8\"><meta http-equiv=\"Refresh\" content=\"0;URL=https://tube.copylaradio.com$(cat /tmp/${id}_filelink.txt)\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/index.html
2021-06-15 20:16:52 +02:00
2021-06-16 01:06:01 +02:00
## DEMO PERIOD
2021-06-15 20:16:52 +02:00
## NICE FINAL STREAMING PAGE
echo " <!DOCTYPE html>
<html>
<head>
2021-06-16 02:44:57 +02:00
<title>$TITLE in Astroport</title>
2021-06-15 20:16:52 +02:00
<meta charset = \" UTF-8\" >
2021-06-16 00:37:09 +02:00
<link rel = 'stylesheet' href = '/crowdbunker.css' type = 'text/css' />
2021-06-15 20:16:52 +02:00
<link rel = 'icon' type = 'image/png' href = '/astrocrowdbunker.png' />
</head>
<body>
<header>
<h6>
2021-06-16 02:44:57 +02:00
<a href = 'https://copylaradio.com' ><span>astrXbian</span> × <span> DEMO</span></a>
2021-06-15 20:16:52 +02:00
</h6>
</header>
<main>
<article>
2021-06-17 19:41:02 +02:00
<video controls><source src = \" $TUBELINK \" type = \" $MIMETYPE \" ></video>
2021-06-15 20:16:52 +02:00
<h1 class = 'video-title' >$TITLE </h1>
</article>
</main>
2021-06-16 00:37:09 +02:00
<center><br>Ce fichier possède un G1 portefeuille qui lui permet de payer son hébergement ( 0.5 G1 /bootstrap / jour ) .
<br>Faire un don permet de conserver le fichier ( ${ id } ) en ligne mais aussi de récompenser son Auteur!<br>
<br>
2021-06-17 15:48:45 +02:00
<br><img width = 222 src = \" https://tube.copylaradio.com/ipns/$IPNSLINK /QR.png\" ></center>
2021-06-15 20:16:52 +02:00
</body>
</html>" > ~/.zen/ipfs/. ${ IPFSNODEID } /KEY/ ${ id } / ${ G1PUB } /index.html
2021-05-07 02:31:22 +02:00
2021-03-31 01:19:41 +02:00
if [ [ " $source " = = "YOUTUBE" ] ]
2021-02-28 23:41:58 +01:00
then
2021-04-08 04:22:31 +02:00
echo " $source "
2021-04-08 04:11:46 +02:00
# mutiTUBE - activate .views.counter
# echo "<meta http-equiv=\"Refresh\" content=\"0;URL=https://tube.copylaradio.com/ipns/$IPNSLINK/${G1PUB}/go\">" > ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/index.html
# TODO go/index.php from nginx proxy acting act as gateway (= Easy Round robin DNS tube.copylaradio.com is dynamic IP swap swarm nodes from node performance...)
2021-02-28 23:41:58 +01:00
fi
2021-03-31 01:19:41 +02:00
# ln -s /$HOME/.zen/astrXbian/www /var/www/astrxbian
# Testez vos application à même la blockchain en la copiant dans ~/.zen/ipfs/.${IPFSNODEID}/KEY/${id}/${G1PUB}/go/
# Proposez de l'ajouter au dépot des applications web2.0 dans ../www/
2021-06-15 20:23:07 +02:00
########################################################################
# EXAMPLE TO ACTIVATE SECURITY : FORCE SIGNATURE VERIFICATION for each sensible file
########################################################################
2021-03-19 01:53:04 +01:00
echo " ~/.zen/ipfs/. ${ IPFSNODEID } /KEY/ ${ id } / ${ G1PUB } /.views.counter "
if [ [ ! -f ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.views.counter.sign ] ] ; then
echo "0" > ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.views.counter
$MY_PATH /tools/natools.py sign -f pubsec -k " $HOME /.zen/secret.dunikey " -i ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.views.counter -o ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /${ G1PUB } /.views.counter.sign
fi
2021-06-15 20:23:07 +02:00
2021-03-19 01:53:04 +01:00
$MY_PATH /tools/natools.py verify -p " ${ G1PUB } " -i " $HOME /.zen/ipfs/. ${ IPFSNODEID } /KEY/ ${ id } / ${ G1PUB } /.views.counter.sign " -o "/tmp/verified_msg" && echo "c'est bon" || echo "c'est pas bon"
# Each time a station modify .views.counter it signs, log and timestamp then publish new IPNS to swarm.
2021-05-06 17:53:49 +02:00
# If a "faulty" blockchain appears (Mediakey collision)...
2021-03-19 01:53:04 +01:00
# Message are sent to warn friends they have to manualy validate data conflict and merge back their mutual chain.
2021-06-15 20:23:07 +02:00
########################################################################
2021-06-16 01:06:01 +02:00
## CHAIN & IPNS REFRESH
2021-06-15 20:23:07 +02:00
########################################################################
2021-03-31 01:19:41 +02:00
# ipfs nanochain progression
I = $( ipfs add -qrH ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } / | tail -n 1)
OLDCHAIN = $( cat ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /.chain)
if [ [ " $OLDCHAIN " != " $I " ] ] # MODIFY CHAIN only if something was changed
then
echo " $( date -u +%s%N | cut -b1-13) " > ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /.timestamp
echo $I > ~/.zen/ipfs/.${ IPFSNODEID } /KEY/${ id } /.chain
fi
2021-02-28 23:41:58 +01:00
# KEY ZenTag IPNS name publish
J = $( ipfs name publish -k ${ id } --quieter /ipfs/${ I } )
2020-12-12 01:26:39 +01:00
2021-05-16 01:21:36 +02:00
echo " $id REFRESHED https://tube.copylaradio.com/ipns/ $J "
2021-06-15 20:23:07 +02:00
########################################################################
########################################################################
2020-12-12 01:26:39 +01:00
done
2021-06-15 20:23:07 +02:00
########################################################################
########################################################################
2021-06-14 16:35:38 +02:00
## TAKE CARE OF PIN CREATED THROUGH autoPINfriends.sh
## Then refresh MEDIAKEY IPNS/IPFS RELATION
## CORRECT ISSUE : https://git.p2p.legal/axiom-team/astrXbian/issues/25
2021-06-15 20:23:07 +02:00
########################################################################
2021-06-14 16:35:38 +02:00
for ipnslink in $( ls ~/.zen/PIN/*/IPNSLINK) ;
ipnsid = $( cat $ipnslink )
ipfsid = $( echo $ipnslink | cut -d '/' -f 6)
mediakey = $( cat~/.zen/PIN/${ ipfsid } /MEDIAKEY)
[ [ ! $( ipfs key list | grep ${ mediakey } ) ] ] && echo "ERROR MISSING MEDIAKEY" && continue
## GET ACTUAL IPNS .chain VALUE
2021-06-16 01:24:02 +02:00
actual = $( ipfs --timeout 12s cat /ipns/$ipnsid /.chain)
2021-06-14 16:35:38 +02:00
## PUBLISH IT
2021-06-16 01:24:02 +02:00
[ [ $actual ] ] && ipfs --timeout 20s name publish -k ${ mediakey } --quieter /ipfs/${ actual }
2021-06-14 16:35:38 +02:00
echo " REFRESHED https://tube.copylaradio.com/ipns/ $ipnsid TO /ipfs/ $actual "
done
2021-03-31 01:19:41 +02:00
2021-06-15 20:23:07 +02:00
########################################################################
########################################################################
########################################################################
2021-03-18 02:24:41 +01:00
# ACTIVATION MONNAIES LIBRES EQUIBIBREES
2021-05-20 23:49:32 +02:00
# En relatif M/N :
2021-02-28 23:41:58 +01:00
# DU(t+1)=(DU+c²)/r
2021-05-20 23:49:32 +02:00
# S(t+1)=(S+DU)/r
# M(t+1)=N (et oui, si vous regardez les formules, on n’ a pas besoin de M :slight_smile: On a donc pas besoin de stocker M !)
# r=(1+DU)*N/N(t+1) (diviser par r, c’ est multiplier par [N(t+1)/N]/(1+DU), qui prend en compte la variation de N)
# Chaque joueur démarre à 100 LOVE au début du JEu. DU = 100 LOVE.
# Le compteur de DU de chacun converge chaque jour vers 100 LOVE (prélevant au fort pour redistribuer aux faibles)
# amortis temporellement par C² (adapté à la durée de vie moyenne des joueurs de chaque essaim !!).
# Cela ressemble à circuit résonant (RLC) amortis par la durée de vie?!
2021-02-28 23:41:58 +01:00
# https://forum.monnaie-libre.fr/t/etude-commencer-a-la-moyenne/15231/34?u=qoop
2021-05-21 00:44:56 +02:00
# https://forum.monnaie-libre.fr/t/formules-en-referentiel-du-et-m-n/10417