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
|
return count
|
||||||
end
|
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 = {}
|
array = {}
|
||||||
|
|
||||||
|
@ -117,16 +125,19 @@ for key,value in pairs(array) do
|
||||||
local mac = key
|
local mac = key
|
||||||
local ip = value["ip"]
|
local ip = value["ip"]
|
||||||
local hostname = value["hostname"]
|
local hostname = value["hostname"]
|
||||||
if hostname ~= "?" then
|
if hostname ~= "?" and hostname ~= "*" then
|
||||||
for key,value in pairs(ip) do
|
for key,value in pairs(ip) do
|
||||||
if non_fqdn then config = config .. "\r\n" .. value .. " " .. hostname end
|
line = value
|
||||||
if network_domain then config = config .. "\r\n" .. value .. " " .. hostname .. "." .. network_domain end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
file = io.open(output_file, "w")
|
if read_file(output_file) ~= config then
|
||||||
file:write(config)
|
file = io.open(output_file, "w")
|
||||||
file:close()
|
file:write(config)
|
||||||
|
file:close()
|
||||||
os.execute(reload_command)
|
os.execute(reload_command)
|
||||||
|
end
|
Loading…
Reference in a new issue