2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-21 19:22:05 +00:00

adding parsing NM resolv.conf for dns entries (if there is no lease file)

This commit is contained in:
sgr 2024-05-07 15:11:43 +02:00 committed by Markus Hilger
parent 549e6ba5ca
commit 0f95df177f

View File

@ -580,6 +580,7 @@ elif [ "$1" = "-s" ];then
str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`
str_inst_gateway=`grep routers $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`
str_inst_dns=`grep domain-name-servers $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`
str_inst_dns_search=`grep domain-search $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`
else
if [ -n "$MACADDRESS" ];then
str_inst_mac=$MACADDRESS
@ -594,6 +595,11 @@ elif [ "$1" = "-s" ];then
fi
fi
str_inst_gateway=`ip ro ls|grep default|awk '{print $3}'|head -1`
str_resolv_file=/var/run/NetworkManager/resolv.conf
if [ -f $str_resolv_file ];then
str_inst_dns=`grep ^nameserver $str_resolv_file | sed 's/^nameserver //g'`
str_inst_dns_search=`grep ^search $str_resolv_file | sed 's/^search //g'`
fi
fi
fi
fi
@ -755,6 +761,11 @@ elif [ "$1" = "-s" ];then
nmcli con modify $con_name ipv4.dns ${str_inst_dns}
fi
fi
if [ -n "${str_inst_dns_search}" ];then
if [ $networkmanager_active -eq 1 ]; then
nmcli con modify $con_name ipv4.dns-search "${str_inst_dns_search}"
fi
fi
if [ -n "${str_inst_mtu}" ];then
if [ $networkmanager_active -eq 1 ]; then
nmcli con modify $con_name mtu ${str_inst_mtu}