If I wanted to run a shell script that was its own file from my RHEL7 kickstart's %post
section, where would I need to put that extra file and what would be the path I would use to run it? For example, if my kickstart.cfg
file resides in my isolinux
directory, would I put the extra shell script in the isolinux file and then run it by putting ./shell-script
in my %post
section? I guess some of my confusion comes from how not understanding how the ISO unpacks everything to become the system at install time.
I want to do this for a bit more modularity in my ISO as the shell script I want to run is a few thousand lines long which I feel like would convolute the kickstart file, especially if I want to run multiple scripts after install.
For reference, here is my kickstart file:
lang en_US
keyboard us
timezone <location> --isUtc
rootpw <password> --iscrypted
#platform x86, AMD64, or Intel EM64T
reboot
text
cdrom
bootloader --location=mbr --append="rhgb quiet crashkernel=auto"
zerombr
clearpart --all --initlabel
autopart
auth --passalgo=sha512 --useshadow
selinux --enforcing
firewall --enabled --ssh
skipx
firstboot --disable
%pre
%end
%post
<RUN SHELL SCRIPT HERE>
%end
%packages
%end
Best Answer
I put the script in my
isolinux
directory and added the following to the%post
section of my kickstart file:Note, that in order to copy the file into the
/root
directory of the newly installed system you need the--nochroot
flag. This has caused me some issues as I have some paths in the script I am trying to run that begin with/
as the base directory. I still have figured out how to fix this, but I have opened up a new ticket about it.