diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-01-14 16:02:25 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-01-14 16:02:25 +0000 |
commit | 8ec1a9867d6d39da5cf796ae067acd3447833d1e (patch) | |
tree | ac2c2bb11863bbddd32422d06448b7f70e266b13 /lib/daemoncontrol.lua | |
parent | 592b94ed536fa16b80860928132df31b9260cd06 (diff) | |
download | acf-core-8ec1a9867d6d39da5cf796ae067acd3447833d1e.tar.bz2 acf-core-8ec1a9867d6d39da5cf796ae067acd3447833d1e.tar.xz |
Added some code in the daemoncontrol
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@565 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/daemoncontrol.lua')
-rw-r--r-- | lib/daemoncontrol.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/daemoncontrol.lua b/lib/daemoncontrol.lua index e69de29..e7c6e2d 100644 --- a/lib/daemoncontrol.lua +++ b/lib/daemoncontrol.lua @@ -0,0 +1,19 @@ +module (..., package.seeall) + +function daemoncontrol (process, action) + local cmdresult = "" + if (string.lower(action) == "start") or (string.lower(action) == "stop") or (string.lower(action) == "restart") then + local file = io.popen( "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin /etc/init.d/" .. process .. " " .. action .. " 2>&1" ) + if file ~= nil then + line = file:read( "*l" ) + while line ~= nil do + cmdresult = cmdresult .. "\n" .. line + line = file:read( "*l" ) + end + file:close() + end + else + cmdresult = "Unknown command!" + end + return {cmdresult=cmdresult, process=process, action=action, } +end |