Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

28.7. 後​​​​​​​續​​​​​​​安​​​​​​​裝​​​​​​​程​​​​​​​式​​​​​​​碼​​​​​​​

您​​​​​​​也​​​​​​​可​​​​​​​以​​​​​​​選​​​​​​​擇​​​​​​​增​​​​​​​加​​​​​​​在​​​​​​​安​​​​​​​裝​​​​​​​完​​​​​​​成​​​​​​​後​​​​​​​要​​​​​​​在​​​​​​​系​​​​​​​統​​​​​​​上​​​​​​​執​​​​​​​行​​​​​​​的​​​​​​​指​​​​​​​令​​​​​​​,這​​​​​​​個​​​​​​​部​​​​​​​份​​​​​​​必​​​​​​​須​​​​​​​在​​​​​​​ kickstart 檔​​​​​​​案​​​​​​​的​​​​​​​最​​​​​​​後​​​​​​​,而​​​​​​​且​​​​​​​必​​​​​​​須​​​​​​​以​​​​​​​ %post 指​​​​​​​令​​​​​​​開​​​​​​​頭​​​​​​​,這​​​​​​​個​​​​​​​部​​​​​​​份​​​​​​​在​​​​​​​例​​​​​​​如​​​​​​​安​​​​​​​裝​​​​​​​其​​​​​​​他​​​​​​​的​​​​​​​軟​​​​​​​體​​​​​​​以​​​​​​​及​​​​​​​設​​​​​​​定​​​​​​​另​​​​​​​一​​​​​​​部​​​​​​​名​​​​​​​稱​​​​​​​伺​​​​​​​服​​​​​​​器​​​​​​​時​​​​​​​相​​​​​​​當​​​​​​​好​​​​​​​用​​​​​​​。​​​​​​​

注意

如​​​​​​​果​​​​​​​您​​​​​​​以​​​​​​​靜​​​​​​​態​​​​​​​的​​​​​​​ IP 資​​​​​​​訊​​​​​​​(含​​​​​​​有​​​​​​​一​​​​​​​部​​​​​​​名​​​​​​​稱​​​​​​​伺​​​​​​​服​​​​​​​器​​​​​​​)來​​​​​​​設​​​​​​​定​​​​​​​網​​​​​​​路​​​​​​​,您​​​​​​​可​​​​​​​以​​​​​​​在​​​​​​​ %post 部​​​​​​​份​​​​​​​存​​​​​​​取​​​​​​​網​​​​​​​路​​​​​​​並​​​​​​​且​​​​​​​解​​​​​​​析​​​​​​​ IP 位​​​​​​​址​​​​​​​。​​​​​​​ 如​​​​​​​果​​​​​​​您​​​​​​​設​​​​​​​定​​​​​​​網​​​​​​​路​​​​​​​為​​​​​​​使​​​​​​​用​​​​​​​ DHCP,當​​​​​​​安​​​​​​​裝​​​​​​​程​​​​​​​式​​​​​​​執​​​​​​​行​​​​​​​ %post 部​​​​​​​份​​​​​​​時​​​​​​​,/etc/resolv.conf 檔​​​​​​​案​​​​​​​還​​​​​​​尚​​​​​​​未​​​​​​​完​​​​​​​成​​​​​​​。​​​​​​​您​​​​​​​可​​​​​​​以​​​​​​​存​​​​​​​取​​​​​​​網​​​​​​​路​​​​​​​,不​​​​​​​過​​​​​​​您​​​​​​​無​​​​​​​法​​​​​​​解​​​​​​​析​​​​​​​ IP 位​​​​​​​址​​​​​​​,因​​​​​​​此​​​​​​​如​​​​​​​果​​​​​​​您​​​​​​​使​​​​​​​用​​​​​​​ DHCP,您​​​​​​​必​​​​​​​須​​​​​​​在​​​​​​​ %post 部​​​​​​​份​​​​​​​指​​​​​​​定​​​​​​​ IP 位​​​​​​​址​​​​​​​。​​​​​​​

注意

