summaryrefslogtreecommitdiffstats
path: root/config/delete_device.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2011-10-11 15:35:02 +0000
committerTed Trask <ttrask01@yahoo.com>2011-10-11 15:35:02 +0000
commitfe1e3e76b8174f3aa0c5adeb9abc10821b8f2013 (patch)
treef90b3a6dd1e24074f559604bbaf62edfbca16817 /config/delete_device.lua
parent6b6de1fd8e91f2fe812db929fea4bef9d1224585 (diff)
downloadacf-provisioning-fe1e3e76b8174f3aa0c5adeb9abc10821b8f2013.tar.bz2
acf-provisioning-fe1e3e76b8174f3aa0c5adeb9abc10821b8f2013.tar.xz
Delete / move other (put) files when delete / change mac for Polycom phone
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)