Re: Hostname and IP address during kickstart

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On July 15, 2004 06:07 am, Ryan Golhar wrote:
> 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@xxxxxxxxx


Ryan,
If you want to use $HOSTNAME, look at 'man hostname' it has a -f and -s option 
for short or long (fqdn) option.

I don't see how "IPADDR=`hostname $HOSTNAME | cut -f 4 -d ' '`" works, that 
not going to give you an IP address.

Also, how are you getting an IP ftrom /etc/sysconfig/network,if it's dhcp, 
there should be no IP address in there (nor is it going to be in  
/etc/sysconfig/network-scripts/ifcfg-eth0)

Pete

>
> -----Original Message-----
> From: Pete Nesbitt [mailto:pete@xxxxxxxxx]
> Sent: Wednesday, July 14, 2004 10:54 PM
> To: golharam@xxxxxxxxx; 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

-- 
Pete Nesbitt, rhce


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux