add option to get IF_NAME from default route
This commit is contained in:
parent
da31662b92
commit
1022b72d08
|
|
@ -508,6 +508,14 @@ while getopts ":i:u:d:b:f:q:c:C:p:xV" OPT; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "${IF_NAME}" = "DEFAULT" ]]; then
|
||||||
|
IF_NAME="$(ip -j route | jq -r 'map(select(.dst=="default"))[0].dev' 2>&1)"
|
||||||
|
if [[ "$?" -ne 0 ]]; then
|
||||||
|
>&2 echo "ERROR: failed to determine the interface name for the default route"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z ${IF_NAME} ]]; then
|
if [[ -z ${IF_NAME} ]]; then
|
||||||
print_usage
|
print_usage
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue