IBM Books

Software Planning and Installation Guide


RedHat 7.1 Kickstart configuration template file

The following is a sample Kickstart configuration template for RedHat 7.1. The template file is located in /opt/csm/install/kscfg.tmpl.RedHat.7.1. The most commonly updated sections of this template are shown in boldface type.

#
#Kickstart Configuration File for RedHat 7.1 Only
#
 
lang en_US
keyboard "us"
 
network --bootproto dhcp
 
#
# Where are the RedHat RPMs?
# nfs --server hostname.of.server --dir /path/to/RH/CD/image
#
# If your RedHat RPMs are not on the management server in the normal location,
# you can replace the NFS_HOSTNAME and NFS_DIR variables with your own
# values.
#
nfs --server #NFS_HOSTNAME# --dir #NFS_DIR#
 
#
# Clear the MBR
#
zerombr yes
 
#
# Wipe out the disk
#
clearpart --all
 
#
# Disk partition table. Customize it to fit your needs.
# /boot is strongly recommended
#
part /boot --size 50   --fstype ext3
part /     --size 1024 --fstype ext3
part swap  --size 1024 --ondisk sda
part /var  --size 1024 --fstype ext3
part /opt  --size 512  --fstype ext3
part /usr  --size 2048 --fstype ext3
#
# install or upgrade
#
install
 
#
# mouse selection
#
#mouse genericps/2 --emulthree
mouse none
 
#
# Select a time zone
# Add the --utc switch if your hardware clock is set to GMT
# Use the /usr/sbin/timeconfig tool to determine valid values.
#
# The timezone is set by default to the same timezone that the management
# server has.  This is found in /etc/sysconfig/clock on the management server.
#
timezone #TIMEZONE_UTC# #TIMEZONE#
 
#
# Don't set up X Windows.
#
skipx
 
#
# To generate an encrypted root password use:
#
# perl -e 'print crypt("blah","Xa") . "\n";'p
# openssl passwd -apr1 -salt xxxxxxxx password
# 
# where "blah" is your root password.
#
# --iscrypted is broken
#
#rootpw --iscrypted XaLGAVe1C41x2
#rootpw XaLGAVe1C41x2 --iscrypted
rootpw cluster
auth --useshadow --enablemd5
 
#
# Lilo
#
lilo --location mbr
 
#
# Reboot after installation
#
reboot
 
#
#end of section
#
 
#
# Choose the packages and package groups to install
# The following files must not be removed, or else csm will not work:
#   @ Networked Workstation
#   pdksh
#   kernel-headers
#   rsh-server
#   nfs-utils
#   xinetd
#   tftp
#   binutils
#   others ????
#   
#
%packages
@ Networked Workstation
compat-libstdc++
kernel-smp
kernel-headers
glibc-devel
binutils
cpp
gcc
flex
autofs
pdksh
tcsh
ntp
xosview
XFree86
tftp
xinetd
rsh
rsh-server
telnet-server
pvm
pvm-gui
psacct
nfs-utils
raidtools
ucd-snmp
rsync
yp-tools
ypserv
ypbind
m4
sendmail-cf
%pre#
# Pre Install script
#
# This script may be modified as needed.  However, certain sections should
# not be altered or else the CSM installation will not work correctly. These
# sections are marked with the text "DO NOT ERASE THIS SECTION".
#
 
####################### DO NOT ERASE THIS SECTION (begin) #####################
#
# Set some variables first.  These get filled in by the management server.
export NODE_HOSTNAME=#NODE_HOSTNAME#
export NFS_IP=#NFS_IP#
export TFTP_IP=#TFTP_IP#
export CSM_VERSION=#CSM_VERSION#
export CSMINSTALL=/csminstall
export ATFTP=$CSMINSTALL/csm/$CSM_VERSION/atftp
export LOGFILE=/var/log/csm/install.log
 
write_log()
{
    mkdir -p /var/log/csm
    echo "`date`: $*" >> $LOGFILE
} # END write_log
 
LOGGER='write_log'
 
