From f0694987e8ebb6d5f4e06e0672d547cf20a0eb90 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: May 14 2021 06:14:14 +0000 Subject: Set up dns cmdline by parsing "nmcli --get-values" Resolves: bz1919052 Upstream: Fedora Conflict: None commit 6f1badec789c86761f5777af80ba229ec13fc793 Author: Coiby Xu Date: Thu Apr 1 15:32:12 2021 +0800 Set up dns cmdline by parsing "nmcli --get-values" Signed-off-by: Coiby Xu Acked-by: Kairui Song Signed-off-by: Coiby Xu --- diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 02293f4..6c34760 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -97,15 +97,26 @@ source_ifcfg_file() { fi } -# $1: netdev name +# $1: nmcli connection show output kdump_setup_dns() { - local _nameserver _dns + local _netdev="$1" + local _nm_show_cmd="$2" + local _nameserver _dns _tmp array local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf - source_ifcfg_file $1 - - [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile" - [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" + _tmp=$(get_nmcli_value_by_field "$_nm_show_cmd" "IP4.DNS") + array=(${_tmp//|/ }) + if [[ ${array[@]} ]]; then + for _dns in "${array[@]}" + do + echo "nameserver=$_dns" >> "$_dnsfile" + done + else + dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script" + source_ifcfg_file "$_netdev" + [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile" + [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" + fi while read content; do @@ -546,7 +557,7 @@ kdump_install_net() { echo "$_ifname_opts" >> $_ip_conf fi - kdump_setup_dns "$_netdev" + kdump_setup_dns "$_netdev" "$_nm_show_cmd" if [ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]; then # network-manager module needs this parameter