summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--postgresql-controller.lua21
-rw-r--r--postgresql-model.lua20
2 files changed, 23 insertions, 18 deletions
diff --git a/postgresql-controller.lua b/postgresql-controller.lua
index c1af2c5..2a61370 100644
--- a/postgresql-controller.lua
+++ b/postgresql-controller.lua
@@ -1,28 +1,31 @@
-module(..., package.seeall)
+local mymodule = {}
-mvc = {}
-mvc.on_load = function(self, parent)
+-- Use on_load function to handle multiple instances of this ACF (i.e. postgresql2)
+mymodule.mvc = {}
+mymodule.mvc.on_load = function(self, parent)
self.model.set_processname(string.match(self.conf.prefix, "[^/]+"))
end
-default_action = "status"
+mymodule.default_action = "status"
-function status(self)
+function mymodule.status(self)
return self.model.getstatus()
end
-function startstop(self)
+function mymodule.startstop(self)
return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata)
end
-function details(self)
+function mymodule.details(self)
return self.model.getstatusdetails()
end
-function listfiles(self)
+function mymodule.listfiles(self)
return self.model.getfilelist()
end
-function expert(self)
+function mymodule.expert(self)
return self.handle_form(self, function() return self.model.getfiledetails(self.clientdata.filename) end, self.model.updatefiledetails, self.clientdata, "Save", "Edit Postgresql File", "File Saved")
end
+
+return mymodule
diff --git a/postgresql-model.lua b/postgresql-model.lua
index 1c492f3..efb86d4 100644
--- a/postgresql-model.lua
+++ b/postgresql-model.lua
@@ -1,4 +1,4 @@
-module(..., package.seeall)
+local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
@@ -15,7 +15,7 @@ local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
local datadirectory
local filelist
-function set_processname(p)
+function mymodule.set_processname(p)
processname = p
confdfile = "/etc/conf.d/"..processname
end
@@ -34,23 +34,23 @@ 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, "Postgresql Status")
end
-function getstatusdetails()
+function mymodule.getstatusdetails()
return cfe({ type="longtext", value="", label="Postgresql Status Details" })
end
-function getfilelist()
+function mymodule.getfilelist()
local listed_files = {}
for i,name in ipairs(determinefilelist()) do
@@ -63,10 +63,12 @@ function getfilelist()
return cfe({ type="list", value=listed_files, label="Postgresql File List" })
end
-function getfiledetails(filename)
+function mymodule.getfiledetails(filename)
return modelfunctions.getfiledetails(filename, determinefilelist())
end
-function updatefiledetails(self, filedetails)
+function mymodule.updatefiledetails(self, filedetails)
return modelfunctions.setfiledetails(self, filedetails, determinefilelist())
end
+
+return mymodule