Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ...
  4.  
  5. fix_route () {
  6. good_wifi=$(ip route | perl -ne '/default\s+via\s+(\S+).+?metric\s+600/; if ($1) {print $1; exit}')
  7. good_eth0=$(ip route | perl -ne '/default\s+via\s+(\S+).+?metric\s+100/; if ($1) {print $1; exit}')
  8. bad_eth0=$(ip route | perl -ne '/default\s+via\s+(\S+).+?metric\s+20100/; if ($1) {print $1; exit}')
  9. # if there are no good routes with metrics 100 or 600, and there is a "bad"
  10. # route with metric 20100, assume the bad route is actually good and use it
  11. if [ -z "$good_wifi" -a -z "$good_eth0" -a -n "$bad_eth0" ]; then
  12. echo ip route add 0.0.0.0/0 via "$bad_eth0" metric 100
  13. fi
  14. }
  15.  
  16. while true; do
  17. fix_route
  18. provisioning
  19. echo "*** provisioning exited; waiting 5s before trying again"
  20. sleep 5
  21. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement