~vcs-imports/fai/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
.\" Hey, EMACS: -*- nroff -*-
.\" Please adjust this date whenever revising the manpage.
.\" 
.\" Some roff macros, for reference:
.\" .nh        disable hyphenation
.\" .hy        enable hyphenation
.\" .ad l      left justify
.\" .ad b      justify to both left and right margins
.\" .nf        disable filling
.\" .fi        enable filling
.\" .br        insert line break
.\" .sp <n>    insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.TH "fai-class" "1" "4 October 2011" "FAI 4" ""
.SH "NAME"
fai\-class \- define classes using files and scripts.
.SH "SYNOPSIS"
.B fai\-class
.RI [OPTION] " DIRECTORY CLASSFILE"
.SH "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.

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


.SH "EXAMPLES"
.br 
In FAI, fai\-class is used in the following way: 

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

Then the list of all classes is assigned to the variable classes.

    classes=`cat /tmp/fai/FAI_CLASSES`

.SH "EXAMPLES FOR SCRIPTS"
.ta 40n
.sp
.nf 

This is the script 01alias:

#! /bin/sh

catnc() { # cat but no comment lines
    grep \-v "^#" $1
}
# echo architecture in upper case
dpkg \-\-print\-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
.sp
.fi 
.PP 
.br 
You can define classes on the kernel command line by appening this to
the kernel:

   ADDCLASSES=CLASS1,CLASSX,CLASS3

.SH "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.

.SH "SEE ALSO"
.br 
This program is part of FAI (Fully Automatic Installation). The FAI
homepage is http://fai\-project.org.

.SH "AUTHOR"
Written by Thomas Lange <lange@informatik.uni\-koeln.de>