$LOGGER "`mkdir $CSMINSTALL 2>&1`"
$LOGGER "`mount -o nolock $NFS_IP:$CSMINSTALL $CSMINSTALL 2>&1`"
 
# Update the status file on the management server to say that the install is
# starting.
 
msg="Reboot complete"
/csminstall/csm/write_status -v -p $ATFTP -S $TFTP_IP -n $NODE_HOSTNAME $msg
 
msg="Starting Kickstart Install"
/csminstall/csm/write_status -v -p $ATFTP -S $TFTP_IP -n $NODE_HOSTNAME $msg
 
umount $CSMINSTALL
 
####################### DO NOT ERASE THIS SECTION (end) #######################
exit 0
 
%post
#
# Post Install script
#
# This script may be modified as needed.  However, certain sections should
# not be altered or else the CSM installation will not work correctly. These
# sections are marked with the text "DO NOT ERASE THIS SECTION".
#
 
####################### DO NOT ERASE THIS SECTION (begin) #####################
#
# The LOGGER variable is used to send items to some kind of log.  It can be
# set to 'write_log' in order to call the 'write_log' function (defined below)
# which sends the log output to /var/log/csm/install.log on the node.
# If LOGGER is set to /usr/bin/logger, the Linux syslog facility is used 
# instead.
#
#export LOGGER=/usr/bin/logger
export LOGGER=write_log
 
#
# Set variables
#
# The following variables are substituted into the kickstart template file
# from the setupks tool
#
# MGMTSVR_HOSTNAME   = management server (Long Hostname)
# MGMTSVR_SHORTHOST  = management server (Short Hostname)
# MGMTSVR_IP         = management server (IP)
# NODE_HOSTNAME      = node hostname (Long Hostname)
# NODE_HEX           = node IP address in hexidecimal format
# NFS_HOSTNAME       = NFS Server (Long Hostname) - same as MGMTSVR_HOSTNAME
# NFS_IP             = NFS Server (IP) - same as MGMTSVR_IP
# NFS_DIR            = Path to RedHat CD image on NFS Server
# TFTP_IP            = TFTP Server (IP) - same as MGMTSVR_IP
# NAMESERVERS        = list of comma delimited name servers(IPs or Hostnames)
# DNSDOMAIN          = DNS domain name of the node(NAME)
# SETUP_RSH          = Set to "Y" if $DSH_REMOTE_CMD variable on the 
#                      management server is set to "rsh" or is blank.
# CSM_VERSION        = The version of CSM that is being installed
# TIMEZONE           = Timezone string of the Management Server
# TIMEZONE_UTC       = Timezone Universal System Time Setting 
#                      on the Management Server (either --utc or blank)
#
export KICKSTART_LOGFILE=/var/log/csm/install.log
export MGMTSVR_HOSTNAME=#MGMTSVR_HOSTNAME#
export MGMTSVR_SHORTHOST=#MGMTSVR_SHORTHOST#
export MGMTSVR_IP=#MGMTSVR_IP#
export NODE_HOSTNAME=#NODE_HOSTNAME#
export NODE_HEX=#NODE_HEX#
export NFS_HOSTNAME=#NFS_HOSTNAME#
export NFS_IP=#NFS_IP#
export TFTP_IP=#TFTP_IP#
export NAMESERVERS=#NAMESERVERS#
export DNSDOMAIN=#DNSDOMAIN#
export SETUP_RSH=#SETUP_RSH#
export CSM_VERSION=#CSM_VERSION#
 
#
# Hardcode some other variables
#
export GATEWAY=$(netstat -rn | grep 0.0.0.0 | tail -1 | awk '{print $2}')
export CSM_MANPATH=/opt/man
export CSM_PATH=/opt/bin
export TFTPBOOT=/tftpboot
export CSMINSTALL=/csminstall
export ATFTP=$CSMINSTALL/csm/$CSM_VERSION/atftp
 
#
# Function to add some text to the install.log file on the node.
#
write_log()
{
    mkdir -p /var/log/csm
    echo "`date`: $*" >> $KICKSTART_LOGFILE
} # END write_log
 
