Updated DynDNS
Reload only if records changed
This commit is contained in:
parent
c851fdb165
commit
f1f1da4d5d
|
@ -66,6 +66,14 @@ function count(T)
|
|||
return count
|
||||
end
|
||||
|
||||
function read_file(path)
|
||||
local file = io.open(path, "rb")
|
||||
if not file then return nil end
|
||||
local content = file:read "*a"
|
||||
file:close()
|
||||
return content
|
||||
end
|
||||
|
||||
|
||||
array = {}
|
||||
|
||||
|
@ -117,16 +125,19 @@ for key,value in pairs(array) do
|
|||
local mac = key
|
||||
local ip = value["ip"]
|
||||
local hostname = value["hostname"]
|
||||
if hostname ~= "?" then
|
||||
if hostname ~= "?" and hostname ~= "*" then
|
||||
for key,value in pairs(ip) do
|
||||
if non_fqdn then config = config .. "\r\n" .. value .. " " .. hostname end
|
||||
if network_domain then config = config .. "\r\n" .. value .. " " .. hostname .. "." .. network_domain end
|
||||
line = value
|
||||
if non_fqdn then line = line .. " " .. hostname end
|
||||
if network_domain then line = line .. " " .. (hostname .. "." .. network_domain) end
|
||||
if line ~= value then config = config .. "\r\n" .. line end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
file = io.open(output_file, "w")
|
||||
file:write(config)
|
||||
file:close()
|
||||
|
||||
os.execute(reload_command)
|
||||
if read_file(output_file) ~= config then
|
||||
file = io.open(output_file, "w")
|
||||
file:write(config)
|
||||
file:close()
|
||||
os.execute(reload_command)
|
||||
end
|
Loading…
Reference in a new issue