Tutorial

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


Let try to explain how to use LUCI. First, a few definitions:
LUCI is a soft to edit some text files used to define parameters used by misc. programs. These are configuration files. Each configuration file contains entries, that is, lines with a parameter name and an corresponding value. To use LUCI, we have to write a little text file to describe what there is in the configuration file, we will call this files description files.

Now, we will see on a short example, how to write the description file. Imagine you have a configuration file, /etc/conf for example, with the following content:
#example of configuration file 

FOO=bar

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' 

foo={ 
'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 whole configuration file, and entry parameters, for each entry. The first two lines are global, and the other ones are the entry parameters for the FOO parameter.
The config_file_name parameter tells LUCI where is the file to edit. The config_file_type defines what is 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.
That's all for the global parameters.
Next, we have to describe the entry. We must give it a identification name, here foo. You can choose every string for the identification name, but it cannot begin with an underscore. Then follows a comma separated list of entry parameters between braces. name specifies the name that will appear in the LUCI window. The config_name line tells LUCI what is the name of the entry in the configuration file.
And that's all. Now you can run LUCI. If you have named the description file desc, go in the directory when it is saved, and type:
luci desc
If all is OK, the following window will appear:

If  you replace bar by an other value and press OK, the configuration file will be changed with the new value.

Now that you know the basic use of LUCI, you can try to use it on different configuration files. There is lots of other things you can do in the description file, like different kinds of entry (string, integer, list...). You can also define your own configuration file format for specific use. This tutorial is very incomplete for 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.

Jérôme.