#
# Use atftp to get a file from the management server.  The remote file is
# relative to /tftpboot
#
atftp_get()
{
    _remote_file=$1
    _local_file=$2
 
    # Use this format if LOGGER=/usr/bin/logger
    #echo "get $_local_file $remote_file" | $ATFTP $TFTP_IP 2>&1 | $LOGGER
 
    # Use this format if LOGGER=write_log
    $LOGGER "`echo \"get $_remote_file $_local_file\" | $ATFTP $TFTP_IP 2>&1`"
} # END atftp_get
 
#
# Use atftp to put a file to the management server.  The remote file is
# relative to /tftpboot
#
atftp_put()
{
    _local_file=$1
    _remote_file=$2
 
    # Use this format if LOGGER=/usr/bin/logger
    #echo "put $_remote_file $local_file" | $ATFTP $TFTP_IP 2>&1 | $LOGGER
 
    # Use this format if LOGGER=write_log
    $LOGGER "`echo \"put $_local_file $_remote_file\" | $ATFTP $TFTP_IP 2>&1`"
} # END atftp_put
 
 
#
# Function to add a line to the status file on the management server.  
# The status file is in the /csminstall/csm/status directory on the 
# management server.
#
# The first argument to this function is the message.  It should be quoted
# if it contains spaces.  The second optional argument is a status.  This is
# typically used to send the exit code of a command to the status log.
#
# The format of the output message in the status file is:
#    <date>: <message>: <status>
# If <status> is not provided, the format of the message in the status file is:
#    <date>: <message>
#
# This function uses atftp to transfer the status file back and forth.  The
# atftp server should have been setup on the management server automatically 
# when csm.server was installed.  The atftp client resides in the mounted
# /csminstall filesystem.  So this function cannot be used until after the
# /csminstall filesystem is mounted.
#
write_status()
{
    msg=$1;
    status=${2:-''}
 
    if [ "$status" ]
    then
	statusflag="-s $status"
    else
	statusflag=""
    fi
    
    /csminstall/csm/write_status -p $ATFTP -S $TFTP_IP -n $NODE_HOSTNAME $statusflag $msg
 
}  # END write_status
 
 
$LOGGER "Starting Install"
 
#netstat -rn | $LOGGER		# Use this format if LOGGER=/usr/bin/logger
$LOGGER "`netstat -rn`"		# Use this format if LOGGER=write_log
 
#
# Setup Syslog
#
# Turn syslog so we can use $LOGGER to send messages to syslogd running on a
# management node. Use $LOGGER.
#
# Uncomment this if you want all syslog messages from the node to be sent to
# the management server.  Be sure to also uncomment the section that says
# "Setup Syslog again" (below)
#
#mv /etc/syslog.conf /etc/syslog.conf.ORIG
#echo "*.*	@$MGMTSVR_IP" >/etc/syslog.conf
#/etc/rc.d/init.d/syslog start
#$LOGGER "Install: syslog setup"
 
#
# Mount /csminstall
#
$LOGGER "Mounting $CSMINSTALL"
# Use this format if LOGGER=/usr/bin/logger
#mkdir $TFTPBOOT 2>&1 | $LOGGER
#mount -o nolock $NFS_IP:$TFTPBOOT $TFTPBOOT 2>&1 | $LOGGER
# Use this format if LOGGER=write_log
$LOGGER "`mkdir $CSMINSTALL 2>&1`"
$LOGGER "`mount -o nolock $NFS_IP:$CSMINSTALL $CSMINSTALL 2>&1`"
 
write_status "Kickstart RPM Installation Complete."
write_status "Starting Kickstart Post-Install."
 
# Run csmprereboot.  This adds csmfirstboot to the /etc/inittab file.
# It also mounts and unmounts /csminstall if needed.
/csminstall/csm/$CSM_VERSION/csmprereboot -m $MGMTSVR_HOSTNAME -n $NODE_HOSTNAME
 
####################### DO NOT ERASE THIS SECTION (end) #######################
 
