How do I pass arguments from the PXE command line to a kickstart %pre, %post script?
With simple boolean options, I've done a grep
in /proc/cmdline
, which is very easy. For key-value options, the set
trick seems handy, though I haven't tried it. Specific answers to your questions:
1) Yes, it sounds like this will work. I've done very similar things with kickstart and /proc/cmdline
.
2) No, I don't believe there is any better way. The kernel exposes its command line options in /proc/cmdline
, and kickstart doesn't provide any high-level mechanisms for dealing with kernel command line options.
3) Yes, this has been done before. Try it out, and come back if you can't make it work.
A few additional thoughts:
1) Don't put a comma between the command-line options (just separate them with spaces).
2) With pxelinux, it can be helpful to use an append
line. For example:
append initrd=f16-x86_64/initrd.img ks=nfs:server.example.com:/path/to/f16.ks mycustomflag mykey=myval
3) Network settings (like the hostname example you gave) are often better served by DHCP.
I was able to get it working using the following commands to parse all of the key value pairs into variables:
# Get the kernel parameters
params=`cat /proc/cmdline`
# Split them on spaces
params_split=(${params// / })
# Go through each of them
for p in "${params_split[@]}"; do
# And if it's a key value pair
if [[ $p =~ "=" ]]; then
# And if the key doesn't have a period in it
p_split=(${p//=/ })
if [[ !($p_split[0] =~ ".") ]]; then
# Then set the key to the value
eval $p;
fi;
fi
done