Created
September 7, 2019 01:36
-
-
Save pdcastro/993c53b0edd0bd68343333d12bac3719 to your computer and use it in GitHub Desktop.
fix_route function for the provisioning container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment