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
sudo ln -s /home/$YOU/.zen/astroport/www/LOVELand /var/www/loveland
fi
sudo chmod 777 /var/www/loveland/jukebox/albumart
sudo chmod 777 /var/www/loveland/jukebox/prefs
sudo chmod -R 777 /var/www/loveland/jukebox/albumart
sudo chmod -R 777 /var/www/loveland/jukebox/prefs
# Disabling default website
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')
TODAY=$(date '+%Y%m%d')
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 '
___ __ __
@ -29,9 +36,11 @@ echo '
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 ?
#for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do
$MY_PATH/ipfs_SWARM_refresh.sh
for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do
# PHONE=$(cat $hashfile)
# HPHONE=$(basename -- "$hashfile")
# 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"
# CREATE G1 WALLET
.$MY_PATH/sms_NEW.sh "$PHONE" "$PARRAIN"
$MY_PATH/sms_NEW.sh "$PHONE" "$PARRAIN"
else
# ACCOUNT ALREADY EXISTING
@ -69,7 +78,7 @@ for hashfile in $(ls /tmp/loveland_entrance/); do
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
# DOUBLE AUTH SMS !!
./sms_AUTH.sh "$PHONE" "$PARRAIN"
$MY_PATH/sms_AUTH.sh "$PHONE" "$PARRAIN"
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
# 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

View File

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

View File

@ -69,7 +69,7 @@
<div class="container">
<div class="row">
<div class="col-xl-9 mx-auto">
<h1>Invitation</h1><br><br>
<h1>Recevez une Invitation</h1><br><br>
</div>
<div class="col-md-10 col-lg-8 col-xl-7 mx-auto">
<form id="formphone">
@ -88,7 +88,7 @@
<div class="row">
<div class="col-xl-9 mx-auto">
<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>
@ -117,7 +117,7 @@
<h2>Univers Numérique ancré dans le Réel</h2>
<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.
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>
<h4>Fabriquez votre clef, évadons-nous ensemble !</h4></p>
</div>
@ -125,7 +125,7 @@
<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 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.
Tous associés, nous partageons nos besoins, nos compétences, nos connaissances.
<br><br>
@ -255,6 +255,7 @@
typeSpeed: 40
});
</script>
</body>
</body>
</html>

View File

@ -17,19 +17,18 @@ if (strlen($_REQUEST['phone']) == 10 ) {
// CREATE FILE for POST TREATMENT with sms_ASTROPORT.sh
// LOCAL
$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) {
print ($YOU);
exec("ipfs id -f='<id>\n'", $IPFSNODEID, $return);
$IPFSNODEID = exec("ipfs id -f='<id>\n'", $output, $return);
// 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);
}
*/
return true;
} else {
return false;

View File

@ -16,7 +16,8 @@ ME="${0##*/}"
# ex: ./'$ME'
# 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
########################################################################
@ -39,23 +40,24 @@ echo "I am $ipfsnodeid"
## CHANNELS SWARM INDEX COPY PROCEDURE
## SIGNAL ~/.zen/g1sms_wallets TODO
# NOW PUBLISH ~/.zen/ipfs/ to SWARM
[[ ! -d ~/.zen/ipfs ]] && echo "ERROR : ~/.zen/ipfs/ NOT FOUND" && exit 1
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
echo "PUBLISHING MY OWN /home/$YOU/.zen/ipfs/ to SWARM"
[[ ! -d /home/$YOU/.zen/ipfs ]] && echo "ERROR : /home/$YOU/.zen/ipfs/ NOT FOUND" && exit 1
IWALLETS=$(ipfs add -rHq /home/$YOU/.zen/ipfs | tail -n 1)
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
# 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 $(ipfs swarm peers | awk -F '/' '{print $7}');
for id in $(ipfs swarm peers | grep 'ip4' | awk -F '/' '{print $7}');
do
count=$((count+1))
# FULL REFRESH (allow deletion, for DEV period)
# TODO: COMMENT TO LOWER DISK USAGE
echo "Refreshing ~/.zen/ipfs_swarm/.$id ($count)"
rm -Rf ~/.zen/ipfs_swarm/.$id
$MY_PATH/tools/timeout.sh -t 30 ipfs get --output=~/.zen/ipfs_swarm/ /ipns/$id
echo "Refreshing /home/$YOU/.zen/ipfs_swarm/.$id ($count)"
rm -Rf /home/$YOU/.zen/ipfs_swarm/.$id
$MY_PATH/tools/timeout.sh -t 30 ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$id
count=$((count+1))
done
# TODO: TASK treatment.