3.2 Configuration Basics

The configuration file defines most parameters needed for the normal operation of slb. The program will not start if its configuration file does not exist, cannot be read, or contains some errors.

The configuration file is located in your system configuration directory (normally ‘/etc’) and is named ‘slb.conf’. You can place it elsewhere as well, but in this case you will need to explicitly inform slb about its actual location, using the ‘--config-file’ (‘-c’) command line option:

 
slb --config-file ./new.conf

Before actually starting the program, it is wise to check the configuration file for errors. To do so, use the ‘--lint’ (‘-t’) command line option:

 
slb --lint

When started with this option, slb parses the configuration, reports any errors on the standard error and exits. If parsing succeeds, it exits with code 0. Otherwise, if any errors have been found, it exits with code 78 (configuration error).

The ‘--lint’ option can, of course, be used together with ‘--config-file’, e.g.:

 
slb --lint --config-file ./new.conf

If you are unsure about the correct configuration syntax, you can obtain a concise summary any time, by running:

 
slb --config-help

The summary is printed to the standard output and includes all configuration statements with short descriptions of their purpose and arguments.

In this section we will provide a quick start introduction to the slb configuration. For a more detailed and formal discussion, refer to SLB Configuration File.

The configuration file consists of statements. There are two kinds of statements, called simple and block statements. A simple statement consists of a keyword and value, or values, separated by any amount of whitespace and terminated with a semicolon, for example:

 
wakeup 15;

A block statement is used for logical grouping of other statements. It consists of a keyword, optionally followed by a value, and a set of other statements, enclosed in a pair of curly brackets. For example:

 
syslog {
  facility local1;
  tag slb;
}

A semicolon may follow the closing ‘}’, although this is not required.

Note that whitespace (i.e. space characters, tabs and newlines) has no special syntactical meaning, except that it serves to separate otherwise adjacent tokens. For example, the following form of the ‘syslog’ statement is entirely equivalent to the one shown above:

 
syslog { facility local1;   tag  slb; }

Several types of comments are supported. A single-line comment starts with ‘#’ or ‘//’ and continues to the end of the line. A multi-line or C-style comment starts with the two characters ‘/*’ (slash, star) and continues until the first occurrence of ‘*/’ (star, slash). Whatever comment type are used, they are removed from the configuration prior to parsing it.

After comment removal, the configuration is preprocessed using m4. This is a highly useful feature, which allows for considerable simplification of configuration files. It is described in Preprocessing with m4.