diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-09-23 18:13:03 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-09-23 18:13:03 +0000 |
commit | fb00ff8f05dae3c110beceb929ea036e4cd14ae1 (patch) | |
tree | 51d124ce1c65e3a600a7da7b9dd57ffafd83f910 /config/update_device_params.lua | |
parent | 60ef6e20019e046aa801325d29893ada12b5d5af (diff) | |
download | acf-provisioning-fb00ff8f05dae3c110beceb929ea036e4cd14ae1.tar.bz2 acf-provisioning-fb00ff8f05dae3c110beceb929ea036e4cd14ae1.tar.xz |
Change function prototypes to pass self and use self.model instead of functions table
Changed the order of the first two parameters passed to validate function in provisioning_params
Replaced all APP references with self, now that self is available
Still need to implement swapvalidateparams script
Diffstat (limited to 'config/update_device_params.lua')
-rw-r--r-- | config/update_device_params.lua | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/config/update_device_params.lua b/config/update_device_params.lua index 6d7ae23..42560c3 100644 --- a/config/update_device_params.lua +++ b/config/update_device_params.lua @@ -1,17 +1,17 @@ -- This is the script run after editing device params -local functions, params, oldparams = ... +local self, params, oldparams = ... require("posix") local root = "/var/www/provisioning/htdocs/" ---APP.logevent("got to update_device_params script") +--self.logevent("got to update_device_params script") local function findip(mac) if not mac or mac == "" then return nil end - local ipaddr = functions.getselectresponse("SELECT ip FROM provisioning_requests WHERE mac~*'"..mac.."'") + local ipaddr = self.getselectresponse("SELECT ip FROM provisioning_requests WHERE mac~*'"..mac.."'") if ipaddr and ipaddr[1] then return ipaddr[1].ip end @@ -20,10 +20,10 @@ end local notify_device = function(mac, extension) local ipaddr = findip(mac) if ipaddr then - --APP.logevent("Notifying "..ipaddr.." to update for "..(mac or "")) + --self.logevent("Notifying "..ipaddr.." to update for "..(mac or "")) os.execute("/etc/provisioning/notify_device "..ipaddr.." "..extension) else - --APP.logevent("Warning - could not find IP address for "..(mac or "")) + --self.logevent("Warning - could not find IP address for "..(mac or "")) end end @@ -34,10 +34,10 @@ if oldparams.value.device and oldparams.value.device.value.mac and oldparams.val if string.match(oldparams.value.device.label, "Polycom") and string.match(oldparams.value.device.value.mac.value, "[1-9A-F]") then local deletefiles = true if string.match(params.value.device.value.mac.value, "[1-9A-F]") then - --APP.logevent("Moving files for "..oldparams.value.device.value.mac.value) + --self.logevent("Moving files for "..oldparams.value.device.value.mac.value) deletefiles = false else - --APP.logevent("Deleting files for "..oldparams.value.device.value.mac.value) + --self.logevent("Deleting files for "..oldparams.value.device.value.mac.value) end local path = root.."Polycom/" if posix.stat(path, "type") == "directory" then @@ -45,10 +45,10 @@ if oldparams.value.device and oldparams.value.device.value.mac and oldparams.val if string.match(d, string.lower(oldparams.value.device.value.mac.value)) and posix.stat(path..d, "type") == "regular" then local newfile = string.gsub(d, string.lower(oldparams.value.device.value.mac.value), string.lower(params.value.device.value.mac.value)) if deletefiles then - --APP.logevent("deleting "..path..d) + --self.logevent("deleting "..path..d) os.remove(path..d) else - --APP.logevent("moving "..path..d.." to "..path..newfile) + --self.logevent("moving "..path..d.." to "..path..newfile) os.rename(path..d, path..newfile) end end |