Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ...
- fix_route () {
- good_wifi=$(ip route | perl -ne '/default\s+via\s+(\S+).+?metric\s+600/; if ($1) {print $1; exit}')
- good_eth0=$(ip route | perl -ne '/default\s+via\s+(\S+).+?metric\s+100/; if ($1) {print $1; exit}')
- bad_eth0=$(ip route | perl -ne '/default\s+via\s+(\S+).+?metric\s+20100/; if ($1) {print $1; exit}')
- # if there are no good routes with metrics 100 or 600, and there is a "bad"
- # route with metric 20100, assume the bad route is actually good and use it
- if [ -z "$good_wifi" -a -z "$good_eth0" -a -n "$bad_eth0" ]; then
- echo ip route add 0.0.0.0/0 via "$bad_eth0" metric 100
- fi
- }
- while true; do
- fix_route
- provisioning
- echo "*** provisioning exited; waiting 5s before trying again"
- sleep 5
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement