PDA

View Full Version : Kickstart %post installation variables



goaf
22nd November 2004, 06:54 PM
Ive searched high and low regarding using variables in the %post section of a kickstart installation and Ive tried various options e.g "export HOSTNAME=test" and then tried using the $HOSTNAME variable later in the script but I cant get it to work.
Does anyone know if its possible to use variables in kickstart

Jman
22nd November 2004, 11:23 PM
It seems that you can use shell script style variables (http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-kickstart2-preinstallconfig.html), at least in %pre.

cshabazian
24th January 2005, 07:45 AM
variables work just fine within the %pre and %post sections, but aren't maintained across them without some tricks.

Roberto10
28th April 2008, 02:21 PM
I was having the worst week of my life until I saw hope in this thread: what do I do to make a variable's value persist from the %pre to the %post section?
I tried saving the value of the variable in a file while in %pre. However, the %post environment is in chroot, thus not able to see that file.

codecrank
28th April 2008, 07:04 PM
To find out what variables are used and their value, you could do :



%pre
exec > /root/preks.log 2>&1
set

%post
exec > /root/postks.log 2>&1
set


and check the output after the install.


you could preserve variables via an nfs-mounted file. kinda ugly but it should work.

Roberto10
28th April 2008, 10:19 PM
%pre has no access to /root, because hda is not yet formatted. And if it found a /root mounted, it would become erased by the disk formatting.
I'll try the NFS server option.

mkhan01
20th May 2009, 06:18 PM
you can call have multiple %post sections, hence call a %post w/ no chroot and xfer the file to somehere within the chrooted env, for eg:

%pre
echo "SOMEVAL" > /tmp/myvar # /tmp is in ram

%post --nochroot
cp /tmp/myvar /mnt/sysimage/tmp # /mnt/sysimage/tmp is /tmp in chrooted env

%post
read MYVAR < /tmp/myvar #read the var
echo $MYVAR # print its value, should be SOMEVAL
rm -rf /tmp/myvar # cleanup