I'm using PXE to install ISO. There are two scripts for environment configuration, I want to added them in kickstart file, so the environment will be setup completely and automatically after the system installed.
However, my situation is:
- Script 1 must reboot (has been added in script1.sh)
- Script 2 depends on script 1
Here part of kickstart file:
...
...
%post
wget http://xxx/script1.sh
wget http://xxx/script2.sh
sh -x script1.sh | tee script1.log
sh -x script2.sh | tee script2.log
%end
So, is there anyway that script 2 can be executed after system reboot by using kickstart file? Or the other way, just executed the script 2 once after reboot.
Thanks.
The way I have done this is to make a startup script that calls secondary script(s), which in your case are
script1.sh
andscript2.sh
.Here is one reference about configuring RHEL 6 Runlevels and Services. Alternatively, if have access to an existing RHEL/CentOS system you could browse
/etc/init.d/
and copy one of the simpler startup scripts there as the basis for your own.To put this all together, you'll need to:
In your kickstart file
wget
call to download the startup script you created./etc/init.d
. Keep in mind that%post
is run in a chroot environment.chkconfig
.In your startup script
script2.sh
, disable the startup script with anotherchkconfig *service_name* off
so it isn't run on future reboots.