summaryrefslogtreecommitdiffstats
path: root/squid-controller.lua
diff options
context:
space:
mode:
authorAndreas Brodmann <andreas.brodmann@gmail.com>2007-11-20 19:47:58 +0000
committerAndreas Brodmann <andreas.brodmann@gmail.com>2007-11-20 19:47:58 +0000
commitb2a4c830601186377d8999bac02ea465fd704e66 (patch)
treeb0b5fe21c3d156daaa3fe2cacc06135dad30b8e4 /squid-controller.lua
parent5c0d2431db19eb77acc9e9b76ae0010e40240dcc (diff)
downloadacf-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-controller.lua')
-rw-r--r--squid-controller.lua53
1 files changed, 53 insertions, 0 deletions
diff --git a/squid-controller.lua b/squid-controller.lua
new file mode 100644
index 0000000..46da101
--- /dev/null
+++ b/squid-controller.lua
@@ -0,0 +1,53 @@
+-- the squid controller
+
+module (..., package.seeall)
+
+-- Cause an http redirect to our "read" action
+-- We use the self.conf table because it already has prefix,controller,etc
+-- The redir code is defined in the application error handler (acf-controller)
+local list_redir = function (self)
+ self.conf.action = "home"
+ self.conf.type = "redir"
+ error (self.conf)
+end
+
+local pvt = {}
+mvc= {}
+mvc.on_load = function( self, parent )
+ -- If they try to run a bogus action, send them to read
+ if ( rawget(self.worker, self.conf.action) == nil ) then
+ list_redir(self)
+ end
+ pvt.parent_on_exec = parent.worker.mvc.post_exec
+end
+
+mvc.pre_exec = function( self )
+ -- pvt.parent_on_exec ()
+end
+
+mvc.post_exec = function( self )
+ return pvt.parent_on_exec()
+end
+
+basic = function( self )
+
+ local option = { script = ENV["SCRIPT_NAME"],
+ prefix = self.conf.prefix,
+ controller = self.conf.controller,
+ action = self.conf.action,
+ extra = ""
+ }
+
+ local service = { message="", status="" }
+ if self.clientdata.srvcmd then
+ local srvcmd = self.clientdata.srvcmd
+ if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
+ service.message = self.model.service_control( srvcmd )
+ end
+ end
+
+ service.status = self.model.get_status()
+
+ return ( cfe ({ option = option, service = service }) )
+end
+