astroport/g1sms/sms_ASTROPORT.sh

74 lines
2.3 KiB
Bash
Raw Normal View History

2020-05-13 13:04:49 +02:00
#!/bin/bash
################################################################################
# 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
################################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
source $MY_PATH/init.sh
source $MY_PATH/functions.sh
2020-05-13 20:37:04 +02:00
2020-05-13 13:04:49 +02:00
TODAY=$(date '+%Y%m%d')
2020-05-13 20:37:04 +02:00
timestamp=$(date -u +%s%N | cut -b1-13)
2020-05-13 13:04:49 +02:00
log "__SUB:sms_ASTROPORT.sh"
2020-05-13 20:37:04 +02:00
# VERIFY task relay directory EXISTS and is 777
# LOCAL MODE
2020-05-13 13:04:49 +02:00
[[ ! -d /tmp/loveland_entrance ]] && mkdir -p /tmp/loveland_entrance && chmod -R 777 /tmp/loveland_entrance
2020-05-13 20:37:04 +02:00
# 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
# Search new SSB Publish
2020-05-13 13:04:49 +02:00
for hashfile in $(ls /tmp/loveland_entrance/); do
PHONE=$(cat $hashfile)
PHONEHASH=$(basename -- "$hashfile")
2020-05-13 20:37:04 +02:00
# TODO CHECK PHONE IN SWARM
# if [[ ! -f /home/$YOU/.zen/ipfs_swarm/.Qm*/CHANNEL/$PHONEHASH@*/_pub ]]; then
# fi
2020-05-13 15:09:53 +02:00
if [[ ! -f /home/$YOU/.zen/g1sms_wallets/$PHONE/_pub ]]; then
# NOT THERE
2020-05-13 13:04:49 +02:00
sms_INIT_ACCOUNT "$PHONE"
else
# ALREADY THERE
# Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU
2020-05-13 15:09:53 +02:00
PUBKEY=$(cat /home/$YOU/.zen/g1sms_wallets/$PHONE/_pub)
2020-05-13 13:04:49 +02:00
AMOUNTG1=$(silkaj_balance $PUBKEY)
AMOUNTDU=$(bc -l <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
2020-05-13 20:37:04 +02:00
# DOUBLE AUTH SMS !!
2020-05-13 13:04:49 +02:00
2020-05-13 20:37:04 +02:00
mess="Bonjour
Compte
2020-05-13 13:04:49 +02:00
Astroport Station"
# Send response SMS
sms_SEND "$PHONE" "$mess"
2020-05-13 20:37:04 +02:00
# SEND THE KEY !!
2020-05-13 13:04:49 +02:00
fi
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 "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit 0