Add functions for read current default route and DNS settings
This commit is contained in:
parent
b813aeeaff
commit
2f4b81a644
@ -404,6 +404,22 @@ write_iface_default_gw()
|
||||
printf 'default via %s\n' "$2" >>"$1/ipv${p}route"
|
||||
}
|
||||
|
||||
# read_iface_current_default_gw <iface_path> [ ip_version ]
|
||||
read_iface_current_default_gw()
|
||||
{
|
||||
local name="${1##*/}"
|
||||
local p="${2:-4}" r= d=
|
||||
|
||||
eval "r=\$__default_ipv${p}_gw_re"
|
||||
|
||||
/sbin/ip -$p route show to default dev "$name" 2>/dev/null | \
|
||||
sed -n -e "s/$r/\1/p" \
|
||||
-e 't l1' \
|
||||
-e 'b' \
|
||||
-e ': l1' \
|
||||
-e 'q'
|
||||
}
|
||||
|
||||
read_iface_search()
|
||||
{
|
||||
local retval
|
||||
@ -422,6 +438,11 @@ write_iface_search()
|
||||
[ -s "$resolvconf_file" ] || rm -f -- "$resolvconf_file"
|
||||
}
|
||||
|
||||
read_current_search()
|
||||
{
|
||||
read_iface_search /etc
|
||||
}
|
||||
|
||||
read_iface_dns()
|
||||
{
|
||||
local retval
|
||||
@ -444,6 +465,11 @@ write_iface_dns()
|
||||
[ -s "$resolvconf_file" ] || rm -f -- "$resolvconf_file"
|
||||
}
|
||||
|
||||
read_current_dns()
|
||||
{
|
||||
read_iface_dns /etc
|
||||
}
|
||||
|
||||
# NOTE: For bond/bridge interfaces HOST variable means
|
||||
# "_This_ interface is a host for interfaces in the list".
|
||||
# But for VLAN interfaces HOST variable has opposite meaning:
|
||||
|
Loading…
Reference in New Issue
Block a user