From fcf36da45cde75ad34f9b9e534924402b39c8560 Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 9 Nov 2020 15:02:14 +0100 Subject: [PATCH 1/2] Remove reference to poka absolut path ... --- duniter-resync.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/duniter-resync.sh b/duniter-resync.sh index 35e8784..0d30a6c 100755 --- a/duniter-resync.sh +++ b/duniter-resync.sh @@ -1,18 +1,12 @@ #!/bin/bash -node=g1.presles.fr -#g1.cgeek.fr -#node=duniter.moul.re - -log="/var/log/duniter-resync.log" -oldlog="/home/poka/scripts/old-resync.log" +node=g1.presles.fr #g1.cgeek.fr #node=duniter.moul.re +log="$HOME/duniter-resync.log" echo "Début de la resynchronisation du noeud Duniter" /usr/bin/duniter stop -sleep 1 - -tail -n 1 $log >> $oldlog +sleep 0.5 [[ $1 == "erase" ]] && rm -rf ~/.config/duniter/duniter_default/data/ /usr/bin/duniter sync $node --nointeractive > $log 2>&1 & @@ -27,7 +21,7 @@ wait $BACK_PID kill -9 $LOG_PID -sleep 1 +sleep 0.5 /usr/bin/duniter webstart From e9c3d033f45da60f98381c185882a59c403162d7 Mon Sep 17 00:00:00 2001 From: poka Date: Tue, 10 Nov 2020 23:47:27 +0100 Subject: [PATCH 2/2] Adapt checkBlock for everyone --- duniter-checkBlock.sh | 95 ++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 50 deletions(-) diff --git a/duniter-checkBlock.sh b/duniter-checkBlock.sh index 95612c0..6879fcd 100755 --- a/duniter-checkBlock.sh +++ b/duniter-checkBlock.sh @@ -1,31 +1,57 @@ #!/bin/bash -refname="https://g1.cgeek.fr" +## MY VARS ### +myEmail="poka@p2p.legal" +### + +MY_PATH="`dirname \"$0\"`" +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" + +refname="g1.presles.fr" date=$(date '+%d-%m-%y à %H:%M') echo "############################" echo "$date" -rep="/home/poka/scripts" lock=0 -lockSync="/home/poka/scripts/lock-sync" +lockSync="$MY_PATH/lock-sync" [[ -n $lockSync ]] && touch $lockSync PID=$(ps auxf | grep "duniter" | grep -v -E "color=auto|grep|restart" | awk '{ print $2 }') PID=($(echo "$PID" | tr '\n' ' ')) +sendalerte() { +actionAlerte="$1" +date=$(date +"%Hh%M") + +mutt -e "set from='duniter-g1@p2p.legal'" -e "set content_type=text/html" -e "set charset=UTF-8" -s "Alerte noeud ğ1 resync à $date !" $myEmail < + + + +

Mon noeud ğ1 a été $actionAlerte

+
+ +Par précaution, ce scrip a été locké $lock fois. + + + +MAIL_END +} + if [[ -z $PID ]]; then - $rep/duniter-restart.sh - actionAlerte="redémarré" - sendalerte + $MY_PATH/duniter-restart.sh + sendalerte "redémarré" exit 0 fi -pokaNode=$(curl -s http://192.168.9.54:45000/blockchain/current | jq '.number') +myBMA=$(netstat -pnl 2>/dev/null | grep "duniter_defaul" | grep ":45000" | awk '{ print $4 }') +myNode=$(curl -s http://$myBMA/blockchain/current | jq '.number') refNode=$(curl -s $refname/blockchain/current | jq '.number') [[ -e $lockSync ]] && lock=$(cat $lockSync) -if [[ -z $pokaNode ]]; then +if [[ -z $myNode ]]; then if [[ $lock > 3 ]]; then rm $lockSync touch $lockSync @@ -37,54 +63,23 @@ if [[ -z $pokaNode ]]; then fi else [[ $(cat $lockSync) != 0 ]] && echo 0 > $lockSync - diffNode=$(($refNode - $pokaNode)) + diffNode=$(($refNode - $myNode)) fi checkg1() { + echo "Mon noeud est au block $myNode tandi que le noeud $refName est à $refNode" -echo "Mon noeud est au block $pokaNode tandi que le noeud $refName est à $refNode" - -if [[ $pokaNode < $refNode ]]; then - echo "Mon noeud est à la bourre, il a $diffNode blocks de retard ..." -else - echo "Tout est bon!" -fi - -} - -sendalerte() { - -TO="poka@p2p.legal" -date=$(date +"%Hh%M") - -mutt -e "set from='duniter-g1@p2p.legal'" -e "set content_type=text/html" -e "set charset=UTF-8" -s "Alerte noeud ğ1 resync à $date !" $TO < - - - -

Le noeud ğ1 de Poka a été $actionAlerte

-
- -Par précaution, ce scrip a été locké $lock fois. - - - -MAIL_END - -} - -checkg1 -#sendalerte - -if [[ $1 == "auto" ]]; then - if [ $diffNode -gt 5 ]; then - actionAlerte="resynchronisé" - sendalerte - bash $rep/duniter-resync.sh > /dev/null 2>&1 + if [[ $myNode < $refNode ]]; then + echo "Mon noeud est à la bourre, il a $diffNode blocks de retard ..." else - exit 0 + echo "Tout est bon!" fi +} +checkg1 + +if [ $diffNode -gt 5 ]; then + [[ $1 == "auto" ]] && sendalerte "resynchronisé" + bash $MY_PATH/duniter-resync.sh > /dev/null 2>&1 fi exit 0