diff options
author | ttrask <ttrask@ab2d0c66-481e-0410-8bed-d214d4d58bed> | 2009-03-17 20:39:56 +0000 |
---|---|---|
committer | ttrask <ttrask@ab2d0c66-481e-0410-8bed-d214d4d58bed> | 2009-03-17 20:39:56 +0000 |
commit | c700c97cb992cdc3eb62d93a52e1bf56ed5ea585 (patch) | |
tree | fb6446b8fbe31833808ab1319d845b0614047fee /lib/processinfo.lua | |
parent | 5dc15abba740eae84b4202a6a7319cad163fe87c (diff) | |
download | acf-core-c700c97cb992cdc3eb62d93a52e1bf56ed5ea585.tar.bz2 acf-core-c700c97cb992cdc3eb62d93a52e1bf56ed5ea585.tar.xz |
Changed the way startstop works in core to add a list of allowed actions. Modified all ACFs that don't use the standard functions to work with new library method.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1730 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/processinfo.lua')
-rw-r--r-- | lib/processinfo.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/processinfo.lua b/lib/processinfo.lua index f41e62f..35ea42f 100644 --- a/lib/processinfo.lua +++ b/lib/processinfo.lua @@ -112,14 +112,18 @@ function delete_startupsequence(servicename) return cmdresult,cmderrors end -function daemoncontrol (process, action) +function daemoncontrol (process, action, actions) + actions = actions or {"start", "stop", "restart"} + local reverseactions = {} + for i,act in ipairs(actions) do reverseactions[string.lower(act)] = i end + local cmdresult = "" local cmderrors if not process then cmderrors = "Invalid service name" - elseif (string.lower(action) == "start") or (string.lower(action) == "stop") or (string.lower(action) == "restart") then + elseif reverseactions[string.lower(action)] then local file = io.popen( "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin /etc/init.d/" .. - format.escapespecialcharacters(process) .. " " .. string.lower(action) .. " 2>&1" ) + format.escapespecialcharacters(process) .. " " .. format.escapespecialcharacters(string.lower(action)) .. " 2>&1" ) if file ~= nil then cmdresult = file:read( "*a" ) file:close() @@ -128,7 +132,7 @@ function daemoncontrol (process, action) else cmderrors = "Unknown command!" end - return cmdresult,cmderrors + return cmdresult,cmderrors,actions end -- the following methods are available: |