I think what I am trying to do can be achieved using bash scripts, but I could definitely use some help here ! Ok, here's the scenario:
I have a two-node MySQL cluster with Master-Master replication in place. Now, the application in question (SOGo) runs on those two nodes. At any given point of time, both instances of the application are supposed to read-from/write-to a single replica, to avoid duplicate entries, obviously.
So if instance A is writing to its local database, then B is also writing on that database, remotely. And vice-versa.
If A goes down, then I have to replace a configuration directive in B's SOGo instance to make it use its local database now. A simple sed statement and service restart does this.
After that, when A gets back again, then either I can instruct A to write to B's copy, or ask B to stop writing on its local copy, and instead write to A's copy.
So, to automate this procedure, what would be my best bet ?