Reworked Configuration Management

MidCOM 2.4 features a completly new configuration strategy, as already outlined in the article Unified MidCOM configuration system. In addition with this, the framework has been extended by a way to add system-specific configuration options and by two scripts to generate and check the MidCOM configuration.

Systemwide MidCOM configuration

MidCOM now supports a systemwide configuration file, located in /etc/midgard/midcom.conf. The configuration options in there are merged into the default configuration immediately before the site local configuration is merged into the configuartion store. The file must be valid PHP, and all configuration options must be stored into the array midcom_config_site. A full example is:

$GLOBALS['midcom_config_site']['cache_module_content_backend'] = 
Array ('driver' => 'dba', 'handler' => 'db4');
$GLOBALS['midcom_config_site']['cache_module_nap_backend'] =
Array ('driver' => 'dba', 'handler' => 'db4');
$GLOBALS['midcom_config_site']['utility_imagemagick_base'] =
'/usr/bin/';
$GLOBALS['midcom_config_site']['utility_find'] =
'/usr/bin/find';
$GLOBALS['midcom_config_site']['utility_file'] =
'/usr/bin/file';
$GLOBALS['midcom_config_site']['utility_unzip'] =
'/usr/bin/unzip';
$GLOBALS['midcom_config_site']['utility_gzip'] =
'/bin/gzip';
$GLOBALS['midcom_config_site']['utility_tar'] =
'/bin/tar';
$GLOBALS['midcom_config_site']['utility_jpegtran'] =
'/usr/bin/jpegtran';
$GLOBALS['midcom_config_site']['utility_jhead'] =
'/usr/bin/jhead';
$GLOBALS['midcom_config_site']['utility_catdoc'] =
'/usr/bin/catdoc';
$GLOBALS['midcom_config_site']['utility_pdftotext'] =
'/usr/bin/pdftotext';
$GLOBALS['midcom_config_site']['utility_unrtf'] =
'/usr/bin/unrtf';
$GLOBALS['midcom_config_site']['cache_base_directory'] =
'/var/cache/midcom/';
$GLOBALS['midcom_config_site']['indexer_backend'] = 'xmltcp';
?>

This is very useful in combination with the autoconf script outlined below as it allows you to set all relevant utility locations at a central place.

Automatic generation of configuration files

MidCOM now provides a first step in automated configuration detection. In the support directory of MidCOM there is a file named autoconf.php. When executed, it checks for all required external utilities and configuration options. It also allows you to write the detected configuration into a file suitable for usage with /etc/midgard/midcom.conf. A sample output can be found in the file autoconf-output.txt attached to this article.

You normally execute it like this:

$ php autoconf.php [ output filename ]

If the output filename is specified, the detected configuration will be written to the file specified, enclosed in php tags. Since this file will be silently overwritten it is recommended to write it in a file separate of midcom.conf and include it from there:

$ php autoconf.php /etc/midgard/midcom_autoconf.inc

In the midcom.conf file you then write something like include('midcom_autoconf.inc'). This way you can safely overwrite the autoconf detected files.

Be aware that the autoconf script requires the utility which available in the current $PATH. If the command which which doesn't work, the script will terminate with a fatal error.

A note for Debian users

Debian has separate configuration files for command-line and web-Apache, therefore you need to start the autoconf script with the right configuration file:

$ php -c /etc/php4/apache/php.ini autoconf.php

Validating the configuration of an existing MidCOM site

This is the last goodie on the configuration front. On any existing MidCOM site you can call the a config-test script using the URL schema http://path.to.midcom.host/midcom-exec-midcom/config-test.php. It will run a series of tests in the current environment to verify the operational state of MidCOM.

Even though it is a rather basic script yet (it does not test version numbers of external helper utilities), it should be a great help in detecting missing utillites or wrong configuration settings. The following image is a screenshot of its output:

BLOB Preview

Downloads

File Size Last modified
autoconf-output.txt 2.086 Byte 2005-05-24