diff options
Diffstat (limited to 'postfix-model.lua')
-rw-r--r-- | postfix-model.lua | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/postfix-model.lua b/postfix-model.lua index 2b01b35..06436e5 100644 --- a/postfix-model.lua +++ b/postfix-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -34,19 +34,19 @@ end -- ################################################################################ -- PUBLIC FUNCTIONS -function get_startstop(self, clientdata) +function mymodule.get_startstop(self, clientdata) return modelfunctions.get_startstop(processname) end -function startstop_service(self, startstop, action) +function mymodule.startstop_service(self, startstop, action) return modelfunctions.startstop_service(startstop, action) end -function getstatus() +function mymodule.getstatus() return modelfunctions.getstatus(processname, packagename, "Postfix Status") end -function getstatusdetails() +function mymodule.getstatusdetails() return cfe({ type="longtext", value="", label="Postfix Status Details" }) end @@ -62,7 +62,7 @@ local function geteditablefilelist() return result end -function getfilelist() +function mymodule.getfilelist() local listed_files = {} for i,name in ipairs(geteditablefilelist()) do @@ -75,21 +75,21 @@ function getfilelist() return cfe({ type="list", value=listed_files, label="Postfix File List" }) end -function getfiledetails(filename) +function mymodule.getfiledetails(filename) return modelfunctions.getfiledetails(filename, geteditablefilelist()) end -function updatefiledetails(self, filedetails) +function mymodule.updatefiledetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, geteditablefilelist()) end -function getnewfile() +function mymodule.getnewfile() local options = {} options.filename = cfe({ label="File Name" }) return cfe({ type="group", value=options, label="New File" }) end -function createfile(self, newfile) +function mymodule.createfile(self, newfile) newfile.errtxt = "Failed to create file" local path = string.match(newfile.value.filename.value, "^%s*(.*%S)%s*$") or "" if not string.find(path, "/") then @@ -111,13 +111,13 @@ function createfile(self, newfile) return newfile end -function getdeletefile(self, clientdata) +function mymodule.getdeletefile(self, clientdata) local retval = {} retval.filename = cfe({ value=clientdata.filename or "", label="File Name" }) return cfe({ type="group", value=retval, label="Delete File" }) end -function deletefile(self, delfile) +function mymodule.deletefile(self, delfile) local filename = delfile.value.filename.value delfile.errtxt = "Failed to delete file" if not validator.is_valid_filename(filename, baseurl) then @@ -131,12 +131,12 @@ function deletefile(self, delfile) return delfile end -function get_rebuild_databases() +function mymodule.get_rebuild_databases() local retval = {} return cfe({ type="group", value=retval, label="Rebuild Databases" }) end -function rebuild_databases(self, rebuild) +function mymodule.rebuild_databases(self, rebuild) local result = {"Rebuilding databases"} local errresult = false local cmd,f,cmdresult,errtxt @@ -174,18 +174,20 @@ function rebuild_databases(self, rebuild) return rebuild end -function getmailqueue() +function mymodule.getmailqueue() local result, errtxt = modelfunctions.run_executable({"mailq"}) return cfe({ type="longtext", value=result, label="Postfix Mail Queue", errtxt=errtxt }) end -function getflushqueue() +function mymodule.getflushqueue() local retval = {} return cfe({ type="group", value=retval, label="Flush Queue" }) end -function flushqueue(self, flush) +function mymodule.flushqueue(self, flush) flush.descr, flush.errtxt = modelfunctions.run_executable({"postqueue", "-f"}) if not flush.errtxt and flush.descr == "" then flush.descr = "Queue Flushed" end return flush end + +return mymodule |