mirror of https://github.com/aredn/aredn.git
Remove need for /etc/config/services file (#1045)
This commit is contained in:
parent
509d475133
commit
b6dfba160e
|
@ -306,27 +306,19 @@ end
|
|||
-- Return locally hosted services (for sysinfo.json)
|
||||
-------------------------------------
|
||||
function model.local_services()
|
||||
local filelines={}
|
||||
local lclsrvs={}
|
||||
local lclsrvfile=io.open("/etc/config/services", "r")
|
||||
if lclsrvfile~=nil then
|
||||
for line in lclsrvfile:lines() do
|
||||
table.insert(filelines, line)
|
||||
require("aredn.services")
|
||||
local lclsrvs = {}
|
||||
local _, _, services = aredn.services.get()
|
||||
for _, service in ipairs(services)
|
||||
do
|
||||
local link, protocol, name = service:match("^([^|]*)|(.+)|([^\t]*).*")
|
||||
if link and protocol and name then
|
||||
table.insert(lclsrvs, {
|
||||
name = name,
|
||||
protocol = protocol,
|
||||
link = link
|
||||
})
|
||||
end
|
||||
lclsrvfile:close()
|
||||
for pos,val in pairs(filelines) do
|
||||
local service={}
|
||||
local link,protocol,name = string.match(val,"^([^|]*)|(.+)|([^\t]*).*")
|
||||
if link and protocol and name then
|
||||
service['name']=name
|
||||
service['protocol']=protocol
|
||||
service['link']=link
|
||||
table.insert(lclsrvs, service)
|
||||
end
|
||||
end
|
||||
else
|
||||
service['error']="Cannot read local services file"
|
||||
table.insert(lclsrvs, service)
|
||||
end
|
||||
return lclsrvs
|
||||
end
|
||||
|
|
|
@ -986,29 +986,6 @@ if nixio.fs.access("/etc/config.mesh/olsrd", "r") then
|
|||
end
|
||||
end
|
||||
|
||||
-- generate the services file
|
||||
local sf = io.open("/tmp/new_config/services", "w")
|
||||
if sf then
|
||||
if nixio.fs.access(servfile) then
|
||||
for line in io.lines(servfile)
|
||||
do
|
||||
if not (line:match("^%s*#") or line:match("^%s*$")) then
|
||||
local name, link, proto, host, port, sffx = line:match("(.*)|(.*)|(.*)|(.*)|(.*)|(.*)")
|
||||
if name and name ~= "" and host ~= "" then
|
||||
if proto == "" then
|
||||
proto = "http"
|
||||
end
|
||||
if link == "0" then
|
||||
port = "0"
|
||||
end
|
||||
sf:write(string.format("%s://%s:%s/%s|tcp|%s\n", proto, host, port, sffx, name))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
sf:close()
|
||||
end
|
||||
|
||||
-- Update user firewall
|
||||
local _, diff = filecopy("/etc/config.mesh/firewall.user", "/etc/firewall.user", true)
|
||||
if diff then
|
||||
|
|
Loading…
Reference in New Issue