後​​​​​​​續​​​​​​​安​​​​​​​裝​​​​​​​的​​​​​​​ script 會​​​​​​​在​​​​​​​ chroot 環​​​​​​​境​​​​​​​下​​​​​​​執​​​​​​​行​​​​​​​,因​​​​​​​此​​​​​​​將​​​​​​​無​​​​​​​法​​​​​​​執​​​​​​​行​​​​​​​如​​​​​​​從​​​​​​​安​​​​​​​裝​​​​​​​媒​​​​​​​體​​​​​​​複​​​​​​​製​​​​​​​ script 或​​​​​​​ RPM 之​​​​​​​類​​​​​​​的​​​​​​​工​​​​​​​作​​​​​​​項​​​​​​​。​​​​​​​
--nochroot
使​​​​​​​您​​​​​​​可​​​​​​​以​​​​​​​指​​​​​​​定​​​​​​​在​​​​​​​ chroot 環​​​​​​​境​​​​​​​之​​​​​​​外​​​​​​​執​​​​​​​行​​​​​​​的​​​​​​​指​​​​​​​令​​​​​​​。​​​​​​​
以​​​​​​​下​​​​​​​的​​​​​​​例​​​​​​​子​​​​​​​會​​​​​​​複​​​​​​​製​​​​​​​ /etc/resolv.conf 檔​​​​​​​案​​​​​​​到​​​​​​​剛​​​​​​​安​​​​​​​裝​​​​​​​好​​​​​​​的​​​​​​​檔​​​​​​​案​​​​​​​系​​​​​​​統​​​​​​​中​​​​​​​。​​​​​​​
%post --nochroot cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf
--interpreter /usr/bin/python
您​​​​​​​可​​​​​​​以​​​​​​​指​​​​​​​定​​​​​​​一​​​​​​​個​​​​​​​不​​​​​​​同​​​​​​​的​​​​​​​程​​​​​​​式​​​​​​​語​​​​​​​言​​​​​​​,例​​​​​​​如​​​​​​​ Python,請​​​​​​​以​​​​​​​您​​​​​​​所​​​​​​​選​​​​​​​擇​​​​​​​之​​​​​​​程​​​​​​​式​​​​​​​語​​​​​​​言​​​​​​​取​​​​​​​代​​​​​​​ /usr/bin/python。​​​​​​​

28.7.1. 範​​​​​​​例​​​​​​​

將​​​​​​​系​​​​​​​統​​​​​​​登​​​​​​​記​​​​​​​至​​​​​​​ Red Hat 網​​​​​​​路​​​​​​​衛​​​​​​​星​​​​​​​:
%post
( # Note that in this example we run the entire %post section as a subshell for logging.
wget -O- http://proxy-or-sat.example.com/pub/bootstrap_script | /bin/bash
/usr/sbin/rhnreg_ks --activationkey=<activationkey>
# End the subshell and capture any output to a post-install log file.
) 1>/root/post_install.log 2>&1
從​​​​​​​一​​​​​​​個​​​​​​​ NFS 的​​​​​​​共​​​​​​​享​​​​​​​資​​​​​​​源​​​​​​​上​​​​​​​執​​​​​​​行​​​​​​​一​​​​​​​個​​​​​​​名​​​​​​​為​​​​​​​ runme 的​​​​​​​程​​​​​​​式​​​​​​​碼​​​​​​​:
mkdir /mnt/temp 
mount -o nolock 10.10.0.2:/usr/new-machines /mnt/temp open -s -w -- 
/mnt/temp/runme 
umount /mnt/temp

注意

Kickstart 模​​​​​​​式​​​​​​​並​​​​​​​ 不​​​​​​​支​​​​​​​援​​​​​​​ NFS 檔​​​​​​​案​​​​​​​鎖​​​​​​​定​​​​​​​,因​​​​​​​此​​​​​​​在​​​​​​​掛​​​​​​​載​​​​​​​ NFS 時​​​​​​​需​​​​​​​要​​​​​​​ -o nolock。​​​​​​​