summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-08-08 20:27:34 +0000
committerTed Trask <ttrask01@yahoo.com>2012-08-08 20:27:34 +0000
commit12a599b5e3ac719513bed698271cec060283b223 (patch)
tree61113db7acf8e1f089d79e48b173339dfeef9ad7
parent642d284ce1fe2d57e0a74230ec338024d927cc6e (diff)
downloadacf-provisioning-12a599b5e3ac719513bed698271cec060283b223.tar.bz2
acf-provisioning-12a599b5e3ac719513bed698271cec060283b223.tar.xz
Modified scripts so no exception if Polycom path is missing
-rw-r--r--config/delete_device.lua10
-rw-r--r--config/update_device_params.lua12
2 files changed, 13 insertions, 9 deletions
diff --git a/config/delete_device.lua b/config/delete_device.lua
index ea69da2..d7e34a1 100644
--- a/config/delete_device.lua
+++ b/config/delete_device.lua
@@ -10,10 +10,12 @@ 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)
+ if posix.stat(path, "type") == "directory" then
+ 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
end
diff --git a/config/update_device_params.lua b/config/update_device_params.lua
index 5d13099..61d33d2 100644
--- a/config/update_device_params.lua
+++ b/config/update_device_params.lua
@@ -33,11 +33,13 @@ oldparams = oldparams or {value={}}
if oldparams.value.device and oldparams.value.device.value.mac and oldparams.value.device.value.mac.value ~= "" and params.value.device and params.value.device.value.mac and params.value.device.value.mac.value ~= oldparams.value.device.value.mac.value then
if string.match(oldparams.value.device.label, "Polycom") 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
- local newfile = string.gsub(d, string.lower(oldparams.value.device.value.mac.value), string.lower(params.value.device.value.mac.value))
- APP.logevent("moving "..path..d.." to "..path..newfile)
- os.rename(path..d, path..newfile)
+ if posix.stat(path, "type") == "directory" then
+ 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
+ local newfile = string.gsub(d, string.lower(oldparams.value.device.value.mac.value), string.lower(params.value.device.value.mac.value))
+ APP.logevent("moving "..path..d.." to "..path..newfile)
+ os.rename(path..d, path..newfile)
+ end
end
end
end