Remove need for /etc/config/services file (#1045)

This commit is contained in:
Tim Wilkinson 2023-12-27 14:39:17 -08:00 committed by GitHub
parent 509d475133
commit b6dfba160e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 43 deletions

View File

@ -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

View File

@ -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