28.6. 预​​​​​​​安​​​​​​​装​​​​​​​脚​​​​​​​本​​​​​​​

你​​​​​​​可​​​​​​​以​​​​​​​在​​​​​​​ ks.cfg 文​​​​​​​件​​​​​​​被​​​​​​​解​​​​​​​析​​​​​​​后​​​​​​​马​​​​​​​上​​​​​​​加​​​​​​​入​​​​​​​要​​​​​​​运​​​​​​​行​​​​​​​的​​​​​​​命​​​​​​​令​​​​​​​。​​​​​​​这​​​​​​​个​​​​​​​部​​​​​​​分​​​​​​​必​​​​​​​须​​​​​​​处​​​​​​​于​​​​​​​ kickstart 文​​​​​​​件​​​​​​​的​​​​​​​最​​​​​​​后​​​​​​​(在​​​​​​​命​​​​​​​令​​​​​​​部​​​​​​​分​​​​​​​之​​​​​​​后​​​​​​​)而​​​​​​​且​​​​​​​必​​​​​​​须​​​​​​​用​​​​​​​ %pre 命​​​​​​​令​​​​​​​开​​​​​​​头​​​​​​​。​​​​​​​你​​​​​​​可​​​​​​​以​​​​​​​在​​​​​​​ %pre 部​​​​​​​分​​​​​​​访​​​​​​​问​​​​​​​网​​​​​​​络​​​​​​​;然​​​​​​​而​​​​​​​,此​​​​​​​时​​​​​​​命​​​​​​​名​​​​​​​服​​​​​​​务​​​​​​​还​​​​​​​未​​​​​​​被​​​​​​​配​​​​​​​置​​​​​​​,所​​​​​​​以​​​​​​​只​​​​​​​能​​​​​​​使​​​​​​​用​​​​​​​ IP 地​​​​​​​址​​​​​​​。​​​​​​​

注意

注​​​​​​​意​​​​​​​,预​​​​​​​安​​​​​​​装​​​​​​​脚​​​​​​​本​​​​​​​不​​​​​​​在​​​​​​​改​​​​​​​换​​​​​​​了​​​​​​​的​​​​​​​根​​​​​​​环​​​​​​​境​​​​​​​(chroot)中​​​​​​​运​​​​​​​行​​​​​​​。​​​​​​​
--interpreter /usr/bin/python
允​​​​​​​许​​​​​​​你​​​​​​​指​​​​​​​定​​​​​​​不​​​​​​​同​​​​​​​的​​​​​​​脚​​​​​​​本​​​​​​​语​​​​​​​言​​​​​​​,如​​​​​​​ Python。​​​​​​​把​​​​​​​ /usr/bin/python 替​​​​​​​换​​​​​​​成​​​​​​​你​​​​​​​想​​​​​​​使​​​​​​​用​​​​​​​的​​​​​​​脚​​​​​​​本​​​​​​​语​​​​​​​言​​​​​​​。​​​​​​​

28.6.1. 范​​​​​​​例​​​​​​​

下​​​​​​​面​​​​​​​是​​​​​​​一​​​​​​​个​​​​​​​ %pre 部​​​​​​​分​​​​​​​的​​​​​​​示​​​​​​​例​​​​​​​:
%pre  
#!/bin/sh  
hds="" 
mymedia=""  
for file in /proc/ide/h* do   
	mymedia=`cat $file/media`   
	if [ $mymedia == "disk" ] ; then       
		hds="$hds `basename $file`"   
	fi 
done  
set $hds 
numhd=`echo $#`  
drive1=`echo $hds | cut -d' ' -f1` 
drive2=`echo $hds | cut -d' ' -f2`  
#Write out partition scheme based on whether there are 1 or 2 hard drives  
if [ $numhd == "2" ] ; then   
	#2 drives   
	echo "#partitioning scheme generated in %pre for 2 drives" > /tmp/part-include   
	echo "clearpart --all" >> /tmp/part-include   
	echo "part /boot --fstype ext3 --size 75 --ondisk hda" >> /tmp/part-include   
	echo "part / --fstype ext3 --size 1 --grow --ondisk hda" >> /tmp/part-include   
	echo "part swap --recommended --ondisk $drive1" >> /tmp/part-include   
	echo "part /home --fstype ext3 --size 1 --grow --ondisk hdb" >> /tmp/part-include 