#
# Hardcode eth0 (optional, recommended)
#
$LOGGER "Setting up eth0"
IP0=$(ifconfig eth0 | grep inet | awk '{print $2}' | awk -F: '{print $2}')
BC0=$(ifconfig eth0 | grep inet | awk '{print $3}' | awk -F: '{print $2}')
SM0=$(ifconfig eth0 | grep inet | awk '{print $4}' | awk -F: '{print $2}')
cd /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth0.ORIG
echo "DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
IPADDR=$IP0
BROADCAST=$BC0
NETMASK=$SM0" >ifcfg-eth0
 
#
# Setup /etc/resolv.conf
#
$LOGGER "Setting up /etc/resolv.conf"
mv /etc/resolv.conf /etc/resolv.conf.ORIG
if [ "$DNSDOMAIN" ]
then
    echo "search $DNSDOMAIN" >/etc/resolv.conf
fi
for i in $(echo $NAMESERVERS | tr ',' ' ')
do
	echo "nameserver $i"
done >>/etc/resolv.conf
 
#
# Setup /etc/sysconfig/network
#
$LOGGER "Setting up /etc/sysconfig/network"
HOSTNAME=$(host $IP0 2>/dev/null | awk '{print $5}' | sed 's/\.$//')
SHORT_HOSTNAME=$(echo $HOSTNAME | awk -F. '{print $1}')
cp /etc/sysconfig/network /etc/sysconfig/network.ORIG
echo "NETWORKING=yes
HOSTNAME=$HOSTNAME
FORWARD_IPV4=yes
GATEWAYDEV=eth0
GATEWAY=$GATEWAY" >/etc/sysconfig/network
 
#
# Setup /etc/hosts
# Add myself and the management server
#
$LOGGER "Setting up /etc/hosts"
echo "127.0.0.1	localhost
 
$IP0	$HOSTNAME	$SHORT_HOSTNAME
$MGMTSVR_IP	$MGMTSVR_HOSTNAME	$MGMTSVR_SHORTHOST" > /etc/hosts
 
#
# Add users (optional)
#
# The following line produces an encrypted password of "cluster"
# perl -e 'print crypt("cluster","Xa") . "\n";'p
#
$LOGGER "Adding users"
adduser admin -u 1000 -p `perl -e 'print crypt("cluster","Xa") . "\n";'`
#
# Enable rsh, add management server to /root/.rhosts and add 'rsh' to 
# /etc/securetty to allow root to rsh to the node.
#
if [ "${SETUP_RSH}" = "Y" ]
then
	if [ -r /etc/xinetd.d/rsh ]
	then
		$LOGGER "Enable rsh"
		# Could use chkconfig to do this 
		#perl -pi -e 's/^(\tdisable[^=]*=) yes/$1 no/' /etc/xinetd.d/rsh
		chkconfig rsh on
 
		$LOGGER "Allow root to rsh"
		echo "rsh" >> /etc/securetty
 
		$LOGGER "Setting up /root/.rhosts"
		cd /root
		echo "$MGMTSVR_SHORTHOST" >.rhosts
		echo "$MGMTSVR_HOSTNAME" >>.rhosts
		chmod 600 .rhosts
	fi
fi
 
#
# Setup PAM (optional)
#
# Uncomment this if you want to enable ftp, login, rlogin, rsh, sshd
#$LOGGER "Setup PAM"
#cd /etc/pam.d
#for i in ftp login rlogin rsh sshd
#do
#	echo "account    required     /lib/security/pam_access.so" >>$i
#done
#echo "-:ALL EXCEPT root:ALL" >>/etc/security/access.conf
#cp /etc/security/access.conf /etc/security/access.conf.BOOT
#echo "cp /etc/security/access.conf.BOOT /etc/security/access.conf >/dev/null 2>&1" >>/etc/rc.d/rc.local
 
 
#
# Setup man paths in /etc/man.config.  Add CSM_MANPATH after /usr/local/man.
#
$LOGGER "Setup man paths"
cp -f /etc/man.config /etc/man.config.ORIG
FIXEDMANPATH=$(echo $CSM_MANPATH | sed 's/\//\\\//g')
perl -pi -e "s/^MANPATH[\t ]+\/usr\/local\/man$/MANPATH\t\/usr\/local\/man\nMANPATH $FIXEDMANPATH/" /etc/man.config
 
