hostname lookup ...

Jason Kohles email at jasonkohles.com
Wed Jan 30 16:10:39 UTC 2008


On Jan 30, 2008, at 9:28 AM, Gerrard Geldenhuis wrote:

> Hi
>
> I have written a script but it does not work as expected.
>
> The script is a post script with nochroot.
>
> I tested the dnsdomainname command in the console after my script  
> failed and saw that it returns localdomain.
>
> Hostname and uname returns localhost.localdomain.
>
> We want the time servers to be different depending on in which DC  
> the server is build…
>
> Can anyone suggest a better method of doing what I am trying to  
> achieve here?
>

dnsdomainname is going to use /etc/hosts to determine what the domain  
name is, since you are running outside the chroot, it's going to look  
at the hosts file that is built into the installer root image, not the  
one that actually contains your hostname.

You aren't doing anything here that requires you to be outside the  
chroot, so your best option is probably just to remove the --nochroot  
and remove /mnt/sysimage from all the paths.  If you have things that  
do need to be done outside the chroot, you can either split them into  
two separate %post sections, or run dnsdomainname inside the chroot...

%post --nochroot
DOMAIN=$( chroot /mnt/sysimage /bin/dnsdomainname )
echo "starting time sync"

The other option is not to use dnsdomainname at all, and just source / 
etc/sysconfig/network and extract the domainname from the hostname you  
find there...

%post --nochroot
. /mnt/sysimage/etc/sysconfig/network # to set $HOSTNAME
export DOMAIN=${HOSTNAME#*.}

-- 
Jason Kohles, RHCA RHCDS RHCE
email at jasonkohles.com - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/kickstart-list/attachments/20080130/950e9dee/attachment.htm>


More information about the Kickstart-list mailing list