1
0
Fork 0
mirror of synced 2025-04-05 14:13:37 +03:00

Merge pull request #1 from abuango/abuango-patch-1

Limit Number of default routes returned to 1
This commit is contained in:
Abubakar Ango 2019-03-08 14:17:02 +01:00 committed by GitHub
commit 3cd1911bf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,7 +69,7 @@ if [ "$(id -u)" != 0 ]; then
exiterr "Script must be run as root. Try 'sudo sh $0'"
fi
def_iface=$(route 2>/dev/null | grep '^default' | grep -o '[^ ]*$')
def_iface=$(route 2>/dev/null | grep -m 1 '^default' | grep -o '[^ ]*$')
[ -z "$def_iface" ] && def_iface=$(ip -4 route list 0/0 2>/dev/null | grep -Po '(?<=dev )(\S+)')
def_state=$(cat "/sys/class/net/$def_iface/operstate" 2>/dev/null)
if [ -n "$def_state" ] && [ "$def_state" != "down" ]; then