Basic bash script to keep full node synced

That script was really useful for me before 1.1.6 update. Full node connections are far better with 1.1.6 but if someone still having connections issues, can use my below script.

It is very basic script and still open to improvements. Basically check every x second that we have enough full node connections. if we have not, it automatically tries to connect chia offical nodes to improve connection state.

please save it with any name with script file. like xxx.sh

then

chmod 777 xxx.sh
./xxx.sh

Thanks.

#!/bin/bash

cd /home/erdinc/chia-blockchain #change to your chia-blockchain folder
. ./activate

min_connected_node_count=2
loop_time_in_seconds=60

while true;
do
        chia_not_synced=$(chia show -s | grep "Not Synced" | wc -l)
        chia_connected_node_count=$(chia show -c | grep "FULL_NODE" | wc -l)

        echo -e "Chia Not Connected -> " $chia_not_synced
        echo -e "Connected Node Count -> " $chia_connected_node_count
        loop_time_in_seconds=60

        # actual full node connections are lower than min_connected_node_count. we are adding official chia nodes again.
        if [ $chia_not_synced -eq 1 ] || [ $chia_connected_node_count -lt $min_connected_node_count ];
        then
                echo -e "Connection issue. Connect to nodes."
                chia show -a node-or.chia.net:8444
                chia show -a node-eu.chia.net:8444
                chia show -a node-apne.chia.net:8444
                chia show -a node.chia.net:8444
                loop_time_in_seconds=3
        fi

        sleep $loop_time_in_seconds
done
3 Likes

Cool, thanks for the scrypt. What does . ./activate on line 4 do? I don’t have such file in my chia-blockchain folder…