2019-11-19 00:59:03 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-11-23 17:24:08 +01:00
|
|
|
DUNITER=$(grep g1_node ../config/config.php | awk '{ print $3}' | tr -d ';' | tr -d "'")
|
|
|
|
TXBLOCKS=$(curl -s $DUNITER/blockchain/with/tx | jq '.result.blocks[]')
|
2019-11-19 00:59:03 +01:00
|
|
|
TXBLOCKS=$(echo "$TXBLOCKS" | tail -n 5 | tr '\n' ' ')
|
2019-11-23 17:24:08 +01:00
|
|
|
keyword="merci"
|
2019-11-19 00:59:03 +01:00
|
|
|
|
2019-11-23 17:24:08 +01:00
|
|
|
for i in $TXBLOCKS; do
|
|
|
|
result=$(curl -s $DUNITER/blockchain/block/$i | jq '.transactions[].comment' | grep -v '""' | tr -d '"')
|
2019-11-19 00:59:03 +01:00
|
|
|
|
2019-11-23 17:24:08 +01:00
|
|
|
### TODO: Finaliser pour cas réel, prendre en compte plusieurs transactions gmarche dans même block, ainsi que transaction déjà passé en Vendu.
|
|
|
|
isSell=$(echo "$result" | grep "$keyword")
|
|
|
|
[[ ! -z $isSell ]] && echo $isSell
|
|
|
|
echo ---
|
2019-11-19 00:59:03 +01:00
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
isSell="[Achat GMarche] : testCesium"
|
|
|
|
isSell=$(echo $isSell | cut -d' ' -f4-)
|
|
|
|
|
2019-11-23 17:24:08 +01:00
|
|
|
#echo "$isSell est vendu"
|
2019-11-19 00:59:03 +01:00
|
|
|
|
|
|
|
req="UPDATE products SET status = 'solde' WHERE name = '$isSell';"
|
|
|
|
|
2019-11-23 17:24:08 +01:00
|
|
|
sudo mysql --database gmarche -e "$req"
|
|
|
|
sudo mysql --database gmarche -e "SELECT name,status FROM products;"
|
2019-11-19 00:59:03 +01:00
|
|
|
|
|
|
|
exit 0
|