Fedora Linux Support Community & Resources Center
  #1  
Old 23rd October 2012, 10:05 PM
daytooner Offline
Registered User
 
Join Date: Apr 2009
Posts: 182
linuxfedorafirefox
HowTo: set system HOST name in kickstart

I am building a kickstart file. But I can't find anywhere how to set the $HOST variable name.

The GUI install prompts for a host name, then uses that for several things, including naming various LVMs (vg_<host>_root, etc). So is there a way to set this in the kickstart file? Or do I need to manually name everything?

I could write out a file like /etc/sysconfig/network in a %pre script, %include that file in, and set a variable that way (and then in a %post script write out the fhat file to the chroot'd environment). But I was wondering if there was a simpler built in way to do that. (I do know how to read a vaiable from the kernel boot line in the %pre script).

TIA

ken
Reply With Quote
  #2  
Old 23rd October 2012, 10:23 PM
sea's Avatar
sea Online
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Helvetic Federation (Swissh)
Age: 33
Posts: 2,598
windows_7chrome
Re: HowTo: set system HOST name in kickstart

I learn much about customizing my own KS while looking at the one's Anaconda is generating after each and every OS installation.
Have a look at /root/anaconda-ks.cfg

Hope this helps

EDIT:
As i had forgotten to name my machines during the last installations, idk if you find anything usefull.
Good luck
__________________
Fedora Manual: http://docs.fedoraproject.org
Script-Tools: https://sourceforge.net/projects/script-tools/
sudo st tweak repo toggle livna ; st iso dl-fed && st iso usb
Reply With Quote
  #3  
Old 23rd October 2012, 10:46 PM
DBelton's Avatar
DBelton Offline
Administrator
 
Join Date: Aug 2009
Posts: 6,613
linuxfirefox
Re: HowTo: set system HOST name in kickstart

hostname is set in your kickstart file on the network line using the --hostname parameter..

For example:

Code:
network --onboot yes --device p33p1 --noipv6 --nameserver 192.168.1.254 --hostname tower20.home
Reply With Quote
  #4  
Old 24th October 2012, 01:51 AM
daytooner Offline
Registered User
 
Join Date: Apr 2009
Posts: 182
linuxfedorafirefox
Re: HowTo: set system HOST name in kickstart

Quote:
Originally Posted by DBelton View Post
hostname is set in your kickstart file on the network line using the --hostname parameter..

For example:

Code:
network --onboot yes --device p33p1 --noipv6 --nameserver 192.168.1.254 --hostname tower20.home
I kind of assumed that. But just a couple of clarifications: does this set the $HOSTNAME variable within the kickstart script? Put another way, how do I use that name (tower20.home) in your example) to set logvol names (vg_tower20.home_root, etc). Also, will kickstart put this value into /etc/syconfig/network, or will I need to do this in a %post script.

(FWIW: I am planning on using this script for multiple installs, with only the host name changed. That would be set in the default pxeboot
Anyways, thanks for this info. It is a good start, and since this first install is a fresh, test one, I guess I can play around a bit.

ken
Reply With Quote
  #5  
Old 24th October 2012, 03:26 AM
DBelton's Avatar
DBelton Offline
Administrator
 
Join Date: Aug 2009
Posts: 6,613
linuxfirefox
Re: HowTo: set system HOST name in kickstart

I have never really tried doing what you are wanting, so I really don't know for certain if it sets the $HOSTNAME variable or not.

I did run across something in my notes from awhile back about getting the hostname in the %pre section, though. It asks for the hostname in a virtual console and set up the network (/etc/sysconfig/network) file.

Code:
%pre
chvt 6

## Query for hostname, then write it to 'network' file
read -p "

What is my hostname?

" NAME /dev/tty6 2>&1

echo "NETWORKING=yes
HOSTNAME=${NAME}" > network

chvt 1
And in the %post to actually write the file out:
Code:
%post --nochroot
# bring in hostname collected from %pre, then source it
cp network /mnt/sysimage/etc/sysconfig/network
. /mnt/sysimage/etc/sysconfig/network
# force hostname change
/mnt/sysimage/bin/hostname $HOSTNAME

# setup variables for use in /etc/hosts
LONG=`/mnt/sysimage/bin/hostname`
SHORT=`/mnt/sysimage/bin/hostname -s`
IP=`/mnt/sysimage/usr/bin/host ${SHORT} | awk {'print $4'}`
echo "${IP}\t\t${LONG} ${SHORT}" >> /mnt/sysimage/etc/hosts
Reply With Quote
  #6  
Old 26th October 2012, 12:53 AM
daytooner Offline
Registered User
 
Join Date: Apr 2009
Posts: 182
linuxfedorafirefox
Re: HowTo: set system HOST name in kickstart

Thanks for all of the suggestions.

There are some that have some nice suggestions for other uses that I need.

But the solution to this particular problem turns out to be really simple. As DBelton pointed out, the hostname is the network's hostname. So just add "--hostname=<whatever>" to the network line in your kickstart file.

This sets the computer's name, as well as the lv's that get generated (vg_<hostname>_lv_root, etc.). which is what I wanted.

Thanks to all.

ken
Reply With Quote
Reply

Tags
host, hostname, howto, kickstart, set

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
local host login nm-system-settings: could not get the system bus Snoopz2403 Hardware & Laptops 3 5th August 2008 02:42 PM
system-config-kickstart FC5 will not run Luniz2k1 Using Fedora 0 14th October 2006 12:11 AM
use system-config-kickstart from FC2 for FC1 JJS EOL (End Of Life) Versions 0 9th June 2004 11:21 AM


Current GMT-time: 17:09 (Saturday, 18-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat