i guess the trick will be finding a reliable means of testing whether the connection is really down (as opposed to not doing anything).
if you could to that you could use a while look (while
to keep cheching it.
then when it's failed run the fail over script. obviously your script will need to monitor when it comes back up then run a fail back script.
you would need to write a new init script and call it an an appropriate run level.
it sounds complex but i think doable - IMHO reliably determining whether a connection is really down is harder that you might imagine....