Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/vbash
- ########################################################################
- # Script to switch between gateways depending on connection #
- # Relies on static routes and pings to hosts #
- # #
- # @Author Andrew Shaw #
- # @Date 2015-10-16 #
- ########################################################################
- #It's for Vyatta
- #Get the Vyatta functions for configuration
- source /opt/vyatta/etc/functions/script-template
- #Function to check the gateway
- function checkGateway {
- /usr/lib/nagios/plugins/check_ping -w 1000,50% -c 1000,50% -H $1
- }
- #Function to set the gateway
- function setGateway {
- configure
- set system gateway-address $1
- commit
- # exit
- }
- #Failover Logic
- while true
- do
- if checkGateway 185.60.88.85
- then echo "Manannan 5GHz Bow has Internet"
- setGateway 10.22.0.158
- elif checkGateway 185.60.88.86
- then echo "Manannan 5GHz Stern has Internet"
- setGateway 10.22.0.162
- elif checkGateway 185.60.88.87
- then echo "Manannan 4G Bow has Internet"
- setGateway 10.23.0.2
- elif checkGateway 185.60.88.88
- then echo "Manannan 4G Stern has Internet"
- setGateway 10.23.0.6
- elif checkGateway 185.60.88.89
- then echo "Manannan Satellite has Internet"
- setGateway 10.24.0.2
- fi
- sleep 1
- done
Add Comment
Please, Sign In to add comment