fai-class(1)

πŸ“¦
version 6.6ubuntu1 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– fai-class β€” the manual page, but make it make sense πŸ’–

okay so this is fai-class, from section 1 of the manual pages, and honestly? she's an internal queen. sit down bestie, we're gonna go through the whole thing. πŸŽ€


✨ NAME ✨

fai-class β€” define classes using files and scripts. that's the whole vibe. classes, defined, by files and scripts. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

fai-class [OPTION] DIRECTORY CLASSFILE

two arguments, no cap. DIRECTORY and CLASSFILE, in that order, with optional flags out front. 🫢

🌸 DESCRIPTION 🌸

okay first thing, important, don't get it twisted: this command is only called internally by FAI and not directly by the user. so if you're out here running it by hand, you're doing main character stuff but not the intended stuff. πŸ™ˆ

fai-class runs the scripts in DIRECTORY to define classes. every class it finds gets written out to CLASSFILE, and each class gets its own separate line. use absolute paths for both of those arguments, fr fr, relative paths are not it.

every script or executable that matches ^[0-9][0-9]* β€” meaning it starts with two digits β€” gets executed, and they run in alphabetical order. they define classes by writing the class names to stdout. classes can be separated by spaces, or you can put one per line, either slaps. and all lines starting with a "#" are comment lines and get ignored. periodt.

shell scripts ending in .sh are sourced, which means they can define classes by setting the variable $newclasses β€” so useful for scripts where you literally cannot control stdout, iykyk. any variables defined inside those scripts are available to the other scripts in DIRECTORY, but heads up, they are not exported to the shell that called fai-class. if those scripts wanna define variables, they can write the definitions to the file $LOGDIR/additional.var, which will get sourced in the following task. πŸ’«

all scripts can define extra classes by writing them to the file $LOGDIR/additional-classes. those classes get defined after all the scripts are executed. and that temporary file gets removed after use β€” it's giving one-time-use energy. 🧚


now the order, because bestie the order is everything β€” it sets the priority of the classes from low to high:

  1. first, the class DEFAULT is defined.
  2. then all the scripts are executed to define classes.
  3. after that, the classes from the file $LOGDIR/additional-classes are added.
  4. subsequently, all the classes in the file with the hostname are added.
  5. finally, classes defined by the variable ADDCLASSES are used. that variable must be a comma separated list of classes, and yes you can define it on the kernel command line. πŸ‘‘

and finally finally: the class with the hostname and LAST are defined.

⚠️ okay this one is a real one: every line in a file containing a class name must end with a newline. if the newline is missing on the last line of a file, that class can't be added. no newline, no class. that's the rule. πŸ’€

lastly, the exit code of every single script gets written to the file status.log in LOGDIR. receipts kept. πŸ“

πŸ’… OPTIONS πŸ’…

  • -d β€” create debugging output. spill the tea about what's happening. πŸ›
  • -h β€” show help, version and a summary of the options. the classic "wait what does this do again" button. πŸ™‹
  • -T β€” test if classes in CLASSFILE are defined multiple times. this should never happen bestie, it's a vibe check. the test runs 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. she's chatty and we love that. πŸ—£οΈ

🌈 EXAMPLES 🌈

in FAI, fai-class gets used like this:

# 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`

and that's it, that's the whole flow. iconic. ⭐

🧚 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-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

and you can define classes on the kernel command line by appending this to the kernel:

ADDCLASSES=CLASS1,CLASSX,CLASS3

kernel command line class injection, we love a sneaky little shortcut. πŸ“

πŸŽ€ NOTES πŸŽ€

  • all class names should be written in uppercase letters β€” except the class of the hostname, she's special.
  • do not use a dash, use an underscore. dashes are not invited to this party. 🚫
  • only executable scripts in DIRECTORY are used.
  • CLASSFILE is removed before writing to it.
  • scripts should not directly write to CLASSFILE. don't do it. hands off. πŸ™…
  • LOGDIR should not be writable for everybody. lock that down, bestie. πŸ”’

🫢 SEE ALSO 🫢

this program is part of FAI (Fully Automatic Installation). the FAI homepage is http://fai-project.org. go say hi. 🌐

πŸ‘‘ AUTHOR πŸ‘‘

written by Thomas Lange <lange@cs.uni-koeln.de>. the original icon, we stan. πŸ’œ


and that's the whole page, bestie!! this one is from FAI 4, dated 23 September 2015 β€” a certified classic, still slaying. go define some classes. mwah. πŸ˜­πŸ’–