diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-10-20 00:34:33 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-10-20 00:34:33 +0000 |
commit | 02cb94968c5d8f3c85ca797aa12cf70c9110fb63 (patch) | |
tree | 66396a092724e9098b967bd732a251ba7b135f97 | |
parent | 3db77af821ca734d1b8dc72cc7bef25be056ad9c (diff) | |
download | acf-mdadm-02cb94968c5d8f3c85ca797aa12cf70c9110fb63.tar.bz2 acf-mdadm-02cb94968c5d8f3c85ca797aa12cf70c9110fb63.tar.xz |
Remove all calls to 'module' in preparation for move to Lua 5.2
Use mymodule parameter for module definition.
This was also helpful in revealing places where the code relied on the global environment.
-rw-r--r-- | mdadm-controller.lua | 14 | ||||
-rw-r--r-- | mdadm-model.lua | 20 |
2 files changed, 18 insertions, 16 deletions
diff --git a/mdadm-controller.lua b/mdadm-controller.lua index 88e6de3..044cf96 100644 --- a/mdadm-controller.lua +++ b/mdadm-controller.lua @@ -1,19 +1,21 @@ -module(..., package.seeall) +local mymodule = {} -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 expert(self) +function mymodule.expert(self) return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit MDADM Config", "Configuration Set") end + +return mymodule diff --git a/mdadm-model.lua b/mdadm-model.lua index 44183c4..c3af970 100644 --- a/mdadm-model.lua +++ b/mdadm-model.lua @@ -1,4 +1,4 @@ -module(..., package.seeall) +local mymodule = {} -- Load libraries modelfunctions = require("modelfunctions") @@ -10,34 +10,34 @@ local configfile = "/etc/mdadm.conf" local processname = "mdadm-raid" local packagename = "mdadm" -local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin " - -- ################################################################################ -- LOCAL FUNCTIONS -- ################################################################################ -- PUBLIC FUNCTIONS -function get_startstop(self, clientdata) +function mymodule.get_startstop(self, clientdata) return modelfunctions.get_startstop(processname) - end +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, "MDADM Status") end -function getstatusdetails() +function mymodule.getstatusdetails() return cfe({ type="longtext", value=fs.read_file("/proc/mdstat") or "", label="MDADM Status Details" }) end -function get_filedetails() +function mymodule.get_filedetails() return modelfunctions.getfiledetails(configfile) end -function update_filedetails(self, filedetails) +function mymodule.update_filedetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, {configfile}) end + +return mymodule |