else   
	#1 drive   
	echo "#partitioning scheme generated in %pre for 1 drive" > /tmp/part-include   
	echo "clearpart --all" >> /tmp/part-include   
	echo "part /boot --fstype ext3 --size 75" >> /tmp/part-includ   
	echo "part swap --recommended" >> /tmp/part-include   
	echo "part / --fstype ext3 --size 2048" >> /tmp/part-include   
	echo "part /home --fstype ext3 --size 2048 --grow" >> /tmp/part-include 
fi
该​​​​​​​脚​​​​​​​本​​​​​​​判​​​​​​​定​​​​​​​系​​​​​​​统​​​​​​​上​​​​​​​的​​​​​​​硬​​​​​​​盘​​​​​​​驱​​​​​​​动​​​​​​​器​​​​​​​的​​​​​​​数​​​​​​​量​​​​​​​,并​​​​​​​根​​​​​​​据​​​​​​​系​​​​​​​统​​​​​​​上​​​​​​​有​​​​​​​一​​​​​​​个​​​​​​​还​​​​​​​是​​​​​​​两​​​​​​​个​​​​​​​驱​​​​​​​动​​​​​​​器​​​​​​​而​​​​​​​编​​​​​​​写​​​​​​​带​​​​​​​有​​​​​​​不​​​​​​​同​​​​​​​分​​​​​​​区​​​​​​​方​​​​​​​案​​​​​​​的​​​​​​​文​​​​​​​本​​​​​​​文​​​​​​​件​​​​​​​。​​​​​​​与​​​​​​​其​​​​​​​在​​​​​​​ kickstart 文​​​​​​​件​​​​​​​中​​​​​​​有​​​​​​​一​​​​​​​组​​​​​​​分​​​​​​​区​​​​​​​命​​​​​​​令​​​​​​​,你​​​​​​​可​​​​​​​以​​​​​​​包​​​​​​​括​​​​​​​以​​​​​​​下​​​​​​​行​​​​​​​:
%include /tmp/part-include
脚​​​​​​​本​​​​​​​里​​​​​​​选​​​​​​​择​​​​​​​的​​​​​​​分​​​​​​​区​​​​​​​命​​​​​​​令​​​​​​​被​​​​​​​使​​​​​​​用​​​​​​​了​​​​​​​。​​​​​​​

注意

kickstart 文​​​​​​​件​​​​​​​的​​​​​​​ pre-installation 脚​​​​​​​本​​​​​​​部​​​​​​​分​​​​​​​不​​​​​​​能​​​​​​​够​​​​​​​管​​​​​​​理​​​​​​​多​​​​​​​个​​​​​​​安​​​​​​​装​​​​​​​树​​​​​​​或​​​​​​​安​​​​​​​装​​​​​​​介​​​​​​​质​​​​​​​。​​​​​​​这​​​​​​​个​​​​​​​信​​​​​​​息​​​​​​​必​​​​​​​须​​​​​​​包​​​​​​​含​​​​​​​在​​​​​​​创​​​​​​​建​​​​​​​的​​​​​​​每​​​​​​​个​​​​​​​ ks.cfg 文​​​​​​​件​​​​​​​里​​​​​​​,这​​​​​​​是​​​​​​​因​​​​​​​为​​​​​​​ pre-installation 脚​​​​​​​本​​​​​​​是​​​​​​​在​​​​​​​安​​​​​​​装​​​​​​​程​​​​​​​序​​​​​​​的​​​​​​​第​​​​​​​二​​​​​​​阶​​​​​​​段​​​​​​​才​​​​​​​被​​​​​​​执​​​​​​​行​​​​​​​。​​​​​​​

为了尽快向用户提供最新的信息,本文档可能会包括由机器自动从英文原文翻译的内容。如需更多信息,请参阅此说明。