From 4aa007e7d9c4d1c58b9e80cb375a6bd92661072a Mon Sep 17 00:00:00 2001 From: Jeff Bilyk Date: Sat, 1 Oct 2011 15:05:37 +0000 Subject: acf-lighttpd: initial commit --- Makefile | 44 +++++++++++++++++++++++++++ README | 1 + config.mk | 10 ++++++ lighttpd-controller.lua | 33 ++++++++++++++++++++ lighttpd-details.html.lsp | 12 ++++++++ lighttpd-expert-html.lsp | 1 + lighttpd-listfiles-html.lsp | 27 +++++++++++++++++ lighttpd-logfile-html.lsp | 9 ++++++ lighttpd-model.lua | 74 +++++++++++++++++++++++++++++++++++++++++++++ lighttpd-startstop-html.lsp | 1 + lighttpd-status-html.lsp | 1 + lighttpd.menu | 4 +++ lighttpd.roles | 3 ++ 13 files changed, 220 insertions(+) create mode 100644 Makefile create mode 100644 README create mode 100644 config.mk create mode 100644 lighttpd-controller.lua create mode 100644 lighttpd-details.html.lsp create mode 120000 lighttpd-expert-html.lsp create mode 100644 lighttpd-listfiles-html.lsp create mode 100644 lighttpd-logfile-html.lsp create mode 100644 lighttpd-model.lua create mode 120000 lighttpd-startstop-html.lsp create mode 120000 lighttpd-status-html.lsp create mode 100644 lighttpd.menu create mode 100644 lighttpd.roles 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") %> + +

<%= html.html_escape(data.label) %>

+
+<% +displayitem(data) +%> +
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 %> + +

<%= html.html_escape(data.label) %>

+
+ + + + + + + +<% for i,file in ipairs(data.value) do %> + + + + + +<% end %> +
FileSizeLast Modified
<%= html.link{value = "expert?filename=" .. file.filename.."&redir="..page_info.orig_action, label=file.filename} %><%= html.html_escape(file.filesize) %><%= html.html_escape(file.mtime) %>
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 -- cgit v1.2.3