mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 10:41:34 +00:00
Merge custom KEA configuration extension with generated configuration
This commit is contained in:
parent
1140cfa9fe
commit
76d5f05a23
1 changed files with 19 additions and 0 deletions
|
|
@ -5,6 +5,8 @@
|
|||
local sys_utils = require "sys_utils"
|
||||
local json = require "dkjson"
|
||||
|
||||
local KEA_CONF_EXT_PATH = "/etc/ntopng/kea-dhcp4-ext.conf"
|
||||
|
||||
local kea_dhcp_server = {}
|
||||
kea_dhcp_server.service_name = "kea-dhcp4-server"
|
||||
|
||||
|
|
@ -184,6 +186,23 @@ function kea_dhcp_server.writeDhcpServerConfiguration(dhcp_config, all_interface
|
|||
end
|
||||
end
|
||||
|
||||
-- Check for external configuration file and merge if present
|
||||
local ext_config_f = sys_utils.openFile(KEA_CONF_EXT_PATH, "r")
|
||||
if ext_config_f then
|
||||
local ext_config_json = ext_config_f:read("*all")
|
||||
ext_config_f:close()
|
||||
|
||||
if not isEmptyString(ext_config_json) then
|
||||
local ext_config, pos, err = json.decode(ext_config_json)
|
||||
if ext_config then
|
||||
-- Merge external configuration with generated configuration
|
||||
kea_config = table.merge(kea_config, ext_config)
|
||||
else
|
||||
traceError(TRACE_WARNING, TRACE_CONSOLE, "Failed to parse " .. KEA_CONF_EXT_PATH .. ": " .. (err or "unknown error"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Write the Kea DHCP4 configuration file in JSON format
|
||||
local f = sys_utils.openFile("/etc/kea/kea-dhcp4.conf", "w")
|
||||
if not f then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue