Trigger sms_ACTION from EMAIL... TX TODO

This commit is contained in:
qo-op 2020-01-30 00:13:55 +01:00
parent 73eca2426c
commit 43963548ea
3 changed files with 23 additions and 24 deletions

View File

@ -14,7 +14,7 @@ if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
#if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi # BUG because cron USER=""
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
cd $GPATH
@ -22,14 +22,9 @@ source ./shell/init.sh
source ./shell/functions.sh
timebar=$(date +%H:%M)
minut=$(date +%M)
##################################################################
if [[ "$1" == "" ]]; then
##################################################################
echo "$minut MN - It is $timebar in the morning, or in the night? It depends on your day..."
exit
fi
log "__CRON: $timebar $1"
minut=$(date +%M | sed 's/^0*//')
[[ $minut == "" ]] && minut=0
log "__CRON:cron_MINUTE.sh - $minut - It is $timebar ... $1"
##################################################################
##################################################################
@ -46,12 +41,12 @@ if [[ $(($minut%$EVERY)) == 0 ]]; then
TIMEBEFORE=$(date --date="-$EVERY minutes" +"%s")
[[ $NODE_G1PUBKEY == "" ]] && NODE_G1PUBKEY="5sdcypPRDrzEirtTqXwzvNnMwGpjXK6EhNdti8qsdS4h"
TIMESTAMP=$(date +"%s")
log "GETTING last $EVERY mn TX : https://duniter-g1.p2p.legal/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP"
#log "GETTING last $EVERY mn TX : https://duniter-g1.p2p.legal/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP"
curl -s https://duniter-g1.p2p.legal/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP | jq '.history.pending' | jq '.[].comment' > /tmp/scan.json
while read SMS_1_TEXT
do
export $SMS_1_TEXT
log "$NODE_G1PUBKEY TX RECEIVED !! COMMENT = " $SMS_1_TEXT
log "$NODE_G1PUBKEY TX PENDING !! COMMENT = " $SMS_1_TEXT
# TODO: VERIFY SOURCE PUBKEY IS RELATED TO A WALLET
# PUBKEY=
# WALLET=$(grep -Rwl "$PUBKEY" ./wallets/*/*.pub | head -n 1)
@ -90,7 +85,7 @@ while [[ $FROM != "" && $SUBJECT != "" ]]; do
curl -s --user "vir@g1sms.fr:Z1cG1V1r!" pop3://pop.bookmyname.com/1 --request dele --list-only
cat ./email.txt | sed s/EMAIL/"${FROM}"/g | sed s/SUBJECT/"G1sms+ INCONNU"/g | sed s/MESSAGE/"Portefeuille G1sms inconnu"/g | ssmtp ${FROM}
fi
log "NO MAIL"
#log "NO MAIL"
fi
done
@ -159,8 +154,12 @@ if [[ "$1" == "KALKUN" ]]; then
member=""
phone=$(echo $number | cut -d '/' -f 3);
if [[ -f $number/$phone.uidname ]]; then member=$(cat $number/$phone.uidname); fi
if [[ ! $member ]]; then member=$phone; fi
if [[ $phone && $member ]]; then add_contact $phone $member; log "__SUB:cron_MINUTE.sh: KALKUN add_contact $phone $member"; fi
if [[ $phone && $member ]]; then
rm_contact $phone $member;
sleep 2
add_contact $phone $member;
log "__SUB:cron_MINUTE.sh: KALKUN refresh contact $phone $member";
fi
done
fi
##################################################################

View File

@ -124,14 +124,14 @@ su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID"
count=1
# Search for All peers Nodes. TODO: To be changed when Swarm is too bug or not expendanding
#for id in ./wallets/.Qm*/;
for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
do
count=$((count+1))
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$id"
rm -Rf ./wallets_swarm/.$id
./shell/timeout.sh -t 20 su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
done
#for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
#do
# count=$((count+1))
# id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
# log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$id"
# rm -Rf ./wallets_swarm/.$id
# ./shell/timeout.sh -t 20 su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
#done
log "__SUB:ipfs_swarm_wallets_refresh: ./wallets_swarm/ RENEW from $count peers .........OK!!!"

View File

@ -96,7 +96,7 @@ then
rm -f "./authfile"
log_history $PHONE "G1BILLET, $TRANSAC, $BILLETPUBKEY"
sleep 3
sleep 5
# Fill BILLET with TRANSAC amount
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$TRANSAC" --output="$BILLETPUBKEY" --comment="G1Billet $NUMBER" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
@ -131,7 +131,7 @@ then
done
# + G1SMS Commission
sleep 2
sleep 10
COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$BILLCOM" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Achat G1Billets" -y)
# POUR IMPRIMER LES BILLETS! Brancher votre imprimante, configurer cups, activer code lp ;)