SWARM refresh

This commit is contained in:
qo-op 2020-05-14 11:51:25 +02:00
parent 7f9c02fb71
commit 002b3bd3e8
6 changed files with 41 additions and 38 deletions

View File

@ -69,8 +69,8 @@ sudo sed -i "s/_SERVERNAME_/$nodename/g" /etc/nginx/conf.d/loveland.conf
if [[ ! -L /var/www/loveland ]]; then if [[ ! -L /var/www/loveland ]]; then
sudo ln -s /home/$YOU/.zen/astroport/www/LOVELand /var/www/loveland sudo ln -s /home/$YOU/.zen/astroport/www/LOVELand /var/www/loveland
fi fi
sudo chmod 777 /var/www/loveland/jukebox/albumart sudo chmod -R 777 /var/www/loveland/jukebox/albumart
sudo chmod 777 /var/www/loveland/jukebox/prefs sudo chmod -R 777 /var/www/loveland/jukebox/prefs
# Disabling default website # Disabling default website
sudo rm -f /etc/nginx/sites-enabled/default sudo rm -f /etc/nginx/sites-enabled/default

View File

@ -18,6 +18,13 @@ YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail
IPFSNODEID=$(ipfs id -f='<id>\n') IPFSNODEID=$(ipfs id -f='<id>\n')
TODAY=$(date '+%Y%m%d') TODAY=$(date '+%Y%m%d')
timestamp=$(date -u +%s%N | cut -b1-13) timestamp=$(date -u +%s%N | cut -b1-13)
# VERIFY task relay directory EXISTS and is 777
# LOCAL MODE
[[ ! -d /tmp/loveland_entrance ]] && mkdir -p /tmp/loveland_entrance && chmod -R 777 /tmp/loveland_entrance
# SWARM TASK MODE
[[ ! -d /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance ]] \
&& mkdir -p /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance \
&& chmod -R 777 /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance
echo ' echo '
___ __ __ ___ __ __
@ -29,9 +36,11 @@ echo '
Love Land ENTRANCE CHECKING Love Land ENTRANCE CHECKING
' '
[[ ! $G1SMS == "yes" ]] && echo "I am NOT a G1SMS Node... Can't do nothing... EXIT" && exit 1
# TODO SWARM MODE TEST and activate ? $MY_PATH/ipfs_SWARM_refresh.sh
#for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do
for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do
# PHONE=$(cat $hashfile) # PHONE=$(cat $hashfile)
# HPHONE=$(basename -- "$hashfile") # HPHONE=$(basename -- "$hashfile")
# echo "We have received Ajax Astroport request from $PHONE" # echo "We have received Ajax Astroport request from $PHONE"
@ -58,7 +67,7 @@ for hashfile in $(ls /tmp/loveland_entrance/); do
[[ $PARRAIN ]] && MEMRIB=$(sms_uid2key "$PARRAIN" "$PHONE" "$PIN") && echo "RIB PARRAIN: $MEMRIB" [[ $PARRAIN ]] && MEMRIB=$(sms_uid2key "$PARRAIN" "$PHONE" "$PIN") && echo "RIB PARRAIN: $MEMRIB"
# CREATE G1 WALLET # CREATE G1 WALLET
.$MY_PATH/sms_NEW.sh "$PHONE" "$PARRAIN" $MY_PATH/sms_NEW.sh "$PHONE" "$PARRAIN"
else else
# ACCOUNT ALREADY EXISTING # ACCOUNT ALREADY EXISTING
@ -69,7 +78,7 @@ for hashfile in $(ls /tmp/loveland_entrance/); do
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR") AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
# DOUBLE AUTH SMS !! # DOUBLE AUTH SMS !!
./sms_AUTH.sh "$PHONE" "$PARRAIN" $MY_PATH/sms_AUTH.sh "$PHONE" "$PARRAIN"
mess="Bonjour! Astroport Station" mess="Bonjour! Astroport Station"
@ -88,13 +97,4 @@ done
[[ -d /home/$YOU/.zen/g1sms_wallets/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms_wallets/$PHONE [[ -d /home/$YOU/.zen/g1sms_wallets/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms_wallets/$PHONE
# VERIFY task relay directory EXISTS and is 777
# LOCAL MODE
[[ ! -d /tmp/loveland_entrance ]] && mkdir -p /tmp/loveland_entrance && chmod -R 777 /tmp/loveland_entrance
# TASK SWARM MODE
[[ ! -d /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance ]] \
&& mkdir -p /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance \
&& chmod -R 777 /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance
exit 0 exit 0

View File

@ -1,6 +1,7 @@
jQuery(document).ready(function () { jQuery(document).ready(function () {
var host = window.location.hostname; var host = window.location.hostname;
$('#nodename').html(host); $('#nodename').html(host);
$("#formphone").submit(function(e) { $("#formphone").submit(function(e) {
e.preventDefault(); // avoid to execute the actual submit of the form. e.preventDefault(); // avoid to execute the actual submit of the form.
console.log("button PHONE clicked"); console.log("button PHONE clicked");

View File

@ -69,7 +69,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-xl-9 mx-auto"> <div class="col-xl-9 mx-auto">
<h1>Invitation</h1><br><br> <h1>Recevez une Invitation</h1><br><br>
</div> </div>
<div class="col-md-10 col-lg-8 col-xl-7 mx-auto"> <div class="col-md-10 col-lg-8 col-xl-7 mx-auto">
<form id="formphone"> <form id="formphone">
@ -88,7 +88,7 @@
<div class="row"> <div class="row">
<div class="col-xl-9 mx-auto"> <div class="col-xl-9 mx-auto">
<div id="phoneresultat"> <div id="phoneresultat">
<br><h4>LIBRE<br>vers un Futur plus Humain</h4> <br><h4>Soyons LIBRE<br>dirigeons nous vers un Futur plus Humain</h4>
</div> </div>
</div> </div>
</div> </div>
@ -117,7 +117,7 @@
<h2>Univers Numérique ancré dans le Réel</h2> <h2>Univers Numérique ancré dans le Réel</h2>
<p class="lead mb-0">Impossible à réaliser <b>jusqu'à aujourd'hui</b>! <p class="lead mb-0">Impossible à réaliser <b>jusqu'à aujourd'hui</b>!
Nous avons mis au point un système d'information totalement décentralisé. Créé par les Humains qui le compose. Nous avons mis au point un système d'information totalement décentralisé. Créé par les Humains qui le compose.
Chacun y est souverain. <b>Forgeron monétaire </b> relié aux Oasis de son réseau d'Amis. Chacun y est souverain. <b>Forgeron monétaire libre</b> relié aux Oasis de son réseau d'Amis.
<br><br>Ici nul privilège autre que celui consciemment transmis.<br><br> <br><br>Ici nul privilège autre que celui consciemment transmis.<br><br>
<h4>Fabriquez votre clef, évadons-nous ensemble !</h4></p> <h4>Fabriquez votre clef, évadons-nous ensemble !</h4></p>
</div> </div>
@ -125,7 +125,7 @@
<div class="row no-gutters"> <div class="row no-gutters">
<div class="col-lg-6 text-white showcase-img" style="background-image: url('img/bg-showcase-2.jpg');"></div> <div class="col-lg-6 text-white showcase-img" style="background-image: url('img/bg-showcase-2.jpg');"></div>
<div class="col-lg-6 my-auto showcase-text"> <div class="col-lg-6 my-auto showcase-text">
<h2>Bâtisseurs du Monde Libre</h2> <h2>Bâtisseurs du "Monde Libre"</h2>
<p class="lead mb-0">Astroport construit un "Metavers" composé du maillage des mini-mondes de chacun. <p class="lead mb-0">Astroport construit un "Metavers" composé du maillage des mini-mondes de chacun.
Tous associés, nous partageons nos besoins, nos compétences, nos connaissances. Tous associés, nous partageons nos besoins, nos compétences, nos connaissances.
<br><br> <br><br>
@ -255,6 +255,7 @@
typeSpeed: 40 typeSpeed: 40
}); });
</script> </script>
</body>
</body>
</html> </html>

View File

@ -17,19 +17,18 @@ if (strlen($_REQUEST['phone']) == 10 ) {
// CREATE FILE for POST TREATMENT with sms_ASTROPORT.sh // CREATE FILE for POST TREATMENT with sms_ASTROPORT.sh
// LOCAL // LOCAL
$fp = fopen('/tmp/loveland_entrance/'.$HPHONE, 'w'); $fp = fopen('/tmp/loveland_entrance/'.$HPHONE, 'w');
fwrite($fp, $PHONE.'|'.$PARRAIN.'|'.$naissance);
/*
// MODE SWARM Syntax error: ")" unexpected TODO DEBUG
exec("ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)", $YOU, $return);
fwrite($fp, $PHONE.'|'.$PARRAIN.'|'.$naissance);
// MODE SWARM : write
$YOU = exec("ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1", $output, $return);
if ($return == 0) { if ($return == 0) {
print ($YOU); $IPFSNODEID = exec("ipfs id -f='<id>\n'", $output, $return);
exec("ipfs id -f='<id>\n'", $IPFSNODEID, $return);
// ACCESS RIGHT PROBLEM !!! // ACCESS RIGHT PROBLEM !!!
$fp = fopen('/home/$YOU/.zen/ipfs/.'.$IPFSNODEID.'/TASK/loveland_entrance/'.$HPHONE, 'w'); $fp = fopen('/home/'.$YOU.'/.zen/ipfs/.'.$IPFSNODEID.'/TASK/loveland_entrance/'.$HPHONE, 'w');
fwrite($fp, $PHONE); fwrite($fp, $PHONE);
} }
*/
return true; return true;
} else { } else {
return false; return false;

View File

@ -16,7 +16,8 @@ ME="${0##*/}"
# ex: ./'$ME' # ex: ./'$ME'
# SYNC IPFS SWARM PEERS SHARED DATA .Qm**** # SYNC IPFS SWARM PEERS SHARED DATA .Qm****
########################################################################' ########################################################################'
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
[[ $YOU == "" ]] && echo "Please run ipfs daemon" && exit 1
######################################################################## ########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_info # ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_info
######################################################################## ########################################################################
@ -39,23 +40,24 @@ echo "I am $ipfsnodeid"
## CHANNELS SWARM INDEX COPY PROCEDURE ## CHANNELS SWARM INDEX COPY PROCEDURE
## SIGNAL ~/.zen/g1sms_wallets TODO ## SIGNAL ~/.zen/g1sms_wallets TODO
# NOW PUBLISH ~/.zen/ipfs/ to SWARM echo "PUBLISHING MY OWN /home/$YOU/.zen/ipfs/ to SWARM"
[[ ! -d ~/.zen/ipfs ]] && echo "ERROR : ~/.zen/ipfs/ NOT FOUND" && exit 1 [[ ! -d /home/$YOU/.zen/ipfs ]] && echo "ERROR : /home/$YOU/.zen/ipfs/ NOT FOUND" && exit 1
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1) IWALLETS=$(ipfs add -rHq /home/$YOU/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS) NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
ipfs get --output=~/.zen/ipfs_swarm/ /ipns/$ipfsnodeid ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
echo "REFRESHING /home/$YOU/.zen/ipfs_swarm/ from my SWARM peers"
count=1 count=1
# Search for All peers Nodes. ## TODO: To be changed when Swarm is too big or not expanding # Search for All peers Nodes. ## TODO: To be changed when Swarm is too big or not expanding
#for id in $(ls -d ~/.zen/ipfs_swarm/.Qm* | cut -d '.' -f 3); # Alternative search... #for id in $(ls -d ~/.zen/ipfs_swarm/.Qm* | cut -d '.' -f 3); # Alternative search...
for id in $(ipfs swarm peers | awk -F '/' '{print $7}'); for id in $(ipfs swarm peers | grep 'ip4' | awk -F '/' '{print $7}');
do do
count=$((count+1))
# FULL REFRESH (allow deletion, for DEV period) # FULL REFRESH (allow deletion, for DEV period)
# TODO: COMMENT TO LOWER DISK USAGE # TODO: COMMENT TO LOWER DISK USAGE
echo "Refreshing ~/.zen/ipfs_swarm/.$id ($count)" echo "Refreshing /home/$YOU/.zen/ipfs_swarm/.$id ($count)"
rm -Rf ~/.zen/ipfs_swarm/.$id rm -Rf /home/$YOU/.zen/ipfs_swarm/.$id
$MY_PATH/tools/timeout.sh -t 30 ipfs get --output=~/.zen/ipfs_swarm/ /ipns/$id $MY_PATH/tools/timeout.sh -t 30 ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$id
count=$((count+1))
done done
# TODO: TASK treatment. # TODO: TASK treatment.