Lua is a simple yet powerful scripting language (see http://www.lua.org). Most functions in which LiveConfig interacts with other programs or generates configuration files are programmed in Lua. These scripts are in source code, so customization to specific requirements is quite easy.
The Lua programs are located in /usr/lib/liveconfig/lua/
(respectively <library_path>/lua/
- see library_path
), both with the LiveConfig server as well as the LiveConfig client (lcclient).
When LiveConfig starts, multiple threads for system management are started. Each of these threads contains its own Lua environment. Each Lua environment first loads its internal libraries (like LC.expect
, LC.sys
, and so on), then the main script liveconfig.lua
is run. This loads all other Lua modules (LC.web
, LC.dns
etc.), all files in /etc/liveconfig/lua.d/*.lua
and finally a file called custom.lua
(if existing).
If you need to modify Lua functions, it is strongly recommended to not directly modify an existing Lua script, as this will be overwritten with the next LiveConfig update. Instead, create a file called custom.lua
(at /usr/lib/liveconfig/lua
or at /etc/liveconfig/lua.d/
).
Important
After changes to the custom.lua
file or any other Lua script, LiveConfig must be restarted for the changes to take effect.
Caution
If you make any modification on the Lua programs (also by creating a custom.lua
), we take no responsibility for any errors.
Please check your own functions carefully before using them in production!
For testing of custom Lua scripts you can use lclua
(installed with LiveConfig, usually at /usr/lib/liveconfig/lclua
). This Lua interpreter contains all Lua modules from LiveConfig.
For example, if you want to customize the detection of the Linux distribution, the custom.lua
file might look like this:
-- introduce namespace "MY":
MY = { }
-- keep original function "LC.distribution.detect"
MY.orig_detect = LC.distribution.detect
-- redirect function for distribution detection:
function LC.distribution.detect()
if (LC.fs.is_file("/etc/exampLinux")) then
-- we have an "ExampleLinux"...
LC.distribution.name = "ExampLinux"
LC.distribution.codename = "example"
LC.distribution.family = "Debian"
LC.distribution.version = "1.0"
LC.distribution.description = "Example Linux 1.0 (example)"
return true
else
-- call original function for distribution detection:
return MY.orig_detect()
end
end
The following modules are provided by LiveConfig: