summaryrefslogtreecommitdiffstats
path: root/unbound-model.lua
blob: 1743f723c25da18c96050030db5aeb45ab296c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
local mymodule = {}

-- Load libraries
modelfunctions = require("modelfunctions")
fs = require("acf.fs")
format = require("acf.format")

-- Set variables
local configfile = "/etc/unbound/unbound.conf"
local processname = "unbound"
local packagename = "unbound"

local config

-- ################################################################################
-- LOCAL FUNCTIONS

-- ################################################################################
-- PUBLIC FUNCTIONS

function mymodule.get_startstop(self, clientdata)
        return modelfunctions.get_startstop(processname)
end
	
function mymodule.startstop_service(self, startstop, action)
        return modelfunctions.startstop_service(startstop, action)
end

function mymodule.getstatus()
	return modelfunctions.getstatus(processname, packagename, "Unbound Status")
end

function mymodule.get_filedetails()
	return modelfunctions.getfiledetails(configfile)
end

function mymodule.update_filedetails(self, filedetails)
	return modelfunctions.setfiledetails(self, filedetails, {configfile})
end

function mymodule.get_logfile(f)
	-- Determine the log file from the config file
	-- TODO determine how best to parse the file
--[[
	config = config or format.parse_ini_file(fs.read_file(configfile) or "", "")
	local files = {}
	if config and config.logfile then
		files[#files+1] = {path = config.logfile}
	end
--]]
	if 0 == #files then
		files[#files+1] = {path = "/var/log/messages", grep = "unbound"}
	end
	return cfe({ value=files, label="Unbound Log Files" })
end

return mymodule