failover script to run directly (bash) and some minor changes