2010-02-24 08:27:58 +00:00
|
|
|
defgw=`ip route | grep default | awk '{print $3}'`
|
2009-09-28 02:59:07 +00:00
|
|
|
if [ -f /etc/SuSE-release ]
|
|
|
|
then
|
|
|
|
#SLES9 and SLES10, uses /etc/sysconfig/network/ifcfg-eth-id-<mac>
|
|
|
|
#SLES11, uses /etc/sysconfig/network/ifcfg-eth<x>
|
|
|
|
NICFILEPRE="/etc/sysconfig/network/ifcfg-"
|
|
|
|
echo `hostname` > /etc/HOSTNAME
|
2010-02-24 08:27:58 +00:00
|
|
|
if [ ! -z "$defgw" ]; then
|
|
|
|
echo "default $defgw - -" > /etc/sysconfig/routes
|
|
|
|
fi
|
2009-09-28 02:59:07 +00:00
|
|
|
else
|
|
|
|
#RedHat uses /etc/sysconfig/network-scripts/ifcfg-eth<x>
|
|
|
|
NICFILEPRE="/etc/sysconfig/network-scripts/ifcfg-"
|
|
|
|
sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network
|
2010-02-24 08:27:58 +00:00
|
|
|
if [ ! -z "$defgw" ]; then
|
|
|
|
echo "GATEWAY=$defgw" >> /etc/sysconfig/network
|
|
|
|
fi
|
2009-09-28 02:59:07 +00:00
|
|
|
fi
|
2008-03-07 21:24:09 +00:00
|
|
|
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}'`
|
2009-09-28 02:59:07 +00:00
|
|
|
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
|
2010-12-27 07:49:33 +00:00
|
|
|
sed -i s/BOOTPROTO=\"dhcp\"/BOOTPROTO=static/ $NICFILE
|
2009-09-28 02:59:07 +00:00
|
|
|
echo IPADDR=$IPADDR >> $NICFILE
|
|
|
|
echo NETMASK=$NETMASK >> $NICFILE
|
2008-03-07 21:24:09 +00:00
|
|
|
done
|