This comment has been minimized.

Great idea !
much better than those using pings and corn jobs !
Just that there are a few mistakes ...
This one goes to infinite loop .
as "ifup wan" takes wan down and then again up , if wan is already up, the wan connection redials every 15 seconds !
also, /sys/class/net/eth0/operstate needs to be set to appropriate interface , depending on each user
Have corrected the same , available here : https://gist.github.com/ninadpchaudhari/6561841ffc3667b1e5ee