blob: c61a4e7cbc3aec351f7b0ab16a4971c787d84646 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-- acf model for squid
-- Copyright(c) 2007 A. Brodmann - Licensed under terms of GPL2
module (..., package.seeall)
get_status = function()
local retval = "stopped"
local ptr = io.popen( "/bin/pidof squid" )
local pid = ptr:read( "*a" )
ptr:close()
if pid ~= nil then
if #pid > 1 then
retval = "running"
end
end
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
end
|