I am currently working on a new project. It is just an idea, and let's see how far it goes: you all know about the diversity of configuration files in Unix, it seems that every program has its own syntax. This makes it difficult to write configuration editors for web interfaces or GUI configuration editors.I do not think that much can be done about it, it is nearly impossible to convert each program's configuration file to a single, unified format. But still, most, if not all have one thing in common: they can be represented as trees, with the values as its leaves. See eg. /etc/network/interfaces. If it looks like:
iface eth0 inet static address 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.254
this can be represented in a tree:
iface eth0 family 'inet' method 'static' address '192.168.1.1' gateway '192.168.1.254'
So we could write a parser that reads a conf file and represents it internally as a tree. Each entry can than be accessed in a file system like manner, eg. the address of eth0 with
The same can be done with other conf files, eg, XF86Config-4, dhcpd.conf etc. What we then need is a common way to access and modify the tree. This can be simple commands that are called from shell scripts or functions in for example C. To get the address of eth0 in a shell script, we could write:
cnf ifupdown get iface/eth0/addressAnd the same for XFree86, for example to get the device file for the mouse:
cnf xfree86 get InputDevice/DeviceIn the latter example, we may have ambiguities, I have two mouse devices. So a real script would have to check the Identifier.
So this way it is possible for shell scripts to get the IP address or other values for an interface easily, and different configuration editors can rely on a unified library to access and modify data.
Of course, this approach does not make it easy as pie: it is still necessary to write a parser, and to change values, also an 'unparser' that writes the data back, without loosing any changes that are not understood, and if possible, also any comments that have been made in the fille. That's why I do not know yet how far this project will get.