From db9bee6b1a9a98522a34ba9a6f21716d5e394894 Mon Sep 17 00:00:00 2001 From: bybai Date: Wed, 23 Jan 2019 05:40:18 -0500 Subject: [PATCH] polished --- xCAT/postscripts/configeth | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index e15a3ff8f..151d9766f 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -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