From b44b8d90ab02ddfbf076823489dc580adfb3f73f Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 3 Sep 2023 23:40:13 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BA=91=E9=95=9C=E5=83=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=EF=BC=8C=E5=B0=86dns=E5=8D=95?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=E7=BB=84=E6=8D=A2=E6=88=90=E5=A4=9A=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E7=BB=84=EF=BC=8C=E5=90=A6=E5=88=99centos7/8=E4=BC=9A?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/trans.sh b/trans.sh index 2604bfc..f126be1 100644 --- a/trans.sh +++ b/trans.sh @@ -612,7 +612,7 @@ network: gateway4: $ipv4_gateway @ipv4_gateway gateway6: $ipv6_gateway @ipv6_gateway nameservers: - addresses: [@dns_addrs] + addresses: @dns_addrs EOF if is_dhcpv4 || [ -z "$ipv4_addr" ]; then @@ -637,20 +637,13 @@ EOF dns6_list=$(echo "$dns_list" | grep ':' || true) fi - unset dns_str - is_first=true + is_have_dns=false for cur in $dns4_list $dns6_list; do - if $is_first; then - is_first=false - else - dns_str="$dns_str, " - fi - dns_str="$dns_str$cur" + is_have_dns=true + echo " - $cur" >>$ci_file done - if [ -n "$dns_str" ]; then - sed -i "s/@dns_addrs/$dns_str/" $ci_file - else + if ! $is_have_dns; then sed -i '/nameservers:/d' $ci_file sed -i '/@dns_addrs/d' $ci_file fi