#
# Setup paths.
#  Add PATH definitions to /etc/profile.d/csm.sh and /etc/profile.d/csm.csh
#  Add section to /etc/csh.login that source's all the *.csh files 
#     in /etc/profile.d/  (just like /etc/profile does for *.sh files).
#
$LOGGER "Setup PATHS"
echo "export PATH=\$PATH:$CSM_PATH" >/etc/profile.d/csm.sh
echo "setenv PATH \"\${PATH}:$CSM_PATH\"" >/etc/profile.d/csm.csh
chmod 755 /etc/profile.d/csm.*
echo "
test -d /etc/profile.d
if (\$status == 0) then
	set nonomatch
		foreach i ( /etc/profile.d/*.csh )
		test -f \$i
		if (\$status == 0) then
			source \$i
		endif
		end
	unset i nonomatch
endif" >>/etc/csh.login
 
#
# Setup services
#
$LOGGER "Setup services"
#chkconfig --del apmd 
#chkconfig --del gpm 
#chkconfig --del kudzu 
#chkconfig --del lpd 
#chkconfig --del pcmcia 
#chkconfig --del linuxconf 
#chkconfig --del sendmail 
#chkconfig --del xfs
#chkconfig --del httpd
#chkconfig --del autofs
#chkconfig --del identd
#chkconfig --del isdn
#chkconfig --del pppoe
#chkconfig --level 345 ntpd on
#chkconfig --level 345 sshd on
#chkconfig --level 345 snmpd on
chkconfig telnet on
 
#
# Setup Syslog Again
#
# Uncomment this if you want all syslog messages from the node to be sent to
# the management server.  Be sure to also uncomment the section that says
# "Setup Syslog" (above)
#
#$LOGGER "Syslog setup again"
#echo "*.*	@$MGMTSVR_IP" >/etc/syslog.conf
 
#
# Set local and remote complete install flag
# Put file in /dev/sda1
date >/boot/install_complete
 
####################### DO NOT ERASE THIS SECTION (begin) #####################
#
# Create a pxelinux configuration file for this node and tftp it to the 
# management server.  This pxelinux file will cause the node to boot to 
# the hard disk on the next reboot after the install is complete.  The
# CSM code will be installed during the first reboot of the hard disk.
#
$LOGGER "Update pxelinux configuration on management server"
HEX=$NODE_HEX
 
cd /tmp
 
#
# Use atftp to copy the HEX file over to the management server.
# The HEX file contains a new pxelinux configuration that causes the node
# to boot from hard disk on the next reboot.
#
echo "#boot" >$HEX
#$LOGGER "`echo \"get pxelinux.cfg/$HEX blah\" | $ATFTP $TFTP_IP 2>&1`"
atftp_get pxelinux.cfg/$HEX blah
 
grep SERIAL blah >>$HEX
echo "DEFAULT xCAT
LABEL xCAT
LOCALBOOT 0" >>$HEX
 
#$LOGGER "`echo \"put $HEX pxelinux.cfg/$HEX\" | $ATFTP $TFTP_IP 2>&1`"
atftp_put $HEX pxelinux.cfg/$HEX
 
 
#
# Copy the install log to the management server in /tftpboot/status
#
local_file=$KICKSTART_LOGFILE
remote_file="status/$NODE_HOSTNAME.install.log"
atftp_put $local_file $remote_file
 
#
# Tell the management server that the install is complete.
#
write_status "Kickstart Post-Install Complete."
write_status "Rebooting to hard disk."
 
#
# Unmount $CSMINSTALL
#
$LOGGER "Unmounting $CSMINSTALL"
cd /
umount $CSMINSTALL
rmdir $CSMINSTALL
####################### DO NOT ERASE THIS SECTION (end) #######################
 
cd /
$LOGGER "Install complete"
exit 0


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]