[main]     [download]    [examples]     [documentation]

Let try to explain how to use LUCI. First, a few definitions:

LUCI is a graphical editor for special text files used to define parameters used by programs knows as configuration files. Each configuration file contains entries, that is, lines with a parameter name and a corresponding value. To use LUCI, we have to write a small text file to describe the contents of the configuration file. These small files are called description files.

To use LUCI, type 'luci' followed by the name of your desc_file. If LUCI is run without arguments, it will try to read the directory /etc/luci to find all available description files, and will display the LUCI navigator.

The following short example shows how to write a simple description file:

Imagine you have a configuration file, /etc/conf (for example), with the following content:
# example of configuration file

The first line is a comment, and the second is a entry. The entry name is FOO, and its value is bar.

The description file for this configuration file will look like this:
config_file_name = '/etc/conf'
config_file_type = 'shell'
'name'          : 'Foo parameter',
'config_name'   : 'FOO'

In fact, description files are python code, but you don't have to know python to use LUCI.

Description files have global parameters that describe the entire configuration file, and individual entry parameters to describe each entry. In the above example, the first two lines are global parameters, and the remaining lines are entry parameters for the FOO parameter.

First, the global parameters:

The config_file_name parameter tells LUCI the location of the file to edit. The config_file_type defines the type of the configuration file. Our /etc/conf has a shell type. Each entry is of the following form: PARAMETER=value, and comments begin with a #, like in a shell script. You can use this type even if it's not a real shell script, as long as the entry format is valid.

Next, we have to describe the entry parameters:

First, we must give the entry an identification name, here foo. You can choose any string for the identification name, but it cannot begin with an underscore. The identification name is followed by a comma separated list of entry parameters between braces. name specifies the name that will appear in the LUCI window. The config_name line is the exact pattern LUCI will use to find the entry in the configuration file.

That's all! Now you can run LUCI. If you have named the description file desc, go in the directory where it is saved, and type:

luci desc

If all is OK, the following window will appear:

tutorial example

If you replace bar by another value and press OK, the configuration file will be changed to show the new value.

Now that you know the basics of creating LUCI configuration files, you can try to use it yourself on different configuration files. There are lots of other things you can do in the description file, such as different types of entry (string, integer, list...). You can also define your own configuration file format for a specific use.

This tutorial is very incomplete at the moment, but you can look at the reference documentation to see all the available parameters, and to the examples page to see how you can use them. You can also go to the Python home page if you want to put your own Python code in your description files.

Don't hesitate to mail me to give me feedback about LUCI.


Valid HTML