Commit 4aa007e7 authored by Jeff Bilyk's avatar Jeff Bilyk

acf-lighttpd: initial commit

parents
APP_NAME=lighttpd
PACKAGE=acf-$(APP_NAME)
VERSION=0.3.0
APP_DIST=\
lightpd* \
EXTRA_DIST=README Makefile config.mk
DISTFILES=$(APP_DIST) $(EXTRA_DIST)
TAR=tar
P=$(PACKAGE)-$(VERSION)
tarball=$(P).tar.bz2
install_dir=$(DESTDIR)/$(appdir)/$(APP_NAME)
all:
clean:
rm -rf $(tarball) $(P)
dist: $(tarball)
install:
mkdir -p "$(install_dir)"
cp -a $(APP_DIST) "$(install_dir)"
$(tarball): $(DISTFILES)
rm -rf $(P)
mkdir -p $(P)
cp -a $(DISTFILES) $(P)
$(TAR) -jcf $@ $(P)
rm -rf $(P)
# target that creates a tar package, unpacks is and install from package
dist-install: $(tarball)
$(TAR) -jxf $(tarball)
$(MAKE) -C $(P) install DESTDIR=$(DESTDIR)
rm -rf $(P)
include config.mk
.PHONY: all clean dist install dist-install
ACF for lighttpd
prefix=/usr
datadir=${prefix}/share
sysconfdir=${prefix}/etc
localstatedir=${prefix}/var
acfdir=${datadir}/acf
wwwdir=${acfdir}/www
cgibindir=${acfdir}/cgi-bin
appdir=${acfdir}/app
acflibdir=${acfdir}/lib
sessionsdir=${localstatedir}/lib/acf/sessions
module(..., package.seeall)
-- Load libraries
require("controllerfunctions")
default_action = "status"
function status(self)
return self.model.getstatus()
end
function startstop(self)
return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.clientdata)
end
function details(self)
return self.model.getstatusdetails()
end
function listfiles(self)
return self.model.getfilelist()
end
function expert(self)
return controllerfunctions.handle_form(self, function() return
self.model.getfiledetails(self.clientdata.filename) end,
self.model.updatefiledetails, self.clientdata, "Save", "Edit Lighttpd
File", "File Saved")
end
function logfile(self)
return self.model.getlogfile()
end
<% local data, viewlibrary = ...
require("viewfunctions")
%>
<% viewlibrary.dispatch_component("status") %>
<H2><%= html.html_escape(data.label) %></H2>
<DL>
<%
displayitem(data)
%>
</DL>
../filedetails-html.lsp
\ No newline at end of file
<% local data, viewlibrary, page_info, session = ...
require("viewfunctions")
%>
<% displaycommandresults({"expert"}, session) %>
<% if viewlibrary and viewlibrary.dispatch_component then
viewlibrary.dispatch_component("status")
end %>
<h1><%= html.html_escape(data.label) %></h1>
<DL><TABLE>
<TR style="background:#eee;font-weight:bold;">
<TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">File</TD>
<TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">Size</TD>
<TD style="white-space:nowrap;text-align:left;" class="header">Last Modified</TD>
</TR>
<% for i,file in ipairs(data.value) do %>
<TR>
<TD style="padding-right:20px;white-space:nowrap;"><%= html.link{value = "expert?filename=" .. file.filename.."&redir="..page_info.orig_action, label=file.filename} %></TD>
<TD style="padding-right:20px;white-space:nowrap;"><%= html.html_escape(file.filesize) %></TD>
<TD style="white-space:nowrap;" width="90%"><%= html.html_escape(file.mtime) %></TD>
</TR>
<% end %>
</TABLE></DL>
<% local data, viewlibrary = ...
require("viewfunctions")
%>
<% if viewlibrary and viewlibrary.dispatch_component then
for i,logfile in ipairs(data.value) do
viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {name=logfile.path, grep=logfile.grep})
end
end %>
module(..., package.seeall)
-- Load libraries
require("modelfunctions")
require("fs")
require("format")
-- Set variables
local processname = "lighttpd"
local packagename = "lighttpd"
local filelist = {"/etc/lighttpd/lightpd.conf",
"/etc/lighttpd/mod_cgi.conf"}
local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
-- ################################################################################
-- LOCAL FUNCTIONS
-- ################################################################################
-- PUBLIC FUNCTIONS
function startstop_service(action)
return modelfunctions.startstop_service(processname, action)
end
function getstatus()
return modelfunctions.getstatus(processname, packagename,
"Lighttpd Status")
end
function getstatusdetails()
return cfe({ type="longtext", value="", label="Lighttpd Status
Details" })
end
function getfilelist()
local listed_files = {}
for i,name in ipairs(filelist) do
local filedetails = fs.stat(name) or {}
table.insert ( listed_files , {filename=name, mtime=filedetails.mtime or "---", filesize=filedetails.size or "0"} )
end
table.sort(listed_files, function (a,b) return (a.filename < b.filename) end )
return cfe({ type="list", value=listed_files, label="Lighttpd
File List" })
end
function getfiledetails(filename)
return modelfunctions.getfiledetails(filename, filelist)
end
function updatefiledetails(filedetails)
return modelfunctions.setfiledetails(filedetails, filelist)
end
function getlogfile ()
local files = {}
local logfilepath = format.parse_configfile(fs.read_file(filelist[1]) or "").LogFile
if not logfilepath then
files[#files+1] = {path =
"/var/log/lighttpd/access.log"}
else
files[#files+1] = {path=logfilepath}
end
logfilepath = format.parse_configfile(fs.read_file(filelist[2]) or "").UpdateLogFile
if not logfilepath then
files[#files+1] = {path = "/var/log/eror.log"}
else
files[#files+1] = {path=logfilepath}
end
return cfe({ value=files, label="Lighttpd logfiles" })
end
../startstop-html.lsp
\ No newline at end of file
../status-html.lsp
\ No newline at end of file
#CAT GROUP/DESC TAB ACTION
Applications 91lighttpd Status details
Applications 91lighttpd Expert listfiles
Applications 91lighttpd Logfile logfile
USER=lighttpd:status,lighttpd:logfile,lighttpd:details,lighttpd:startstop
EXPERT=lighttpd:listfiles,lighttpd:expert
ADMIN=lighttpd:status,lighttpd:logfile,lighttpd:details,lighttpd:startstop,lighttpd:listfiles,lighttpd:expert
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment