From fe1e3e76b8174f3aa0c5adeb9abc10821b8f2013 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 11 Oct 2011 15:35:02 +0000 Subject: Delete / move other (put) files when delete / change mac for Polycom phone --- config/delete_device.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'config/delete_device.lua') 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) -- cgit v1.2.3