%include
using a %include can be very helpful. However, you should note that many of the utilities you expect to be on the system will not be present at this point. Moreover, dns will not be operational at ths point. In our example we used nslookup to determine the hostname, you should note that this is not the nslookup that will be on the installed system, it is the busybox nslookup. The output from nslookup in the install environment will be different than that of the full system. To help write your scripts, create a kickstart that has a read line %pre, then chvt to vt 2 (Ctrl-Alt-F2) and try your scripts from the install environment. You will then know which commands are available and more importantly how they will interact with your script.%include can be used to include any other kickstart script in a kickstart script, so you can modularize your kickstart configs.
In this example, I added %include /tmp/disk.cfg in our default.cfg at the point where we specified the partition information.
... # Disk partitioning information part /boot --bytes-per-inode=4096 --fstype="ext3" --size=150 part pv.1 --bytes-per-inode=4096 --grow --size=0 %include /tmp/disk.cfg ... %pre IPADDRESS=`ifconfig eth0 |grep 'inet addr' |awk -F: '{print $2 }' |awk '{print $1 }'` HOSTNAME=`nslookup $IPADDRESS| grep Name | tail -1 | awk '{print $2}'` HOST=`echo $HOSTNAME |awk -F. '{print $1}'` if [ "$HOST" = "" ]; then HOST="unconfigured" fi chvt 2 echo "appending ${HOST}_volume partition information to kickstart" catThis code will try and configure the volgroup to use the name hostname_volume. If it fails to find the hostname (dns does not work in a %pre script), it will default to using the name unconfigured_volume./tmp/disk.cfg volgroup ${HOST}_volume --pesize 32768 pv.1 logvol swap --fstype swap --name=SwapVol --vgname=${HOST}_volume --size=1024 --grow --maxsize=8192 logvol / --fstype ext3 --name=RootVol --vgname=${HOST}_volume --size=8192 --grow EOF sleep 5 chvt 1