fai-class

Langue: en

Version: 23 September 2009 (ubuntu - 24/10/10)

Section: 1 (Commandes utilisateur)

NAME

fai-class - define classes using files and scripts.

SYNOPSIS

fai-class [OPTION] DIRECTORY CLASSFILE

DESCRIPTION

fai-class executes scripts in DIRECTORY to define classes. All classes are written to CLASSFILE, each class on a separate line. Use absolute paths for both arguments. All scripts or executables matching "[0-9][0-9]*" are executed in alphabetical order. They can define classes by writing the names of the classes to stdout. Classes can be separated by spaces or written one on a line. All lines that start with a "#" are comment lines and are ignored.

Shell scripts that end in ".source" are sourced and can define classes by setting the variable $newclasses. This is useful for scripts where you can't control stdout. Variables that are defined in these scripts are available to other scripts in DIRECTORY, but they are not exported to the shell that calls fai-class. Those scripts can define variables by writing definitions to the file $LOGDIR/additional.var, which will be sourced in the following task.

All scripts can define additional classes by writing the classes to the file $LOGDIR/additional-classes. These classes are defined after all scripts are executed. This temporary file will be removed after use.

The order of the classes is important because it defines the priority of the classes from low to high. First, the class DEFAULT is defined. Then all scripts are executed to define classes. After that, the classes from the file $LOGDIR/additional-classes are added. Then, all classes in the file with the hostname are added. Then classes defined by the variable ADDCLASSES are used. This variable must be a comma separated list of classes. You can define this variable on the kernel command line.

Finally, the class with the hostname and LAST are defined.

It's important that each line in a file containg a class name ends with a newline. If the newline is missing on the last line of a file, this class can't be added.

The exit code of every script is written to the file status.log in LOGDIR.

OPTIONS

-d
Create debugging output.
-h
Show help, version and summary of options.
-T
Test if classes in CLASSFILE are defined multiple times. This should never happen. The test is executed after the classes are defined.
-t tmpdir
The file additional-classes is read from the directory tmpdir. Default value is /tmp/fai/.
-v
Create verbose output.

EXAMPLES


In FAI, fai-class is used in the following way:


   # fai-class /fai/class /tmp/fai/FAI_CLASSES

Then a list of all classes is defined in a shell script using the following command:


    classes=`cat /tmp/fai/FAI_CLASSES`

EXAMPLES FOR SCRIPTS

 
 This is the script 01alias:
 
 #! /bin/sh
 
 catnc() { # cat but no comment lines
     grep -v "^#" $1
 }
 # echo architecture in upper case
 dpkg --print-installation-architecture | tr /a-z/ /A-Z/
 uname -s | tr /a-z/ /A-Z/
 
 # all hosts named ant?? use the classes in file anthill
 case $HOSTNAME in
     ant??) catnc anthill ;;
 esac
 
 # a Beowulf cluster; all nodes except the master node
 # use classes from file class/atoms
 case $HOSTNAME in
     atom00) echo BEOWULF_MASTER ;;
     atom??) catnc atoms ;;
 esac
 
 # if host belongs to class C subnet 123.45.6.0 use class NET_6
 case $IPADDR in
     123.45.6.*) echo NET_6 ;;
 esac
 
 
 Another EXAMPLE:
 
 The script 24nis:
 
 #! /bin/sh
 
 # add NIS and the NIS domain name if YPDOMAIN is defined
 
 if [ -n "$YPDOMAIN" ];then
    echo "NIS $YPDOMAIN" | tr /.a-z-/ /_A-Z_/
 else
    echo NONIS
 fi
 
 


You can define classes on the kernel command line by appening this to the kernel:


   ADDCLASSES=CLASS1,CLASSX,CLASS3

NOTES

All class names should be written in uppercase letters (execpt the class of the hostname). Do not use a dash, use an underscore. Only executable scripts in DIRECTORY are used. CLASSFILE is removed before writing to it. Scripts should not directly write to CLASSFILE. LOGDIR should not be writable for everybody.

SEE ALSO


This program is part of FAI (Fully Automatic Installation). The FAI homepage is http://fai-project.org.

AUTHOR

Written by Thomas Lange <lange@informatik.uni-koeln.de>