diff options
Diffstat (limited to 'squid-model.lua')
-rw-r--r-- | squid-model.lua | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/squid-model.lua b/squid-model.lua index e2b9285..f23f026 100644 --- a/squid-model.lua +++ b/squid-model.lua @@ -6,6 +6,7 @@ module (..., package.seeall) require("format") require("processinfo") require("procps") +require("daemoncontrol") -- Set variables local squidconf = "/etc/squid/squid.conf" @@ -121,24 +122,12 @@ get_status_winbindd = function() return retval end -service_control = function( control ) - - local retval = "" - - local ptr = io.popen( "/etc/init.d/squid " .. control, "r" ) - if ptr ~= nil then - local retmsg = ptr:read( "*a" ) - ptr:close() - if retmsg ~= nil then - retval = retmsg - else - retval = "service_control(): Failed to read output from initscript!\n" - end - else - retval = "service_control(): Failed to start/stop/restart service!\n" - end - - return retval +service_control = function( cmd ) + local action = {value=cmd} + local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, cmd) + action.descr=cmdmessage + action.errtxt=cmderror + return cmdresult,action end service_control_winbindd = function( control ) |