From ff2e58e66f039e961cefde2ec351fa6147709ef6 Mon Sep 17 00:00:00 2001 From: amy0701 Date: Thu, 12 Mar 2015 01:27:24 -0400 Subject: [PATCH] fix confignics -s does not work in postscripts --- xCAT/postscripts/configeth | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 7a571db44..590a78598 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash # IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html # Internal script used by confignics only. # It configs the Ethernet adpaters on the node @@ -502,6 +502,21 @@ elif [ "$1" = "-s" ];then str_inst_ip=`grep fixed-address $str_lease_file | tail -n 1 | awk '{print $2}' | sed 's/;$//'` str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` str_inst_gateway=`grep routers $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` + else + if [ -n "$MACADDRESS" ];then + str_inst_mac=$MACADDRESS + inst_nic=`ip -o link |grep -i ${str_inst_mac} |awk '{print $2}'|sed 's/://g'` + if [ ! -z "${inst_nic}" ];then + str_inst_ip=`ip -4 -o addr|grep -i ${inst_nic} |awk '{print $4}'|awk -F/ '{print $1}'` + if [ ! -z "str_inst_ip" ];then + inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` + if [ ! -z "inst_ip_pre" ];then + str_inst_mask=`route |grep ${inst_ip_pre}|awk '{print $3}'|head -1` + fi + fi + fi + str_inst_gateway=`ip ro ls|grep default|awk '{print $3}'|head -1` + fi fi elif [ -f "/etc/SuSE-release" ];then str_lease_file="/var/lib/dhcpcd/dhcpcd-"$str_inst_nic".info" @@ -516,6 +531,21 @@ elif [ "$1" = "-s" ];then str_inst_ip=`grep fixed-address $str_lease_file | tail -n 1 | awk '{print $2}' | sed 's/;$//'` str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` str_inst_gateway=`grep routers $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` + else + if [ -n "$MACADDRESS" ];then + str_inst_mac=$MACADDRESS + inst_nic=`ip -o link |grep -i ${str_inst_mac} |awk '{print $2}'|sed 's/://g'` + if [ ! -z "${inst_nic}" ];then + str_inst_ip=`ip -4 -o addr|grep -i ${inst_nic} |awk '{print $4}'|awk -F/ '{print $1}'` + if [ ! -z "str_inst_ip" ];then + inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` + if [ ! -z "inst_ip_pre" ];then + str_inst_mask=`route |grep ${inst_ip_pre}|awk '{print $3}'|head -1` + fi + fi + fi + str_inst_gateway=`ip ro ls|grep default|awk '{print $3}'|head -1` + fi fi fi if [ -n "$MACADDRESS" ];then