From d05a87b08014d3765a3dea0ac50fa91ec7659f94 Mon Sep 17 00:00:00 2001 From: ligc Date: Tue, 11 Aug 2009 05:56:50 +0000 Subject: [PATCH] update hardeths to work for both RedHat and SuSE git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3983 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/share/xcat/postscripts/hardeths | 27 +++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/postscripts/hardeths b/xCAT-server/share/xcat/postscripts/hardeths index 7c5bbae2f..21a50c382 100644 --- a/xCAT-server/share/xcat/postscripts/hardeths +++ b/xCAT-server/share/xcat/postscripts/hardeths @@ -1,9 +1,26 @@ +if [ -f /etc/SuSE-release ] +then + #SLES9 and SLES10, uses /etc/sysconfig/network/ifcfg-eth-id- + #SLES11, uses /etc/sysconfig/network/ifcfg-eth + NICFILEPRE="/etc/sysconfig/network/ifcfg-" + echo `hostname` > /etc/HOSTNAME +else + #RedHat uses /etc/sysconfig/network-scripts/ifcfg-eth + NICFILEPRE="/etc/sysconfig/network-scripts/ifcfg-" + sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network +fi for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep -v -- --|grep -v lo`; do IPADDR=`ifconfig $nic |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}'` NETMASK=`ifconfig $nic |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'` - sed -i s/BOOTPROTO=dhcp/BOOTPROTO=none/ /etc/sysconfig/network-scripts/ifcfg-$nic - echo IPADDR=$IPADDR >> /etc/sysconfig/network-scripts/ifcfg-$nic - echo NETMASK=$NETMASK >> /etc/sysconfig/network-scripts/ifcfg-$nic + if [ -f ${NICFILEPRE}${nic} ] + then + NICFILE=${NICFILEPRE}${nic} + else + mac=`ifconfig $nic|grep HWaddr|awk '{print $5}'|tr "[A-Z]" "[a-z]"` + NICFILE=${NICFILEPRE}eth-id-${mac} + fi + sed -i s/BOOTPROTO=dhcp/BOOTPROTO=static/ $NICFILE + sed -i s/BOOTPROTO=\'dhcp\'/BOOTPROTO=static/ $NICFILE + echo IPADDR=$IPADDR >> $NICFILE + echo NETMASK=$NETMASK >> $NICFILE done -sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network -