How to conditionally define a class? (ex. Xorg configuration)

Tim Cutts tjrc at sanger.ac.uk
Thu Jan 21 20:18:02 CET 2010


On 21 Jan 2010, at 4:53 pm, Thomas Lange wrote:

>>>>>> On Thu, 21 Jan 2010 17:34:44 +0100, Peter Bittner <peter.bittner at thalesgroup.com 
>>>>>> > said:
>
>> (Probably the solution to this is simple, I haven't just figured it  
>> out,
>> sorry...)
>
>> Now the question is: Instead of running apt-get as above, how can I
>> define the class XORG_ATI dynamically at installation time (if and  
>> only
>> if the XORG class is defined!) in order to install the software  
>> packages
>> listed in var/lib/fai/config/package_config/XORG_ATI ?
>
> Create a script class/99-radeon:
>
> #! /bin/bash
>
> # skip if class XORG is not defined
> grep -q XORG $FAI/class && exit 0
>
> ATI_RADEON_ID=$(lspci | grep VGA | grep ATI | grep Radeon)
> [ "$ATI_RADEON_ID" != "" ] && echo XORG_ATI
>
>
> But the class XORG has to be defined before this script get executed.
> Hope this helps.

We do something similar, but more generic.  We have a perl script  
which runs both lspci and dmidecode, parses the output and sets a lot  
of classes depending on what it finds (manufacturer, machine model  
number, fibrechannel controllers, graphics cards, etc etc)

Tim


More information about the linux-fai mailing list