forked from axiom-team/astroport
108 lines
3.9 KiB
Bash
Executable File
108 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
########################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# Version: 0.1
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
########################################################################
|
|
# 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
|
|
|
|
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
|
|
export IPFSNODEID=$(ipfs id -f='<id>\n') || er+=" ipfs id problem"
|
|
export WHOAMI=$(sbotc whoami | jq -r .id) || er+=" sbotc whoami problem"
|
|
[[ "$YOU" == "" || "$IPFSNODEID" == "" || "$WHOAMI" == "" ]] && echo "ERROR : $er " && exit 1
|
|
|
|
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 '
|
|
___ __ __
|
|
/ | _____/ /__________ ____ ____ _____/ /_
|
|
/ /| | / ___/ __/ ___/ __ \/ __ \/ __ \/ ___/ __/
|
|
/ ___ |(__ ) /_/ / / /_/ / /_/ / /_/ / / / /_
|
|
/_/ |_/____/\__/_/ \____/ .___/\____/_/ \__/
|
|
/_/
|
|
Love Land ENTRANCE CHECKING
|
|
|
|
'
|
|
[[ ! $G1SMS == "yes" ]] && echo "I am NOT a G1SMS Node... Can't do nothing... EXIT" && exit 1
|
|
|
|
/home/$YOU/.zen/astroport/zen/ipfs_SWARM_refresh.sh
|
|
|
|
for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do
|
|
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")
|
|
echo "We have received Ajax Astroport request from $PHONE"
|
|
done
|
|
# CHECK if PHONE is ALREADY registered in SWARM
|
|
# 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
|
|
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")
|
|
|
|
echo "Astroport Ajax Request received $PP"
|
|
|
|
if [[ ! -f /home/$YOU/.zen/g1sms/$PHONE/_pub ]]; then
|
|
# PHONE IS 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
|
|
echo " RUN $MY_PATH/sms_NEW.sh "$PHONE" "$PARRAIN" "
|
|
|
|
else
|
|
# ACCOUNT ALREADY EXISTING
|
|
# Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU
|
|
PUBKEY=$(cat /home/$YOU/.zen/g1sms/$PHONE/_pub)
|
|
AMOUNTG1=$(silkaj_balance $PUBKEY)
|
|
AMOUNTDU=$(bc -l <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
|
|
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
|
|
|
|
# DOUBLE AUTH SMS !!
|
|
echo "RUN $MY_PATH/sms_AUTH.sh "$PHONE" "$PARRAIN" "
|
|
|
|
|
|
mess="Bonjour! Astroport Station"
|
|
|
|
# Send response SMS
|
|
sms_SEND "$PHONE" "$mess"
|
|
|
|
# SEND THE KEY !! AND START ONBOARDING
|
|
|
|
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
[[ -d /home/$YOU/.zen/g1sms/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms/$PHONE
|
|
|
|
exit 0
|