Re: hostname lookup ...

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

 




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@xxxxxxxxxxxxxxx - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire


_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/kickstart-list

[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux