gmarche/scripts/check_sold.sh

30 lines
755 B
Bash
Executable File

#!/bin/bash
#DUNITER="http://192.168.9.54:45000"
DUNITER="https://duniter-g1.p2p.legal"
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
TXBLOCKS=$(echo "$TXBLOCKS" | tail -n 5 | tr '\n' ' ')
#echo "$TXBLOCKS"
for i in $TXBLOCKS2; do
result=$(curl -s ${DUNITER}/blockchain/block/$i | jq '.transactions[].comment' | grep -v '""' | tr -d '"')
isSell=$(echo "$result" | grep "Merci")
# [[ ! -z $isSell ]] && echo $isSell
# echo ---
sleep 1
done
isSell="[Achat GMarche] : testCesium"
isSell=$(echo $isSell | cut -d' ' -f4-)
echo "$isSell est vendu"
req="UPDATE products SET status = 'solde' WHERE name = '$isSell';"
mysql --database gmarche -e "$req"
mysql --database gmarche -e "SELECT name,status FROM products;"
exit 0