Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rost1989/fa1ed8a420829c285fb0ba8bfcd65aa1 to your computer and use it in GitHub Desktop.
Save rost1989/fa1ed8a420829c285fb0ba8bfcd65aa1 to your computer and use it in GitHub Desktop.
[OMNIFLIX] try to catch up with the blocks WITH delay
#!/bin/bash
DELAY=3600 #in secs - how often restart the script
RED_COLOR='\033[0;31m'
WITHOU_COLOR='\033[0m'
LATEST_BLOCK_HEIGHT=$(omniflixhubd query tendermint-validator-set | jq . | grep block_height | grep -o -E '[0-9]+')
YOUR_BLOCK_HEIGHT=$(omniflixhubd status 2>&1 | jq ."SyncInfo"."latest_block_height"| grep -o -E '[0-9]+')
DIFF_BLOCK_HEIGHT=$(expr $LATEST_BLOCK_HEIGHT - $YOUR_BLOCK_HEIGHT)
DIFF_BLOCK_LIMIT=0
for (( ;; )); do
echo -e "LATEST BLOCK HEIGHT: ${LATEST_BLOCK_HEIGHT} \n"
echo -e "YOUR BLOCK HEIGHT: ${YOUR_BLOCK_HEIGHT} \n"
echo -e "Diff are ${DIFF_BLOCK_HEIGHT}"
if [ $DIFF_BLOCK_HEIGHT -gt $DIFF_BLOCK_LIMIT ]; then
echo -e $(omniflixhubd unsafe-reset-all)
echo -e $(sudo systemctl restart omniflixhubd)
fi
for (( timer=${DELAY}; timer>0; timer-- ))
do
printf "* sleep for ${RED_COLOR}%02d${WITHOU_COLOR} sec\r" $timer
sleep 1
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment