[CentOS] how to 'yum update' in a %post

Fri Jun 2 14:31:47 UTC 2006
Joseph Haig <joseph.haig at supanet.net.uk>

Tom Brown wrote:

>
>> Try this in your kickstart file:
>>
>> %post --interpreter /bin/bash
>> yes | yum update
>>
>> Without the '--interpreter /bin/bash' the code will (I think) be 
>> interpreted as python.  Also, when you run 'yum update' you are 
>> prompted to confirm that you want to go ahead and update the listed 
>> packages, and so you need to pipe 'yes' through it.
>
>
> thanks for the response - with regard piping yes through to yum it 
> seems you can just specify  yum -y update and this will anser yes for 
> you.
>
> the interpreter bit is now causing the end of the kickstart to bomb 
> out with the error of '/usr/local/bin/bash can not be run' as this is 
> where bash is it seems. This is the %post bit of the kickstart
>
> %post --nochroot --interpreter /usr/local/bin/bash
> /usr/bin/yum -y update
>
Firstly, try it without the --nochroot as this switch makes the code run 
in the install system environment rather than chrooting into the newly 
installed system.  Even if the commands worked, packages would be 
installed into the temporary file system in memory rather than onto 
disk.  Secondly, it shouldn't be /usr/local/bin/bash unless you have 
installed a custom bash package.  However, you should be able to use 
'--interpreter /bin/sh' to use the Borne shell instead of bash.

Does the -y switch also answer yes to importing the GPG key?  If not, 
you will need to import the key prior to running yum.