summaryrefslogtreecommitdiffstats
path: root/config/delete_device.lua
diff options
context:
space:
mode:
Diffstat (limited to 'config/delete_device.lua')
-rw-r--r--config/delete_device.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/config/delete_device.lua b/config/delete_device.lua
index 6e5a907..ea69da2 100644
--- a/config/delete_device.lua
+++ b/config/delete_device.lua
@@ -1,11 +1,22 @@
-- 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 "
+require("posix")
+
+local root = "/var/www/provisioning/htdocs/"
APP.logevent("got to delete_device script")
-- First, we delete the associated config files
+if oldparams.value.device and string.match(oldparams.value.device.label, "Polycom") and oldparams.value.device.value.mac then
+ local path = root.."Polycom/"
+ for d in posix.files(path) do
+ if string.match(d, string.lower(oldparams.value.device.value.mac.value)) and posix.stat(path..d, "type") == "regular" then
+ APP.logevent("deleting "..path..d)
+ os.remove(path..d)
+ end
+ end
+end
-- 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)