From 3a3ff6452f6a59a0af47587174ecd2bcfe9c1219 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 26 May 2014 22:37:03 +0000 Subject: Added capability to read logfiles from config. --- dovecot-controller.lua | 4 ++++ dovecot-logfile-html.lsp | 4 +++- dovecot-model.lua | 20 +++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dovecot-controller.lua b/dovecot-controller.lua index 32f42b8..de36937 100644 --- a/dovecot-controller.lua +++ b/dovecot-controller.lua @@ -18,4 +18,8 @@ function mymodule.expert(self) return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Dovecot Config", "Configuration Set") end +function mymodule.logfile(self) + return self.model.get_logfile() +end + return mymodule diff --git a/dovecot-logfile-html.lsp b/dovecot-logfile-html.lsp index 53a76ce..d718396 100644 --- a/dovecot-logfile-html.lsp +++ b/dovecot-logfile-html.lsp @@ -2,5 +2,7 @@ %> <% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename="/var/log/messages", grep="dovecot"}) + for i,logfile in ipairs(data.value) do + viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename=logfile.path, grep=logfile.grep}) + end end %> diff --git a/dovecot-model.lua b/dovecot-model.lua index 25393e0..74aff69 100644 --- a/dovecot-model.lua +++ b/dovecot-model.lua @@ -10,7 +10,7 @@ local configfile = "/etc/dovecot/dovecot.conf" local processname = "dovecot" local packagename = "dovecot" -local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin " +local config -- ################################################################################ -- LOCAL FUNCTIONS @@ -42,4 +42,22 @@ function mymodule.update_filedetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, {configfile}) end +function mymodule.get_logfile(f) + config = config or format.parse_ini_file(fs.read_file(configfile) or "", "") + local files = {} + if config and config.log_path then + files[#files+1] = {path = config.log_path} + end + if config and config.info_log_path then + files[#files+1] = {path = config.info_log_path} + end + if config and config.log_path then + files[#files+1] = {path = config.debug_log_path} + end + if 0 == #files then + files[#files+1] = {path = "/var/log/messages", grep = "dovecot"} + end + return cfe({ value=files, label="DoveCot Log Files" }) +end + return mymodule -- cgit v1.2.3