RB OS script for shifting internet in the same network

I have tow internet connections from two different ISPs, and i have a local wireless network and i put a RB 433 AH, so i want to configure my RB for the Internet like that:



if the first ISP internet connection is up (working) so my router gives internet to the access points . but if the first connection got down (stop from working) my router change or shift the connection automatically from the first ISP internet tow the second . ..



please help me to find the solution. for that.



i heard there is a script for this but i don’t know how it works.

at first, you should define ‘stopped working’ term. is gateway working on that moment, or your ppp client to the provider disconected?..

YES , gateway is working at that time.