summaryrefslogtreecommitdiffstats
path: root/lib/daemoncontrol.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/daemoncontrol.lua')
-rw-r--r--lib/daemoncontrol.lua19
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