Hostname and IP address during kickstart
Ryan Golhar
golharam at umdnj.edu
Thu Jul 15 13:07:06 UTC 2004
Hi Peter,
Yes, that's almost exactly what I have. It looks like the machine name
is set to $HOSTNAME. I'm retrieving the IP address from
/etc/sysconfig/network. I came up with this. I need to add the the
full name to the list.
Source /etc/sysconfig/network
IPADDR=`hostname $HOSTNAME | cut -f 4 -d ' '`
echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts
echo "$IPADDR $HOSTNAME.umdnj.edu $HOSTNAME" >> /etc/hosts
-----
Ryan Golhar
Computational Biologist
The Informatics Institute at
The University of Medicine & Dentistry of NJ
Phone: 973-972-5034
Fax: 973-972-7412
Email: golharam at umdnj.edu
-----Original Message-----
From: Pete Nesbitt [mailto:pete at linux1.ca]
Sent: Wednesday, July 14, 2004 10:54 PM
To: golharam at umdnj.edu; General Red Hat Linux discussion list
Subject: Re: Hostname and IP address during kickstart
On July 14, 2004 09:30 am, Ryan Golhar wrote:
> I have a bunch of machines that I kickstart. They all use DHCP to
> obtain their hostname and IP address. The names are address are all
> static (in dhcpd.conf).
>
> Currently, in /etc/hosts on these machines, their hostname is set to
> 127.0.0.1 and this interferes with PVM. I need to set their host name
> to their correct IP address in /etc/hosts. What is the easiest way of
> doing this during %post in kickstart?
>
> Ryan
Hi Ryan,
Here is a little shell script that will overwrite the existing
/etc/hosts file
with the new IP/hostname (as well as 127...). I have tested it in a
dummy
file. It needs to be run as root.
If you have static entries, you need to add them into the script or you
will
lose them.
#!/bin/bash
# this ONLY WORKS IF there are no other entries in hosts!!
# it will overwrite anything in the hosts file!
HOSTS="/etc/hosts"
TEMP_HOSTS="/tmp/hosts.tmp"
NIC="eth0"
IP="`ifconfig $NIC | grep inet | cut -d : -f 2 | cut -d \ -f 1`"
FULL_NAME="`uname -n`" SHORT_NAME="`uname -n|cut -d. -f1`"
echo "127.0.0.1 localhost.localdomain localhost" > $TEMP_HOSTS
echo "$IP $FULL_NAME $SHORT_NAME" >> $TEMP_HOSTS
# add more static entries if needed like this:
#echo "xxx.xxx.xxx.xxx somehost.domain.com somehost" >> $TEMP_HOSTS
cat $TEMP_HOSTS > $HOSTS
#end
Hope that helps
--
Pete Nesbitt, rhce
More information about the redhat-list
mailing list