\section{Univention Configuration Registry in manually created packages}
\label{baseconfig_lokal}
Configuration files can also be integrated in the
\ucsUCR{} system when creating individual software packages for
use in UCS. The complete procedure for package creation in UCS is
documented separately (see \cite{univention-paketerstellung}). 

A subdirectory with the name \emph{conffiles} must be created in the
directory with the package sources. The configuration files and any
subdirectories are copied here. For example, if the file
\ucsURL{/etc/ldap/slapd.conf} should be managed by \ucsUCR{}, it is
copied to \ucsURL{conffiles/etc/ldap/slapd.conf}.

Wildcards can now be integrated into the configuration files in
\emph{conffiles} for the variables and any necessary Python code.

In any case default values for the variables used by the respective
binary package can be issued in \ucsURL{debian/postinst} or
\ucsURL{debian/<binarypackagename>.postinst} through certain settings (see
Chapter~\ref{neue_baseconfig}).

The line

\begin{ucsConfigFile}
univention-install-config-registry
\end{ucsConfigFile}

must be added in the \emph{install} section of the
\ucsName{debian/rules} file so that \ucsUCR{} is integrated when creating
the package.

In addition, the \ucsName{debian/control} file must be adapted, the
source package expanded with a dependency on
\ucsName{univention-config-dev} and all binary packages using
\ucsUCR{} expanded with a dependency on \ucsName{\ucsUCRb{}}.

Each binary package also requires a file called
\ucsURL{debian/<binarypackagename>.\ucsUCRb{}} to be created, in which is
must be specified which files and scripts are to be managed by
\ucsUCR{} and which variables are contained therein.

The syntax of the file can be seen in the following examples:

\begin{itemize}

\item Two configuration files and the variables used in them.
The assignment of variables to files can be omitted if no Python code
is used in the corresponding configuration file.

\begin{ucsConsoleInput}
# cat univention-dhcp.info
Type: file
File: etc/dhcp3/dhcpd.conf
Variables: ldap/base
Variables: dhcpd/ldap/base
Variables: ldap/server/name
Variables: dhcpd/enable

Type: file
File: etc/init.d/dhcp3-server
\end{ucsConsoleInput}

\item  Scripts can also be integrated in \ucsUCR{} alongside
  configuration files. These scripts can be run when certain variables
  are set. Scripts installed with packages are saved in
  \ucsURL{/etc/univention/templates/scripts}. Further scripts which
  should be created individually and then registered with \ucsUCR{}
  must also be copied in the directory. Additional scripts must also
  be entered in the \ucsUCR{} info files. They must be executable
  and also copied in the conffiles directory.

In the following example the \ucsURL{interfaces.sh} script is run when
the values of the \emph{interfaces/eth0/address} or
\emph{interfaces/eth0/network} variables  are changed:

\begin{ucsConfigFile}
Type: script
Script: interfaces.sh
Variables: interfaces/eth0/address
Variables: interfaces/eth0/network
\end{ucsConfigFile}

\item The following example shows a file (multifile), which is
  compiled from several individual files (subfile) if the value of a
  variable is changed. In this way, different packages can combine
  individual parts of a configuration file, which are thus merged.

\begin{ucsConfigFile}
Type: multifile
Multifile: etc/ldap/slapd.conf

Type: subfile
Multifile: etc/ldap/slapd.conf
Subfile: etc/ldap/slapd.conf.d/10schema-core
Variables: ldap/base

Type: subfile
Multifile: etc/ldap/slapd.conf
Subfile: etc/ldap/slapd.conf.d/20acl
Variables: ldap/base
\end{ucsConfigFile}

\end{itemize}

A multifile template must be created to generate a configuration file
from several templates. To do this a directory is created with a name
composed of the template name and the endung \emph{.d}. Several part
templates can be saved in this directory.

The file names of these part templates must begin with double-digit
figures, which determine the order according to which the parts will
be evaluated and merged. This is particularly useful if the individual
parts are from different packages, are to be managed or individual
expansions are to be integrated.

For example, \ucsURL{/etc/univention/templates/files/etc/} contains
the directory \ucsURL{config.d}. This contains the files
\ucsURL{00header}, \ucsURL{05base} and
\ucsURL{11extensions}. These are merged and evaluated by \ucsUCR{}
in ascending order according to their numerical prefix in order to
create the \ucsURL{/etc/config} file.

If the template (single or multifile) were created, they must be
registered before they can be used by \ucsUCR{} (see
Chapter~\ref{bc_include_config}).

\section{Including additional configuration files}
\label{bc_include_config}
Configuration files that do not originate from an installation package
can also be registered in \ucsUCR{}. The following description only
applies to configuration files which are not installed from a package.

Firstly, one or more template files must be created or adapted and
saved under the \ucsURL{/etc/univention/templates/files}
directory. The syntax and exact saving location of the template files
are described in Chapter \ref{baseconfig_registrierung}.

A file must be saved in the \ucsURL{/etc/univention/templates/info}
directory listing the configuration files used and the variables used
in them. The name of file can be chosen freely as long as it ends in
\emph{.info}. The syntax corresponds to the scheme named for the
\ucsURL{debian/<binarypackagename>.\ucsUCRb{}} file in
Chapter~\ref{baseconfig_lokal}.

The \ucsURL{/var/cache/univention-config/cache} cache file must then
be deleted. The additional configuration files are registered the next
time it is run. As soon as a \ucsUCR{} variable registered for this
file is changed or the command \ucsCommand{univention-config-registry
  commit} is executed for this file, a new configuration file is
created from the template file taking into account the \ucsUCR{}
variables.

