From f1472b029da953aea8c2f400475e18182668b1e4 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 30 May 2014 03:12:08 -0700 Subject: [PATCH] fix defect #4146 post.rh.common scipt has ifconfig that does work even on Redhat6 --- .../share/xcat/install/scripts/post.rh.common | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.rh.common b/xCAT-server/share/xcat/install/scripts/post.rh.common index 79bc733a7..9ad02fd7a 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rh.common +++ b/xCAT-server/share/xcat/install/scripts/post.rh.common @@ -13,7 +13,8 @@ if [ -z "$PRINIC" ] then for karg in $(cat /proc/cmdline |sed -e 's/-/:/g' -e 's/ /\n/g'); do if [ "${karg%%=*}" = "BOOTIF" ]; then - export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'` + #export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'` + export PRINIC=`ip -o link|grep -i "${karg#*=}"|awk '{print $2}'|sed s/://` fi done if [ -z "$PRINIC" ]; then @@ -24,13 +25,16 @@ if [ -z "$PRINIC" ] then export PRINIC=eth0 elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then - export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` + #export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` + export PRINIC=`ip -o link|grep -i "$PRINIC"|awk '{print $2}'|sed s/://` fi -IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') +#IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') +IP=$(ip addr show dev $PRINIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1 | awk -F '/' '{print $1}') if [ -z $IP ] then dhclient eth0 - IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') + #IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') + IP=$(ip addr show dev $PRINIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1 | awk -F '/' '{print $1}') fi export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}')