Create .env file for environment variables
This commit is contained in:
parent
50c41e54b3
commit
9cef929552
|
@ -0,0 +1,5 @@
|
||||||
|
DUNITER="http://192.168.9.54:45000" # Adresse du noeud Duniter qui sera scanné
|
||||||
|
DUNITER2="https://g1.duniter.org" # Seconde adresse par sécurité
|
||||||
|
DUNITER3="https://duniter.g1.1000i100.fr" # Troisième adresse par sécurité
|
||||||
|
ESNODE="http://g1.data.duniter.fr" # Adresse du noeud ElasticSearch qui sera scanné
|
||||||
|
WEBPATH="/var/www/g1-stats" # Dossier qui sera créé si vous choisissez l'option web pour la mise en ligne des données (nécessite une configuration apache ou nginx)
|
|
@ -0,0 +1 @@
|
||||||
|
.env
|
|
@ -4,10 +4,13 @@
|
||||||
*Ce code n'a pas été testé dans un autre environement que le miens, il est publié par simple soucis de transparence et d'audit*
|
*Ce code n'a pas été testé dans un autre environement que le miens, il est publié par simple soucis de transparence et d'audit*
|
||||||
|
|
||||||
Utilise l'API BMA pour l'extraction des clés publiques ḡ1 membres et non membres, ainsi que l'API ElasticSearch de Cesium+ pour la récupération des soldes par soucis d'optimisation.
|
Utilise l'API BMA pour l'extraction des clés publiques ḡ1 membres et non membres, ainsi que l'API ElasticSearch de Cesium+ pour la récupération des soldes par soucis d'optimisation.
|
||||||
Les variables d'environnements se trouvent simplement en début de script. Il est nécessaire de les modifier avant l'execution.
|
|
||||||
|
|
||||||
A exécuter dans un environnement Bash Debian/Ubuntu.
|
A exécuter dans un environnement Bash Debian/Ubuntu.
|
||||||
|
|
||||||
|
## Prérequis
|
||||||
|
|
||||||
|
Copiez le fichier .env.example en .env et adaptez les variables selon votre usage.
|
||||||
|
|
||||||
## Exécution
|
## Exécution
|
||||||
|
|
||||||
`./g1-stats.sh`
|
`./g1-stats.sh`
|
||||||
|
|
39
g1-stats.sh
39
g1-stats.sh
|
@ -1,19 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
### Variable ###
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
DUNITER="http://192.168.9.54:45000"
|
if [[ -e $SCRIPTPATH/.env ]]; then source $SCRIPTPATH/.env; else echo "Veuillez créer votre fichier .env inspiré de .env.example" && exit 1; fi
|
||||||
DUNITER2="https://g1.duniter.org"
|
|
||||||
DUNITER3="https://duniter.g1.1000i100.fr"
|
|
||||||
ESNODE="http://g1.data.duniter.fr"
|
|
||||||
webLocation="/var/www/g1-stats"
|
|
||||||
scriptLocation="/opt/g1-stats"
|
|
||||||
###
|
|
||||||
|
|
||||||
### Initialisation des données ###
|
### Initialisation des données ###
|
||||||
startTime=$(date +'%H:%M')
|
startTime=$(date +'%H:%M')
|
||||||
day=$(date +'%d-%m-%y')
|
day=$(date +'%d-%m-%y')
|
||||||
id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||||
indexhtml="$webLocation/index.html"
|
indexhtml="$WEBPATH/index.html"
|
||||||
echo -e "\n############# $day à $startTime #############\n"
|
echo -e "\n############# $day à $startTime #############\n"
|
||||||
[[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc
|
[[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc
|
||||||
echo "Initialisation ..."
|
echo "Initialisation ..."
|
||||||
|
@ -28,6 +22,7 @@ nbrMembers=${#MEMBERS[@]}
|
||||||
lastBloc=${TXBLOCKS[-1]}
|
lastBloc=${TXBLOCKS[-1]}
|
||||||
isWeb=$1
|
isWeb=$1
|
||||||
|
|
||||||
|
exit
|
||||||
### Extraction des adresses Ḡ1 actives ###
|
### Extraction des adresses Ḡ1 actives ###
|
||||||
|
|
||||||
loopWalletUp() {
|
loopWalletUp() {
|
||||||
|
@ -100,18 +95,18 @@ pourcentWallets=$(echo "scale=1; $nbrSimpleWallets*100/$nbrTotalWallets/1" | bc)
|
||||||
### Renseignement de l'index web et indexation de l'historique ###
|
### Renseignement de l'index web et indexation de l'historique ###
|
||||||
web() {
|
web() {
|
||||||
|
|
||||||
[ ! -d $webLocation/history/ ] && mkdir -p $webLocation/history/
|
[ ! -d $WEBPATH/history/ ] && mkdir -p $WEBPATH/history/
|
||||||
[ ! -d $webLocation/css ] && cp -r $scriptLocation/css $webLocation/
|
[ ! -d $WEBPATH/css ] && cp -r $SCRIPTPATH/css $WEBPATH/
|
||||||
cp $scriptLocation/index-stats.html $indexhtml
|
cp $SCRIPTPATH/index-stats.html $indexhtml
|
||||||
|
|
||||||
datePrevious=$(echo $day | awk -F '-' '{ print $3 "-" $2 "-" $1 }')
|
datePrevious=$(echo $day | awk -F '-' '{ print $3 "-" $2 "-" $1 }')
|
||||||
datePrevious=$(date +'%y-%m-%d' -d "$datePrevious -1 day")
|
datePrevious=$(date +'%y-%m-%d' -d "$datePrevious -1 day")
|
||||||
datePrevious=$(echo $datePrevious | awk -F '-' '{ print $3 "-" $2 "-" $1 }')
|
datePrevious=$(echo $datePrevious | awk -F '-' '{ print $3 "-" $2 "-" $1 }')
|
||||||
[[ -z $(ls -l $webLocation/history/ | grep $datePrevious) && -z $(grep '"display:none;" class="previous"' $indexhtml) ]] && sed -i "s/class=\"previous\"/style=\"display:none;\" class=\"previous\"/g" $indexhtml
|
[[ -z $(ls -l $WEBPATH/history/ | grep $datePrevious) && -z $(grep '"display:none;" class="previous"' $indexhtml) ]] && sed -i "s/class=\"previous\"/style=\"display:none;\" class=\"previous\"/g" $indexhtml
|
||||||
dateNext=$(echo $day | awk -F '-' '{ print $3 "-" $2 "-" $1 }')
|
dateNext=$(echo $day | awk -F '-' '{ print $3 "-" $2 "-" $1 }')
|
||||||
dateNext=$(date +'%y-%m-%d' -d "$dateNext +1 day")
|
dateNext=$(date +'%y-%m-%d' -d "$dateNext +1 day")
|
||||||
dateNext=$(echo $dateNext | awk -F '-' '{ print $3 "-" $2 "-" $1 }')
|
dateNext=$(echo $dateNext | awk -F '-' '{ print $3 "-" $2 "-" $1 }')
|
||||||
[[ -z $(ls -l $webLocation/history/ | grep $dateNext) && -z $(grep '"display:none;" class="next"' $indexhtml) ]] && sed -i "s/class=\"next\"/style=\"display:none;\" class=\"next\"/g" $indexhtml
|
[[ -z $(ls -l $WEBPATH/history/ | grep $dateNext) && -z $(grep '"display:none;" class="next"' $indexhtml) ]] && sed -i "s/class=\"next\"/style=\"display:none;\" class=\"next\"/g" $indexhtml
|
||||||
|
|
||||||
sed -i "s/_nbrTotalWallets/$nbrTotalWallets/g" $indexhtml
|
sed -i "s/_nbrTotalWallets/$nbrTotalWallets/g" $indexhtml
|
||||||
sed -i "s/_nbrSimpleWallets/$nbrSimpleWallets/g" $indexhtml
|
sed -i "s/_nbrSimpleWallets/$nbrSimpleWallets/g" $indexhtml
|
||||||
|
@ -133,17 +128,17 @@ web() {
|
||||||
[[ -z $(grep '"display:none;" class="previous"' $indexhtml) ]] && sed -i "s/_datePrevious/$datePrevious/g" $indexhtml
|
[[ -z $(grep '"display:none;" class="previous"' $indexhtml) ]] && sed -i "s/_datePrevious/$datePrevious/g" $indexhtml
|
||||||
[[ -z $(grep '"display:none;" class="next"' $indexhtml) ]] && sed -i "s/_dateNext/$dateNext/g" $indexhtml
|
[[ -z $(grep '"display:none;" class="next"' $indexhtml) ]] && sed -i "s/_dateNext/$dateNext/g" $indexhtml
|
||||||
|
|
||||||
cat "$outFile" | grep . > $webLocation/wallets-g1.txt
|
cat "$outFile" | grep . > $WEBPATH/wallets-g1.txt
|
||||||
echo -e "${MEMBERS[@]}" | sed 's/ /\n/g' > $webLocation/wallets-g1-membres.txt
|
echo -e "${MEMBERS[@]}" | sed 's/ /\n/g' > $WEBPATH/wallets-g1-membres.txt
|
||||||
echo -e "$simpleWallets" > $webLocation/wallets-g1-simple.txt
|
echo -e "$simpleWallets" > $WEBPATH/wallets-g1-simple.txt
|
||||||
|
|
||||||
if [[ "$startTime" == "00:00" ]]; then
|
if [[ "$startTime" == "00:00" ]]; then
|
||||||
cp $indexhtml $webLocation/history/index_$day.html
|
cp $indexhtml $WEBPATH/history/index_$day.html
|
||||||
sed -i "s/css\/style.css/..\/css\/style.css/g" $webLocation/history/index_$day.html
|
sed -i "s/css\/style.css/..\/css\/style.css/g" $WEBPATH/history/index_$day.html
|
||||||
sed -i "s/_dateNext/$day/g" $webLocation/history/index_$datePrevious.html
|
sed -i "s/_dateNext/$day/g" $WEBPATH/history/index_$datePrevious.html
|
||||||
sed -i "s/style=\"display:none;\" class=\"next\"/class=\"next\"/g" $webLocation/history/index_$datePrevious.html
|
sed -i "s/style=\"display:none;\" class=\"next\"/class=\"next\"/g" $WEBPATH/history/index_$datePrevious.html
|
||||||
fi
|
fi
|
||||||
chown -R www-data:www-data $webLocation
|
chown -R www-data:www-data $WEBPATH
|
||||||
}
|
}
|
||||||
|
|
||||||
### Affichage du nombre de wallets ###
|
### Affichage du nombre de wallets ###
|
||||||
|
|
Loading…
Reference in New Issue