2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-31 01:56:39 +00:00
This commit is contained in:
bybai 2019-01-23 05:40:18 -05:00
parent 78e32fadd6
commit db9bee6b1a

View File

@ -133,11 +133,10 @@ function configipv4(){
fi
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_if_name}"
if [ $networkmanager_active -eq 1 ]; then
nmcli con show | grep ${str_if_name}
if [ $? -ne 0 ] ; then
con_name=$(nmcli dev show ${str_if_name}|grep CONNECTION|awk -F: '{print $2}'|sed 's/^[ \t]*$//g')
if [ "$con_name" == "--" ] ; then
nmcli con add type ethernet con-name ${str_if_name} ifname ${str_if_name} ipv4.method manual ipv4.addresses ${str_v4ip}/${str_prefix}
else
con_name=$(nmcli dev show ${str_if_name}|grep CONNECTION|awk -F: '{print $2}'|sed 's/^ *//')
nmcli con mod "${con_name}" ipv4.method manual ipv4.addresses ${str_v4ip}/${str_prefix}
fi
else
@ -536,7 +535,6 @@ elif [ "$1" = "-s" ];then
log_info "configeth on $NODE: config install nic, can not find information from dhcp lease file, return."
exit 1
fi
str_inst_net=$(v4calcnet $str_inst_ip $str_inst_mask)
num_index=1
while [ $num_index -le $NETWORKS_LINES ];do
@ -626,18 +624,17 @@ elif [ "$1" = "-s" ];then
str_inst_prefix=$(v4mask2prefix ${str_inst_mask})
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_inst_nic}"
if [ $networkmanager_active -eq 1 ]; then
nmcli con show | grep ${str_inst_nic}
if [ $? -ne 0 ] ; then
con_name=$(nmcli dev show ${str_if_name}|grep CONNECTION|awk -F: '{print $2}'|sed 's/^[ \t]*$//g')
if [ "$con_name" == "--" ] ; then
nmcli con add type ethernet con-name ${str_inst_nic} ifname ${str_inst_nic} ipv4.method manual ipv4.addresses ${str_inst_ip}/${str_inst_prefix}
else
con_name=$(nmcli dev show ${str_inst_nic}|grep CONNECTION|awk -F: '{print $2}'|sed 's/^ *//')
nmcli con mod "System ens3" ipv4.method manual ipv4.addresses ${str_inst_ip}/${str_inst_prefix}
fi
else
echo "DEVICE=${str_inst_nic}" > $str_conf_file
echo "IPADDR=${str_inst_ip}" >> $str_conf_file
echo "NETMASK=${str_inst_mask}" >> $str_conf_file
echo "BOOTPROTO=static" >> $str_conf_file
echo "BOOTPROTO=none" >> $str_conf_file
echo "ONBOOT=yes" >> $str_conf_file
echo "HWADDR=${str_inst_mac}" >> $str_conf_file
fi