This is what I wrote when I read the document. It is basically part of the Oreilly document translated.
Original article: http://www.linuxdevcenter.com/pub/a/linux/2004/11/04/advanced_kickstart.html
Pre-And Postinstall scripts
Kickstart provides some basic system adjustments and settings, such as setting the root password and time zone. However, it cannot make more detailed adjustments, such as disabling certain services through chkconfig and creating specific directories. Therefore, we need to use the pre-And postinstall scripts to complete these tasks. Obviously, we can see from the name that the execution time of these two types of scripts is pre-executed before installation, and post script is executed after the entire installation process is completed. Both the preinstall and postinstall scripts are defined at the end of the ks file.
The preinstall script starts with % pre. The script uses a syntax similar to that in the RPM spec file. At this stage, the preinstall script can only perform some basic operations, such as searching for some files or mounting NFS sharing.
Postintall scripts have more potential. The postinstall script starts with % post. After the OS installation is complete, the postinstall script is executed on the newly installed system by default. The newly installed system is in the chroot environment, and the root directory is in/mnt/sysimage.
You can use % post-nochroot to execute some commands in non-chroot environments. For example, in the chroot environment, you cannot access the installation disc in the optical drive, because the disc is mounted to/tmp/cdrom and is in the non-chroot environment.
Generally, the postinstall script starts #! The custom shell such as/bin/sh is used as the first line, and then the following is a normal shell script. In this way, you can do everything you want.
From polygun2000 blog