#!/bin/bash if tail /var/log/mariadb/mariadb.log | grep -xq ".*\[ERROR\] WSREP\: wsrep\:\:connect.* failed: 7" then if grep -Fxq "safe_to_bootstrap: 1" /var/lib/mysql/grastate.dat then echo "Running bootstrap" systemctl reset-failed mariadb galera_new_cluster else echo "Not safe to bootstrap waiting to restart mariadb" sleep 120 systemctl reset-failed mariadb systemctl restart mariadb fi fi