summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2016-06-08 19:11:10 +0000
committerTed Trask <ttrask01@yahoo.com>2016-06-08 19:11:10 +0000
commit4dd2e0a349a51321a71415721072e848f2650f2b (patch)
tree3a05ae396f8ccf405f19f9b33e0364e2d8be8929
parentf14b5eacb22f4b35d5a6bf01b7f5eaf449669cb8 (diff)
downloadacf-lib-4dd2e0a349a51321a71415721072e848f2650f2b.tar.bz2
acf-lib-4dd2e0a349a51321a71415721072e848f2650f2b.tar.xz
Modify daemoncontrol to properly report errors and daemon_actions to ignore rc warnings in describe results
-rw-r--r--processinfo.lua24
1 files changed, 16 insertions, 8 deletions
diff --git a/processinfo.lua b/processinfo.lua
index 0a2013d..a479cac 100644
--- a/processinfo.lua
+++ b/processinfo.lua
@@ -102,7 +102,7 @@ function mymodule.delete_runlevels(servicename, runlevels)
end
function mymodule.daemoncontrol (process, action)
- local cmdresult = ""
+ local cmdresult
local cmderrors
if not process then
cmderrors = "Invalid service name"
@@ -114,7 +114,7 @@ function mymodule.daemoncontrol (process, action)
code, cmdresult = subprocess.call_capture({"/etc/init.d/" .. process, string.lower(action), stderr=subprocess.STDOUT})
end)
if not res or err then
- cmdresult = string.gsub(err or "Unknown failure", ": No such file or directory", "-ash: /etc/init.d/"..process..": not found")
+ cmderrors = err
end
end
return cmdresult,cmderrors
@@ -132,12 +132,20 @@ function mymodule.daemon_actions (process)
return nil, err
else
lines = format.string_to_table(res, "\n")
- description = string.match(lines[1], "^%s*%*%s*(.*)")
- for i=2,#lines,1 do
- local act = string.match(lines[i], "^%s*%*%s*([^:]*)")
- if act and not reverse[act] then
- actions[#actions+1] = act
- reverse[act] = #actions
+ -- Description is last line before first action
+ -- Actions are of the form " * action: description"
+ local found = false
+ for i,l in ipairs(lines) do
+ local line = string.gsub(l, "^%s*%*%s*", "")
+ if string.find(line, "^%S*:") then
+ found = true
+ local act = string.match(line, "^([^:]*)")
+ if act and not reverse[act] then
+ actions[#actions+1] = act
+ reverse[act] = #actions
+ end
+ elseif not found then
+ description = line
end
end
end