diff options
author | Andreas Brodmann <andreas.brodmann@gmail.com> | 2007-11-20 19:47:58 +0000 |
---|---|---|
committer | Andreas Brodmann <andreas.brodmann@gmail.com> | 2007-11-20 19:47:58 +0000 |
commit | b2a4c830601186377d8999bac02ea465fd704e66 (patch) | |
tree | b0b5fe21c3d156daaa3fe2cacc06135dad30b8e4 /squid-model.lua | |
parent | 5c0d2431db19eb77acc9e9b76ae0010e40240dcc (diff) | |
download | acf-squid-b2a4c830601186377d8999bac02ea465fd704e66.tar.bz2 acf-squid-b2a4c830601186377d8999bac02ea465fd704e66.tar.xz |
initial import of acf-squidv1.0_alpha1
git-svn-id: svn://svn.alpinelinux.org/acf/squid/trunk@350 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'squid-model.lua')
-rw-r--r-- | squid-model.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/squid-model.lua b/squid-model.lua new file mode 100644 index 0000000..c61a4e7 --- /dev/null +++ b/squid-model.lua @@ -0,0 +1,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 + |