summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-10-20 00:39:12 +0000
committerTed Trask <ttrask01@yahoo.com>2013-10-20 00:39:12 +0000
commit34bae88186d493a274569a8a2f510a9ee85ec134 (patch)
tree753aff4eb72e17d1df334ea8557143f915816c2f
parent801ff66ed8f97603056698f8e8349dcb716665a3 (diff)
downloadacf-openntpd-34bae88186d493a274569a8a2f510a9ee85ec134.tar.bz2
acf-openntpd-34bae88186d493a274569a8a2f510a9ee85ec134.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--openntpd-controller.lua16
-rw-r--r--openntpd-model.lua19
2 files changed, 19 insertions, 16 deletions
diff --git a/openntpd-controller.lua b/openntpd-controller.lua
index dc90eb4..e1b7ca3 100644
--- a/openntpd-controller.lua
+++ b/openntpd-controller.lua
@@ -1,23 +1,25 @@
-module (..., package.seeall)
+local mymodule = {}
-default_action = "status"
+mymodule.default_action = "status"
-function config(self)
+function mymodule.config(self)
return self.handle_form(self, self.model.read_config, self.model.update_config, self.clientdata, "Save", "Edit OpenNTPD Config", "OpenNTPD Configuration Saved")
end
-function status (self)
+function mymodule.status (self)
return self.model.getstatus()
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 Config", "Configuration Set")
end
-function startstop(self)
+function mymodule.startstop(self)
return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata)
end
+
+return mymodule
diff --git a/openntpd-model.lua b/openntpd-model.lua
index 44139c1..f5607f5 100644
--- a/openntpd-model.lua
+++ b/openntpd-model.lua
@@ -1,4 +1,4 @@
-module (..., package.seeall)
+local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
@@ -52,19 +52,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, "OpenNTPD Status")
end
-function getstatusdetails()
+function mymodule.getstatusdetails()
local status = {}
status.timechanged = cfe({ value=last_time_change(), label="Previous time adjustment" })
@@ -73,7 +73,7 @@ function getstatusdetails()
return cfe({ type="group", value=status, label="OpenNTPD Detailed Status" })
end
-function read_config ()
+function mymodule.read_config ()
local config = {}
config.server = cfe({ type="list", value={}, label="Single servers", descr="List of server IP addresses/hostnames. OpenNTPD will attempt to synchronize to one resolved address for each hostname entry.", seq=3 })
config.servers = cfe({ type="list", value={}, label="Multiple servers", descr="List of server IP addresses/hostnames. OpenNTPD will attempt to synchronize to all resolved addresses for each hostname entry.", seq=4 })
@@ -99,7 +99,7 @@ function read_config ()
return cfe({ type="group", value=config, label="OpenNTPD Config" })
end
-function update_config(self, config)
+function mymodule.update_config(self, config)
local success, config = validate_config(config)
if success then
@@ -154,11 +154,12 @@ function update_config(self, config)
return config
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