From 2ece009273252437281c8cc0b84ba2ec49e5d07c Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 17 Oct 2013 19:07:53 +0000 Subject: 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. --- rc-model.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'rc-model.lua') diff --git a/rc-model.lua b/rc-model.lua index d799cca..3df75a2 100644 --- a/rc-model.lua +++ b/rc-model.lua @@ -1,4 +1,4 @@ -module (..., package.seeall) +local mymodule = {} posix = require("posix") modelfunctions = require("modelfunctions") @@ -16,7 +16,7 @@ table.sort(runlevels) local config -status = function() +mymodule.status = function() if not config then config = processinfo.read_initrunlevels() for i,c in pairs(config) do @@ -30,7 +30,7 @@ status = function() return cfe({ type="structure", value=config, label="Init Runlevels" }) end -read_runlevels = function(self, clientdata) +mymodule.read_runlevels = function(self, clientdata) local servicename = clientdata.servicename local value = {} value.servicename = cfe({ value=servicename or "", label="Service Name", seq=1 }) @@ -49,7 +49,7 @@ read_runlevels = function(self, clientdata) return cfe({ type="group", value=value, label="Service Runlevels"}) end -update_runlevels = function(self, service) +mymodule.update_runlevels = function(self, service) local success = modelfunctions.validatemulti(service.value.runlevels) service.value.servicename.errtxt = "Invalid service" for name in posix.files("/etc/init.d") do @@ -85,11 +85,12 @@ update_runlevels = function(self, service) return service end -function get_startstop(self, clientdata) +function mymodule.get_startstop(self, clientdata) return modelfunctions.get_startstop(clientdata.servicename) end -function startstop_service(self, startstop) +function mymodule.startstop_service(self, startstop) return modelfunctions.startstop_service(startstop, clientdata.action) end +return mymodule -- cgit v1.2.3