summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Bilyk <jbilyk@gmail.com>2011-10-01 15:05:37 +0000
committerJeff Bilyk <jbilyk@gmail.com>2011-10-01 15:05:37 +0000
commit4aa007e7d9c4d1c58b9e80cb375a6bd92661072a (patch)
tree92f7c515733214e669eb326cafeb0e78e9a4a666
downloadacf-lighttpd-4aa007e7d9c4d1c58b9e80cb375a6bd92661072a.tar.bz2
acf-lighttpd-4aa007e7d9c4d1c58b9e80cb375a6bd92661072a.tar.xz
acf-lighttpd: initial commit
-rw-r--r--Makefile44
-rw-r--r--README1
-rw-r--r--config.mk10
-rw-r--r--lighttpd-controller.lua33
-rw-r--r--lighttpd-details.html.lsp12
l---------lighttpd-expert-html.lsp1
-rw-r--r--lighttpd-listfiles-html.lsp27
-rw-r--r--lighttpd-logfile-html.lsp9
-rw-r--r--lighttpd-model.lua74
l---------lighttpd-startstop-html.lsp1
l---------lighttpd-status-html.lsp1
-rw-r--r--lighttpd.menu4
-rw-r--r--lighttpd.roles3
13 files changed, 220 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..bfd7f9a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+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
diff --git a/README b/README
new file mode 100644
index 0000000..36f6a79
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+ACF for lighttpd
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..45f4d21
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,10 @@
+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
diff --git a/lighttpd-controller.lua b/lighttpd-controller.lua
new file mode 100644
index 0000000..72da42e
--- /dev/null
+++ b/lighttpd-controller.lua
@@ -0,0 +1,33 @@
+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
diff --git a/lighttpd-details.html.lsp b/lighttpd-details.html.lsp
new file mode 100644
index 0000000..8f1363e
--- /dev/null
+++ b/lighttpd-details.html.lsp
@@ -0,0 +1,12 @@
+<% local data, viewlibrary = ...
+require("viewfunctions")
+%>
+
+<% viewlibrary.dispatch_component("status") %>
+
+<H2><%= html.html_escape(data.label) %></H2>
+<DL>
+<%
+displayitem(data)
+%>
+</DL>
diff --git a/lighttpd-expert-html.lsp b/lighttpd-expert-html.lsp
new file mode 120000
index 0000000..15b1930
--- /dev/null
+++ b/lighttpd-expert-html.lsp
@@ -0,0 +1 @@
+../filedetails-html.lsp \ No newline at end of file
diff --git a/lighttpd-listfiles-html.lsp b/lighttpd-listfiles-html.lsp
new file mode 100644
index 0000000..374146c
--- /dev/null
+++ b/lighttpd-listfiles-html.lsp
@@ -0,0 +1,27 @@
+<% 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>
diff --git a/lighttpd-logfile-html.lsp b/lighttpd-logfile-html.lsp
new file mode 100644
index 0000000..fbe7221
--- /dev/null
+++ b/lighttpd-logfile-html.lsp
@@ -0,0 +1,9 @@
+<% 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 %>
diff --git a/lighttpd-model.lua b/lighttpd-model.lua
new file mode 100644
index 0000000..53c8310
--- /dev/null
+++ b/lighttpd-model.lua
@@ -0,0 +1,74 @@
+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
diff --git a/lighttpd-startstop-html.lsp b/lighttpd-startstop-html.lsp
new file mode 120000
index 0000000..0ea2627
--- /dev/null
+++ b/lighttpd-startstop-html.lsp
@@ -0,0 +1 @@
+../startstop-html.lsp \ No newline at end of file
diff --git a/lighttpd-status-html.lsp b/lighttpd-status-html.lsp
new file mode 120000
index 0000000..b2f8480
--- /dev/null
+++ b/lighttpd-status-html.lsp
@@ -0,0 +1 @@
+../status-html.lsp \ No newline at end of file
diff --git a/lighttpd.menu b/lighttpd.menu
new file mode 100644
index 0000000..f230ca8
--- /dev/null
+++ b/lighttpd.menu
@@ -0,0 +1,4 @@
+#CAT GROUP/DESC TAB ACTION
+Applications 91lighttpd Status details
+Applications 91lighttpd Expert listfiles
+Applications 91lighttpd Logfile logfile
diff --git a/lighttpd.roles b/lighttpd.roles
new file mode 100644
index 0000000..9407dc4
--- /dev/null
+++ b/lighttpd.roles
@@ -0,0 +1,3 @@
+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