diff options
author | Ted Trask <ttrask01@yahoo.com> | 2011-10-10 19:34:59 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2011-10-10 19:34:59 +0000 |
commit | 1d895ace660869053830ed33302e0708efb6065e (patch) | |
tree | 0ed844a6a408042ec0c6f4a11726db7a7915881b /config/delete_device.lua | |
parent | b802504e41cccda64b8f903973d01897bbec7451 (diff) | |
download | acf-provisioning-1d895ace660869053830ed33302e0708efb6065e.tar.bz2 acf-provisioning-1d895ace660869053830ed33302e0708efb6065e.tar.xz |
Added in configuration files / scripts and cgi-bin scripts.
Diffstat (limited to 'config/delete_device.lua')
-rw-r--r-- | config/delete_device.lua | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/config/delete_device.lua b/config/delete_device.lua new file mode 100644 index 0000000..ad908ed --- /dev/null +++ b/config/delete_device.lua @@ -0,0 +1,44 @@ +-- This is the script run after deleting a device (and all of its params) +local functions, olddevice, oldparams = ... + +local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin " + +APP.logevent("got to delete_device script") + +-- We'll handle the deleting of the device by handling the resulting changing of the params +-- First, have to create a new set of params (with blank extensions) +local duplicatestructure +duplicatestructure = function(value, saved) + saved = saved or {} + if type(value) == "table" then + if saved[value] then + return saved[value] + else + local output = {} + saved[value] = output + for k,v in pairs(value) do + output[k] = duplicatestructure(v, saved) + end + return output + end + else + return value + end +end + +local params = duplicatestructure(oldparams) +for name,val in pairs(params.value) do + if string.match(name, "^reg") then + params.value[name].value.extension.value = "" + end +end + +-- Then call the other script +local env = {} +setmetatable (env, {__index = _G}) +-- loadfile loads into the global environment +-- so we set env 0, not env 1 +setfenv (0, env) +local f = loadfile("/etc/provisioning/update_device_params.lua") +if (f) then f(functions, params, oldparams) end +setfenv (0, _G) |