summaryrefslogtreecommitdiffstats
path: root/unbound-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2014-05-26 23:39:07 +0000
committerTed Trask <ttrask01@yahoo.com>2014-05-26 23:39:07 +0000
commit16ae49688035474711f4cc32d890ff4000bdee73 (patch)
treeb49927ab0309e1134f8158575b775772851ad41e /unbound-model.lua
downloadacf-unbound-16ae49688035474711f4cc32d890ff4000bdee73.tar.bz2
acf-unbound-16ae49688035474711f4cc32d890ff4000bdee73.tar.xz
Initial commit of Unbound ACFv0.0.1
Basic support for status / startstop / expert / logfile Logfile assumes syslog and does not yet read the config for logfile location
Diffstat (limited to 'unbound-model.lua')
-rw-r--r--unbound-model.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/unbound-model.lua b/unbound-model.lua
new file mode 100644
index 0000000..1743f72
--- /dev/null
+++ b/unbound-model.lua
@@ -0,0 +1,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