From 8ec1a9867d6d39da5cf796ae067acd3447833d1e Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Mon, 14 Jan 2008 16:02:25 +0000 Subject: Added some code in the daemoncontrol git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@565 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/daemoncontrol.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/daemoncontrol.lua') 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 -- cgit v1.2.3