summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-08-12 14:06:46 +0000
committerTed Trask <ttrask01@yahoo.com>2008-08-12 14:06:46 +0000
commit9c32f7047c8d3b3f19f451149b291ee74ef64062 (patch)
tree47d2fc85994bf4b920b09ad456c52c3937b197b7
parentc9683570fd9a648a80713b4fef357f2cb7d5021b (diff)
downloadacf-squid-9c32f7047c8d3b3f19f451149b291ee74ef64062.tar.bz2
acf-squid-9c32f7047c8d3b3f19f451149b291ee74ef64062.tar.xz
Modified squid to use new status, startstop, and expert (replaced advanced) actions.
git-svn-id: svn://svn.alpinelinux.org/acf/squid/trunk@1379 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--squid-advanced-html.lsp57
-rw-r--r--squid-authentication-html.lsp40
-rw-r--r--squid-basic-html.lsp39
-rw-r--r--squid-controller.lua121
-rw-r--r--squid-digest-html.lsp8
l---------squid-expert-html.lsp1
-rw-r--r--squid-model.lua81
-rw-r--r--squid-saccess-html.lsp9
l---------squid-startstop-html.lsp1
l---------[-rw-r--r--]squid-status-html.lsp31
-rw-r--r--squid.menu2
-rw-r--r--squid.roles2
12 files changed, 44 insertions, 348 deletions
diff --git a/squid-advanced-html.lsp b/squid-advanced-html.lsp
deleted file mode 100644
index a175159..0000000
--- a/squid-advanced-html.lsp
+++ /dev/null
@@ -1,57 +0,0 @@
-<%
-require("viewfunctions")
-
- local form = ...
- local data = form.option
- local service = form.service
-
- local srv1fill = ""
- local srv2fill = "disabled"
- if form.info.status.value == "Enabled" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
-%>
-<H1>SYSTEM INFO</H1>
-<DL>
-<%
-local myform = form.info
-local tags = { "status", "version", "autostart", }
-displayinfo(myform,tags,"viewonly")
-%>
-</DL>
-
-
-<h1>Advanced configuration</h1>
-<dl>
-<dt>Warning</dt>
-<dd class="attention">
- Modifying the web proxy configuration file is generally not necessary.
- You must be familiar with the configuration file before proceeding.
-</dd>
-</dl>
-
-<h2>Configuration</h2>
-<form action="" method="POST">
-<textarea name="config"><% io.write( service.config ) %></textarea>
-
-<h3>Save Changes</h3>
-<dl>
-<dt>Save the contents of the box above</dt><dd><input class="submit" type="submit" name="cmd" value="save"></dd>
-<dt>Process information</dt><dd>This process runs as a service. When you make and save changes,
-the configuration files for the service are changed. However, the changes will not be
-<i>applied</i> until you restart the service.</dd>
-</dl>
-</form>
-
-<h1>MANAGEMENT</h1>
-<form action="" method="POST">
-<dl>
-<DT>Daemon control</DT><dd><input class="submit" type="submit" name="srvcmd" value="start" <% io.write( srv1fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="stop" <% io.write( srv2fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="restart" <% io.write( srv2fill ) %>>
-<% if (service.message) and (service.message.descr) and (#service.message.descr > 0) then %><pre><% io.write( service.message.descr ) %></pre><% end %></dd>
-</dl>
-</form>
-
diff --git a/squid-authentication-html.lsp b/squid-authentication-html.lsp
index 3071134..7e662a7 100644
--- a/squid-authentication-html.lsp
+++ b/squid-authentication-html.lsp
@@ -1,34 +1,14 @@
<%
require("viewfunctions")
- local form = ...
- local data = form.option
- local service = form.service
+ local form, viewlibrary = ...
local config = form.service.config
- local srv1fill = ""
- local srv2fill = "disabled"
- if form.info.status.value == "Enabled" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
- local ifthen = function( variable, value, result )
- if variable == value then
- io.write( result )
- end
- end
-
%>
-<H1>SYSTEM INFO</H1>
-<DL>
-<%
-local myform = form.info
-local tags = { "status", "version", "autostart", }
-displayinfo(myform,tags,"viewonly")
-%>
-</DL>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
<h1>Configuration</h1>
<h2>Authentication Scheme</h2>
@@ -100,12 +80,6 @@ the changes will not be <i>applied</i> until you restart the service.</dd>
</DL>
</form>
-<h1>MANAGEMENT</h1>
-<form action="" method="POST">
-<dl>
-<DT>Daemon control</DT><dd><input class="submit" type="submit" name="srvcmd" value="start" <% io.write( srv1fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="stop" <% io.write( srv2fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="restart" <% io.write( srv2fill ) %>>
-<% if (service.message) and (service.message.descr) and (#service.message.descr > 0) then %><pre><% io.write( service.message.descr ) %></pre><% end %></dd>
-</dl>
-</form>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/squid-basic-html.lsp b/squid-basic-html.lsp
index 2ee56dc..8822f87 100644
--- a/squid-basic-html.lsp
+++ b/squid-basic-html.lsp
@@ -1,34 +1,21 @@
-<%
+<%
require("viewfunctions")
- local form = ...
- local data = form.option
+ local form, viewlibrary = ...
local service = form.service
local config = form.service.config
-
- local srv1fill = ""
- local srv2fill = "disabled"
- if form.info.status.value == "Enabled" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
+
local ifthen = function( variable, value, result )
if variable == value then
io.write( result )
end
end
-
-%>
-<H1>SYSTEM INFO</H1>
-<DL>
-<%
-local myform = form.info
-local tags = { "status", "version", "autostart", }
-displayinfo(myform,tags,"viewonly")
%>
-</DL>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
<h1>Configuration</h1>
<form action="" method="POST">
@@ -98,13 +85,7 @@ until you restart the service.</DD>
</dl>
</form>
-<h1>MANAGEMENT</h1>
-<form action="" method="POST">
-<dl>
-<DT>Daemon control</DT><dd><input class="submit" type="submit" name="srvcmd" value="start" <% io.write( srv1fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="stop" <% io.write( srv2fill ) %>>
-<input class="submit" type="submit" name="srvcmd" value="restart" <% io.write( srv2fill ) %>>
-<% if (service.message) and (service.message.descr) and (#service.message.descr > 0) then %><pre><% io.write( service.message.descr ) %></pre><% end %></dd>
-</dl>
-</form>
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/squid-controller.lua b/squid-controller.lua
index ee1b778..b16bbd8 100644
--- a/squid-controller.lua
+++ b/squid-controller.lua
@@ -2,6 +2,8 @@
module (..., package.seeall)
+require("controllerfunctions")
+
default_action = "status"
dep = function( self )
@@ -21,47 +23,16 @@ dep = function( self )
end
status = function( self )
+ return self.model.getstatus()
+end
- local info = {
- status=self.model.get_status(),
- version = self.model.get_squid_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
- return ( cfe ({ option = option, info = info }) )
+startstop = function( self )
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata)
end
basic = function( self )
local service = {}
- if self.clientdata.srvcmd then
- local srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.srvcmdresult, service.message = self.model.service_control( srvcmd )
- end
- end
-
- local info = {
- status=self.model.get_status(),
- version = self.model.get_squid_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
if not self.model.dependancy_ok() then
redirect(self, "dep")
@@ -86,35 +57,14 @@ basic = function( self )
end
end
- service.status = self.model.get_status()
service.config, service.error = self.model.get_basic_config()
- return ( cfe ({ option = option, service = service, info = info }) )
+ return ( cfe ({ service = service }) )
end
authentication = function( self )
local service = {}
- if self.clientdata.srvcmd then
- local srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.srvcmdresult, service.message = self.model.service_control( srvcmd )
- end
- end
-
- local info = {
- status=self.model.get_status(),
- version = self.model.get_squid_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
if self.clientdata.inout then
local newauth = ""
@@ -137,57 +87,17 @@ authentication = function( self )
self.model.upd_authmethod(newauth)
end
- service.status = self.model.get_status()
service.config, service.error = self.model.get_basic_config()
- return ( cfe ({ option = option, service = service, info = info, mdebug=self.clientdata }) )
+ return ( cfe ({ service = service }) )
end
-advanced = function( self )
-
- local service = {}
- if self.clientdata.srvcmd then
- local srvcmd = self.clientdata.srvcmd
- if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then
- service.srvcmdresult, service.message = self.model.service_control( srvcmd )
- end
- end
-
- local info = {
- status=self.model.get_status(),
- version = self.model.get_squid_version(),
- autostart = self.model.get_autostart(),
- srvctrl = { value = srvctrl}
- }
-
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
- if self.clientdata.cmd then
- if self.clientdata.cmd == "save" then
- service.message = self.model.update_adv_config( self.clientdata.config )
- end
- end
-
- service.status = self.model.get_status()
- service.config = self.model.get_adv_config()
-
- return ( cfe ({ option = option, service = service, info = info }) )
+expert = function( self )
+ return controllerfunctions.handle_form(self, self.model.get_configfile, self.model.update_configfile, self.clientdata, "Save", "Edit Config", "Configuration Set")
end
digest = function( self )
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
local service = { message="", status="", config="" }
if self.clientdata.cmd then
@@ -198,18 +108,11 @@ digest = function( self )
service.config = self.model.get_digest_userlist()
- return ( cfe ({ option = option, service = service }) )
+ return ( cfe ({ service = service }) )
end
saccess = function( self )
- local option = { script = self.conf.script,
- prefix = self.conf.prefix,
- controller = self.conf.controller,
- action = self.conf.action,
- extra = ""
- }
-
local service = { message="", status="", config="" }
if self.clientdata.cmd then
@@ -224,7 +127,7 @@ saccess = function( self )
service.config = self.model.get_saccess()
- return ( cfe ({ option = option, service = service }) )
+ return ( cfe ({ service = service }) )
end
diff --git a/squid-digest-html.lsp b/squid-digest-html.lsp
index b441698..fb8aab6 100644
--- a/squid-digest-html.lsp
+++ b/squid-digest-html.lsp
@@ -1,15 +1,7 @@
<%
local form = ...
- local data = form.option
local service = form.service
- local srv1fill = ""
- local srv2fill = "disabled"
- if service.status == "running" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
%>
<h1>Web Proxy Configuration</h1>
<h2>General Information</h2>
diff --git a/squid-expert-html.lsp b/squid-expert-html.lsp
new file mode 120000
index 0000000..207f324
--- /dev/null
+++ b/squid-expert-html.lsp
@@ -0,0 +1 @@
+../expert-html.lsp \ No newline at end of file
diff --git a/squid-model.lua b/squid-model.lua
index 8e20e34..101a279 100644
--- a/squid-model.lua
+++ b/squid-model.lua
@@ -3,10 +3,8 @@
module (..., package.seeall)
-- Load libraries
+require("modelfunctions")
require("format")
-require("processinfo")
-require("procps")
-require("daemoncontrol")
-- Set variables
local squidconf = "/etc/squid/squid.conf"
@@ -56,39 +54,12 @@ tokenizer.next = function( token )
end
---
-get_status = function()
- local t = procps.pidof(processname)
- local stats
- if (t) and (#t > 0) then
- stats = "Enabled"
- else
- stats = "Disabled"
- end
- local retval = cfe({ name="status",
- label="Program status",
- value=stats,
- })
- return retval
-end
-
-get_squid_version = function()
- local value, errtxt = processinfo.package_version(packagename)
- local retval = cfe({ name = "version",
- label="Program version",
- value=value,
- errtxt=errtxt,
- })
- return retval
+getstatus = function()
+ return modelfunctions.getstatus(processname, packagename, "Squid status")
end
-get_autostart = function()
- local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname)
- local retval = cfe({ name="autostart",
- label="Autostart sequence",
- value=autostart_sequense,
- errtxt=autostart_errtxt,
- })
- return retval
+startstop_service = function(action)
+ return modelfunctions.startstop_service(processname, action)
end
get_winbind_version = function()
@@ -122,14 +93,6 @@ get_status_winbindd = function()
return retval
end
-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 )
local retval = ""
@@ -172,22 +135,8 @@ get_winbindd_config = function()
return config
end
-get_adv_config = function()
-
- local retval = ""
-
- local ptr = io.open( squidconf, "r" )
- if ptr ~= nil then
- local retcfg = ptr:read( "*a" )
- ptr:close()
- if retcfg == nil then
- retval = "\n\n Error: Failed to read " .. squidconf .. "!\n\n"
- else
- retval = retcfg
- end
- end
-
- return retval
+get_configfile = function()
+ return modelfunctions.getfiledetails(squidconf)
end
get_digest_userlist = function()
@@ -255,19 +204,9 @@ get_file_contents = function( name )
return retval
end
-update_adv_config = function( config )
-
- local retval = "Successfully updated " .. squidconf .. "!"
-
- local ptr = io.open( squidconf, "wb+" )
- if ptr ~= nil then
- ptr:write( format.dostounix( config ) )
- ptr:close()
- else
- retval = "update_config(): Error, failed to open " .. squidconf .. "!\n"
- end
-
- return retval
+update_configfile = function( filedetails )
+ filedetails.value.filename.value = squidconf
+ return modelfunctions.setfiledetails(filedetails)
end
update_digest_userlist = function( config )
diff --git a/squid-saccess-html.lsp b/squid-saccess-html.lsp
index be3ea5e..0c11f08 100644
--- a/squid-saccess-html.lsp
+++ b/squid-saccess-html.lsp
@@ -1,15 +1,6 @@
<%
local form = ...
- local data = form.option
local service = form.service
-
- local srv1fill = ""
- local srv2fill = "disabled"
- if service.status == "running" then
- srv1fill = "disabled"
- srv2fill = ""
- end
-
%>
<h1>Web Proxy - Special Access</h1>
<h2>General Information</h2>
diff --git a/squid-startstop-html.lsp b/squid-startstop-html.lsp
new file mode 120000
index 0000000..0ea2627
--- /dev/null
+++ b/squid-startstop-html.lsp
@@ -0,0 +1 @@
+../startstop-html.lsp \ No newline at end of file
diff --git a/squid-status-html.lsp b/squid-status-html.lsp
index 59cb502..b2f8480 100644..120000
--- a/squid-status-html.lsp
+++ b/squid-status-html.lsp
@@ -1,30 +1 @@
-<% local form = ...
-require("viewfunctions")
-%>
-
-<%
---[[ DEBUG INFORMATION
-io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
-io.write(html.cfe_unpack(form))
-io.write("</span>")
---]]
-%>
-
-<H1>SYSTEM INFO</H1>
-<DL>
-<%
-local myform = form.info
-local tags = { "status", "version", "autostart", }
-displayinfo(myform,tags,"viewonly")
-%>
-</DL>
-
-<H2>General information</H2>
-<p>
-Squid is a web proxy server. It makes web requests in behalf of the client, and
-inspecting the returned and optionally caches that content so that the next time
-a client request is made, the content can be served from local disk. This can make
-web surfing faster. Squid can also forward its requests on to a content filter,
-such as DansGuardian.</p>
-
-
+../status-html.lsp \ No newline at end of file
diff --git a/squid.menu b/squid.menu
index 359f8db..102e0a8 100644
--- a/squid.menu
+++ b/squid.menu
@@ -2,7 +2,7 @@
# Cat Group Tab Action
Applications 10Web_Proxy Status status
Applications 10Web_Proxy Basic basic
-Applications 10Web_Proxy Advanced advanced
Applications 10Web_Proxy Authentication authentication
Applications 10Web_Proxy Auth_Digest digest
Applications 10Web_Proxy Special_Access saccess
+Applications 10Web_Proxy Expert expert
diff --git a/squid.roles b/squid.roles
index 93d6b33..61843c9 100644
--- a/squid.roles
+++ b/squid.roles
@@ -1,2 +1,2 @@
READ=squid:status
-UPDATE=squid:basic,squid:dep,squid:authentication,squid:advanced,squid:digest,squid:saccess
+UPDATE=squid:basic,squid:dep,squid:authentication,squid:expert,squid:digest,squid:saccess,squid:startstop