g1-stats/g1-stats.sh

63 lines
2.0 KiB
Bash
Raw Normal View History

2019-10-29 04:55:50 +01:00
#!/bin/bash
2020-06-01 02:36:19 +02:00
################################################################################
# Author: Poka (poka@p2p.legal)
2020-06-24 21:18:23 +02:00
# Version: 0.2.0
2020-06-01 02:36:19 +02:00
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
# Git: https://git.p2p.legal/axiom-team/g1-stats
################################################################################
# Stop if error
set -e
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
if [[ -e $SCRIPTPATH/.env ]]; then source $SCRIPTPATH/.env; else echo "Veuillez créer votre fichier .env inspiré de .env.example" && exit 1; fi
2019-10-29 04:55:50 +01:00
2019-11-19 16:03:22 +01:00
### Initialisation des données ###
startTime=$(date +'%H:%M')
day=$(date +'%y-%m-%d')
dayP=$(date +'%d-%m-%y')
indexhtml="$WEBPATH/index.html"
2019-11-19 16:03:22 +01:00
echo -e "\n############# $day à $startTime #############\n"
2019-10-29 05:29:10 +01:00
[[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc
2019-10-29 04:55:50 +01:00
echo "Initialisation ..."
2020-09-18 15:47:09 +02:00
TXBLOCKS=$(cat $SCRIPTPATH/db/txblocs) #kopa
2020-09-21 02:09:40 +02:00
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
#TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}'))
unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]'
2020-09-21 02:09:40 +02:00
membresPubkeys=$(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')
#membresPubkeys=$(cat db/membresPubkeys) #kopa
nbrMembers=$(echo "$membresPubkeys" | wc -l)
2019-10-29 04:55:50 +01:00
lastBloc=${TXBLOCKS[-1]}
udBlocs=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]')
2019-11-15 23:33:11 +01:00
isWeb=$1
jsonFile="$SCRIPTPATH/db/daily.json"
2019-10-29 04:55:50 +01:00
### On source les fonctions
source $SCRIPTPATH/lib/functions.sh
source $SCRIPTPATH/lib/scanTxWallets.sh
2020-09-15 16:50:15 +02:00
### Extraction des adresses Ḡ1 actives
scanTxWallets $1 #kopa
2020-06-24 21:18:23 +02:00
### Calcul la somme des soldes portefeuilles et membres
sumSoldes
2020-09-15 04:05:07 +02:00
### Ajout des membres sans transaction
addMembers
2020-06-24 21:18:23 +02:00
### Calcul du nombre de wallets
nbrWallets
2019-11-19 16:03:22 +01:00
### Affichage des stats
displayStats
2019-10-29 04:55:50 +01:00
### Renseignement de l'index web et indexation de l'historique
# source $SCRIPTPATH/lib/functions.sh # On source les fonctions de nouveau
2020-09-18 15:47:09 +02:00
[[ $isWeb == "web" ]] && web
### Fin de programme
2019-11-15 23:33:11 +01:00
day=$(date +'%d-%m-%y')
2020-09-15 16:50:15 +02:00
echo -e " ---"
2019-11-15 23:33:11 +01:00
echo "$day - Heure de fin: $(date +'%H:%M')"