%pre

Matt Schillinger mschillinger at wellinx.com
Tue Dec 14 15:13:39 UTC 2004


The 'ks.db' file contains data such as the following:

webp1wi1|fc2|10.1.1.1
webp2wi2|rh9|10.1.1.2

The naming scheme is specific to the company, but what matters to the
kickstart is the first 3 letters of the hostname, which dictates the
'function' of the machine. (web, prt [print], fax, dns)  there are
'function' specific 'packages', 'partitions', and '%post'.  'common' is
the base for which all machines are alike (base packages, base
partitioning, base post configuration). Then, there is the possibility
of having 'host' specific customization (hence ${HOSTNAME}.packages,
${HOSTNAME}.partition, ${HOSTNAME.post}. 'Host' based customization is
kept to a minimum.

URL: Basically, for the url command, i am trying to dynamically generate
the line by having a %include /tmp/url.cfg, which should contain the
'url' line.  the %pre parses field 2 (OS) of the ks.db file, and sets
the 'OS'. it then writes out 'url --url=http://{$KSSERVER}/${OS}' to the
file /tmp/url.cfg

PROBLEM
-------
Anytime that the 'url' command is not SPECIFIED directly in the ks.cfg,
(when i try to %include it, which i have verified that the /tmp/url.cfg
exists and is in the correct format), it causes the Kickstart to prompt
for media type (http, ftp, nfs, CDROM), as if there is no url setup.  As
soon as i include the url statically in the ks.cfg, everything works
fine.  My workaround for now, is to have 1 ks.cfg for each OS
(rh9,rhel-as3,fc1,fc2).

Follows is the %pre i'm using.

Matt Schillinger
mschillinger at wellinx.com


%pre
                                                                                
# First, determine the KickStart Server Address
SETSRV=0
SETHOST=0
for i in `cat /proc/cmdline` ; do
        echo $i | grep "KS=http"
        if [ $? -eq 0 ] ; then
           KSSERVER=`echo $i | awk -F"=" '{ print $2; }' | cut -d"/" -f
3`
           SETSRV=1
        fi
        echo $i | grep "HOSTNAME="
        if [ $? -eq 0 ] ;then
          HOSTNAME=`echo $i | awk -F"=" '{ print $2; }'`
          SETHOST=1
        fi
done
if [ $SETSRV -eq 0 ] ; then
   KSSERVER="172.16.31.243"
fi
if [ $SETHOST -eq 0 ] ; then
   cd /tmp
   /usr/bin/wget http://${KSSERVER}/ks/currenthost
   HOSTNAME=`cat /tmp/currenthost`
fi
                                                                                
function=`echo $HOSTNAME | cut -b1-3`
# Second, download all of the class scripts
cd /tmp
/usr/bin/wget http://${KSSERVER}/ks/ks.db
/usr/bin/wget http://${KSSERVER}/ks/common.partition
/usr/bin/wget http://${KSSERVER}/ks/common.packages
/usr/bin/wget http://${KSSERVER}/ks/${function}.partition
/usr/bin/wget http://${KSSERVER}/ks/${function}.packages
/usr/bin/wget http://${KSSERVER}/ks/${HOSTNAME}.partition
/usr/bin/wget http://${KSSERVER}/ks/${HOSTNAME}.packages
                                                                                
# retrieve Variable info from the ks.db file
HOSTDATA=`grep ${HOSTNAME} /tmp/ks.db`
                                                                                
# process and determine configuration of machine
                                                                                
# Networking
IP=`echo $HOSTDATA | awk -F"|" '{print $3; }'`
DEVICE="eth0"
NETMASK="255.255.255.0"
GATEWAY=`echo $IP | awk -F"." '{print $1 "." $2 "." $3 ".254"; }'`
NAMESERVER1="10.1.2.60"
                                                                                
echo "network --bootproto=static --ip=${IP}  --device=${DEVICE}
--netmask=${NETMASK}  --gateway=${GATEWAY} --nameserver=${NAMESERVER1}
--hostname=${HOSTNAME}" >> /tmp/networking.cfg
                                                                                
# generate url.cfg
OS=`echo $HOSTDATA | awk -F"|" '{print $2; }'`
URL="http://${KSSERVER}/$OS"
echo "url --url=${URL}" > /tmp/url.cfg





On Mon, 2004-12-13 at 18:58, Philip Rowlands wrote:
> On Mon, 13 Dec 2004, Matt Schillinger wrote:
> 
> >I am trying to implement a customized kickstart system, that pulls
> >variables for almost everything..
> 
> Good plan.
> 
> >it should take the original http://IPOFSERVER/ks/ks.cfg and parse out
> >the IP (in %pre) to make the IP a KSSERVER variable.
> 
> OK; the kickstart file being specified on the kernel command line.
> 
> >The way i am trying to do this, is to dynamically create the data in
> >pre, and create a /tmp/url.cfg.
> 
> Sounds like it ought to work. Could you post the %pre script which
> writes out /tmp/url.cfg ?
> 
> 
> Cheers,
> Phil
> 
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list at redhat.com
> https://www.redhat.com/mailman/listinfo/kickstart-list
> 




More information about the Kickstart-list mailing list