How to write script for VPN gateway switch?

I have a VPN subscription at Private Internet Access. I mainly use the Switzerland gateway. Now I use it with their client. Many times the Switzerland gateway is down so I have to find another gateway. I want to setup my DD-WRT router (WRT54GL) with the VPN and I want it to automatically switch between the best possible gateways or at least the ones which are working. So basically a script for this or any other solution is also most welcome.

I was discussing this issue at another forum with somebody. He advised me to ask somebody who has UNIX experience. Since I have no UNIX experience, I do not know how to do that. I quote some of what he advised me.
"In any case the basic configuration is the same as if you would say have 2 remote offices. You build a VPN connection to both from your central location. Unlike a office situation where you would route certain networks to each tunnel in your case you need to route the default route. Since the router likes to always has a BEST route even though there are 2 default routes in the routing table it will choose one or the other based on some metric value you set. If the primary link would go down this default route will get removed and it will use only other one that is left. When the primary comes back it will get the better default route back and it will switch back. The only problem with this design is when the VPN stays active but just does not pass any traffic or is getting 90% packet loss. You would have to write a script that could detect something that advanced and cause it to change the metrics on the other default route to make it be selected."
So here it is.

Previously I was seeking advice on how to connect 3 routers wirelessly. Now I am over that, I will connect them with a wire. But I want my DD-WRT router to do the DHCP server. He adviced me this:
"If you want all your traffic to flow only via vpn then what you do is lie to your end devices. Say your main gateway is 192.168.1.1 and your vpn router is 192.168.1.2 You would set the DHCP server (can be any router) to tell the client devices to send all the traffic to 192.168.1.2. The 192.168.1.2 router would know to send all the traffic into the VPN tunnel to the remote site but it also would know that the gateway to the internet was really 192.168.1.1. It would send the tunnel traffic itself to 192.168.1.1 but it would send any other non tunnel internet traffic though the tunnel."

So can somebody help me with my case? Much appreciated.