From 52366218b94f38b39043320d90f60747acb65ea8 Mon Sep 17 00:00:00 2001 From: qo-op Date: Wed, 13 May 2020 22:58:10 +0200 Subject: [PATCH] Love land entrance opening --- g1sms/functions.sh | 8 ++- g1sms/sms_ASTROPORT.sh | 81 +++++++++++++++++--------- g1sms/sms_AUTH.sh | 11 ++-- www/LOVELand/ajaxform.js | 4 +- www/LOVELand/index.html | 20 ++++++- www/LOVELand/zen_loveland_entrance.php | 22 ++++--- 6 files changed, 101 insertions(+), 45 deletions(-) diff --git a/g1sms/functions.sh b/g1sms/functions.sh index 4f96bb7..66143fd 100755 --- a/g1sms/functions.sh +++ b/g1sms/functions.sh @@ -283,12 +283,14 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)" PIN=$(/home/$YOU/.zen/astroport/zen/tools/diceware.sh | xargs) python3 /home/$YOU/.zen/astroport/zen/tools/key_create_dunikey.py "$UIDNA" "$PIN" ## Copy PubSec file to /tmp/secret.dunikey - mv /tmp/secret.dunikey /home/$YOU/.zen/g1sms_wallets/$PHONE/ + mv /tmp/secret.dunikey /home/$YOU/.zen/g1sms_wallets/$PHONE/ PUBKEY=$(cat $DUNIKEYFILE | grep 'pub:' | cut -d ' ' -f 2) + log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE = $UIDNA $PIN : $PUBKEY" [[ $PUBKEY == "" ]] && log "__SUB:sms_INIT_ACCOUNT: Problem making secret.dunikey" && exit 1 + ####################### - # ACTIVATE G1SMS WALLET + # ACTIVATE G1SMS WALLET SEND 3.14 G1 ####################### # log "$NODE_PUBSECFILE $PUBKEY THIRD_PARTY_MANAGER:$NODE_G1PUBKEY" duniter_server=$(/home/$YOU/.zen/astroport/zen/tools/duniter_getnode.sh) @@ -301,7 +303,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)" log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT" ################ - # GPG cypher PIN (ONLY CREATOR NODE CAN ACCESS IT !) + # GPG cypher PIN so ONLY CREATOR NODE CAN ACCESS IT !) ################ echo "$PIN" > "$PINFILE" echo "${IPFSPrivKey}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE" diff --git a/g1sms/sms_ASTROPORT.sh b/g1sms/sms_ASTROPORT.sh index 70a1045..8a53dff 100755 --- a/g1sms/sms_ASTROPORT.sh +++ b/g1sms/sms_ASTROPORT.sh @@ -3,45 +3,65 @@ # Author: Fred (support@qo-op.com) # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) -# This script is for inscription from a Web page (RUN by cron_MINUTE.sh) -# Web Ajax Form -> /tmp/loveland_entrance/$hashphone +################################################################################ +# AJAX REQUEST TRACKER : ASTROPORT ON BOARDING +# GETTING : PHONE + PARRAIN + NAISSANCE +# +# DataFlow : index.html + ajaxform.js + zen_loveland_entrance.php ################################################################################ MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized source $MY_PATH/init.sh source $MY_PATH/functions.sh +YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); +IPFSNODEID=$(su $YOU -c "ipfs id -f='\n'") TODAY=$(date '+%Y%m%d') timestamp=$(date -u +%s%N | cut -b1-13) -log "__SUB:sms_ASTROPORT.sh" +echo ' + ___ __ __ + / | _____/ /__________ ____ ____ _____/ /_ + / /| | / ___/ __/ ___/ __ \/ __ \/ __ \/ ___/ __/ + / ___ |(__ ) /_/ / / /_/ / /_/ / /_/ / / / /_ +/_/ |_/____/\__/_/ \____/ .___/\____/_/ \__/ + /_/ +Love Land ENTRANCE CHECKING -# 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 MODE -[[ ! -d /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/TASK/loveland_entrance ]] \ -&& mkdir -p /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/TASK/loveland_entrance \ -&& chmod -R 777 /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/TASK/loveland_entrance +' -# SWARM MODE -# for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do -# TODO SSB task relay MODE +# TODO SWARM MODE TEST and activate ? +#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" +#done +# if [[ ! -f /home/$YOU/.zen/ipfs_swarm/.Qm*/CHANNEL/$PHONEHASH@*/_pub ]]; then +# fi +# TODO SSB task relay MODE ?? # Search new SSB Publish for hashfile in $(ls /tmp/loveland_entrance/); do - PHONE=$(cat $hashfile) - PHONEHASH=$(basename -- "$hashfile") + PP=$(cat $hashfile) + PHONE=$(echo $PP | cut -d '|' -f 1) + PARRAIN=$(echo $PP | cut -d '|' -f 2) + NAISSANCE=$(echo $PP | cut -d '|' -f 3) + + HPHONE=$(basename -- "$hashfile") - # TODO CHECK PHONE IN SWARM -# if [[ ! -f /home/$YOU/.zen/ipfs_swarm/.Qm*/CHANNEL/$PHONEHASH@*/_pub ]]; then -# fi + echo "Astroport Ajax Request received $PP" if [[ ! -f /home/$YOU/.zen/g1sms_wallets/$PHONE/_pub ]]; then - # NOT THERE - sms_INIT_ACCOUNT "$PHONE" + # UNKNOW + # CHECK for Associated PARRAIN. GET PubKey? + PARRAIN=$(echo "$PARRAIN" | grep -E "([A-Za-z0-9\-\_]+$)") + [[ $PARRAIN ]] && MEMRIB=$(sms_uid2key "$PARRAIN" "$PHONE" "$PIN") && echo "RIB PARRAIN: $MEMRIB" + + # CREATE G1 WALLET + ./sms_NEW.sh "$PHONE" "$PARRAIN" + else - # ALREADY THERE + # ACCOUNT ALREADY EXISTING # Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU PUBKEY=$(cat /home/$YOU/.zen/g1sms_wallets/$PHONE/_pub) AMOUNTG1=$(silkaj_balance $PUBKEY) @@ -49,15 +69,15 @@ for hashfile in $(ls /tmp/loveland_entrance/); do AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR") # DOUBLE AUTH SMS !! + ./sms_AUTH.sh "$PHONE" "$PARRAIN" - mess="Bonjour -Compte -Astroport Station" + + mess="Bonjour! Astroport Station" # Send response SMS sms_SEND "$PHONE" "$mess" - # SEND THE KEY !! + # SEND THE KEY !! AND START ONBOARDING @@ -65,9 +85,16 @@ Astroport Station" done + [[ -d /home/$YOU/.zen/g1sms_wallets/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms_wallets/$PHONE -log "__SUB:sms_AUTH.sh: END sms_AUTH.sh " -log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~" +# 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 diff --git a/g1sms/sms_AUTH.sh b/g1sms/sms_AUTH.sh index 1e6570c..f8fe463 100755 --- a/g1sms/sms_AUTH.sh +++ b/g1sms/sms_AUTH.sh @@ -17,14 +17,13 @@ source $MY_PATH/init.sh source $MY_PATH/functions.sh PHONE=$1 -VALEUR=$2 +PARRAIN=$2 TODAY=$(date '+%Y%m%d') -log "__SUB:sms_AUTH.sh ($PHONE, $VALEUR)" +log "__SUB:sms_AUTH.sh ($PHONE, $PARRAIN) $TODAY" ## INITIALIZE RESULT FILE -[[ $VALEUR == "" ]] && echo "Indiquez la valeur des G1Billets" && exit 1 -[[ $PHONE != "" ]] && sms_INIT_ACCOUNT "$PHONE" "NOSMS" || exit 1 -[[ $UNKNOWN == "unknown" ]] && echo "G1sms Wallet $PHONE inconnu! Envoyer N au $MASTERPHONE" && exit 1 +# [[ $PHONE != "" ]] && sms_INIT_ACCOUNT "$PHONE" "NOSMS" || exit 1 # VERIFICATION ALREADY DONE BY CALLING bash +#[[ $UNKNOWN == "unknown" ]] && echo "G1sms Wallet $PHONE inconnu! Envoyer N au $MASTERPHONE" && exit 1 # Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU AMOUNTG1=$(silkaj_balance $PUBKEY) @@ -32,7 +31,7 @@ AMOUNTDU=$(bc -l <<< "scale=2; $AMOUNTG1 / $DUFACTOR") AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR") # Convert amount to G1 unit -VIR=$(bc -l <<< "scale=2; $VALEUR * $DUFACTOR / 100") +VIR=$(bc -l <<< "scale=2; $PARRAIN * $DUFACTOR / 100") # Need at least $MIN G1 available! MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT") diff --git a/www/LOVELand/ajaxform.js b/www/LOVELand/ajaxform.js index 82586ce..7637e07 100644 --- a/www/LOVELand/ajaxform.js +++ b/www/LOVELand/ajaxform.js @@ -7,10 +7,12 @@ jQuery(document).ready(function () { "
Suivez ses instructions pour finaliser votre inscription.

"); // declare these vars var phone = jQuery("#phone"); + var parrain = jQuery("#parrain"); + var naissance = jQuery("#naissance"); var data = ''; // ajax call to ajax.php jQuery.getJSON("zen_loveland_entrance.php", { - phone: phone.val() + phone: phone.val(), parrain: parrain.val(), naissance: naissance.val() }, function (data) { $("#phoneresultat").html("

Votre inscription en prise en compte...

"); }); diff --git a/www/LOVELand/index.html b/www/LOVELand/index.html index 012a4f2..b911afd 100644 --- a/www/LOVELand/index.html +++ b/www/LOVELand/index.html @@ -73,7 +73,6 @@
-
@@ -83,6 +82,7 @@
+
@@ -193,6 +193,24 @@
+ + +
+
+
+

DEV ZONE

+
+ +
+
+ +
+
+ +
+
+
+