mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	fix defect #4146 post.rh.common scipt has ifconfig that does work even on Redhat6
This commit is contained in:
		| @@ -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}') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user