From ba3324876496b46628268e4deccfef0283010e36 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 28 May 2014 10:08:51 -0400 Subject: [PATCH] defect 4091 RHEL7 support --- xCAT-server/share/xcat/tools/detect_dhcpd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/tools/detect_dhcpd b/xCAT-server/share/xcat/tools/detect_dhcpd index e7361fdda..78d33e19f 100755 --- a/xCAT-server/share/xcat/tools/detect_dhcpd +++ b/xCAT-server/share/xcat/tools/detect_dhcpd @@ -39,12 +39,19 @@ my $start = Time::HiRes::gettimeofday(); $start =~ s/(\d.*)\.(\d.*)/$1/; if (!$nic) { print "specify a nic\n"; print $::USAGE; exit 1;} -my $IP = `ifconfig $nic | grep "inet addr" | awk '{print \$2}' | awk -F: '{print \$2}'`; +#my $IP = `ifconfig $nic | grep "inet addr" | awk '{print \$2}' | awk -F: '{print \$2}'`; +my $IPADDRMASK = `ip addr show dev $nic | grep inet | grep -v inet6 | awk '{print \$2}' | head -n 1`; +my ($IP,$MASK)= split (/\//,$IPADDRMASK); my $MAC; +my $tmpMAC; +my @ipoutput; if ($::MACADD) { $MAC = $::MACADD; } else { - $MAC = `ifconfig $nic | grep "HWaddr" | /usr/bin/awk '{print \$5}'`; +# $MAC = `ifconfig $nic | grep "HWaddr" | /usr/bin/awk '{print \$5}'`; + $tmpMAC = `ip link show $nic | grep ether`; + @ipoutput= split (' ',$tmpMAC); + $MAC=$ipoutput[1]; } chomp($IP); @@ -313,4 +320,3 @@ sub kill_child { #print "try to kill $cpid\n"; } } -