summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile44
-rw-r--r--README0
-rw-r--r--config.mk11
-rw-r--r--fetchcrl-controller.lua19
l---------fetchcrl-expert-html.lsp1
-rw-r--r--fetchcrl-model.lua64
-rw-r--r--fetchcrl-startstop-html.lsp21
l---------fetchcrl-status-html.lsp1
-rw-r--r--fetchcrl.menu4
-rw-r--r--fetchcrl.roles3
10 files changed, 168 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e8083d3
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+APP_NAME=fetch-crl
+PACKAGE=acf-$(APP_NAME)
+VERSION=0.1.0
+
+APP_DIST=\
+ fetchcrl* \
+
+
+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..e69de29
--- /dev/null
+++ b/README
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..b859a2b
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,11 @@
+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
+squid-cfg-dir=/etc/squid
diff --git a/fetchcrl-controller.lua b/fetchcrl-controller.lua
new file mode 100644
index 0000000..0b957ba
--- /dev/null
+++ b/fetchcrl-controller.lua
@@ -0,0 +1,19 @@
+-- the fetch-crl controller
+
+module (..., package.seeall)
+
+require("controllerfunctions")
+
+default_action = "status"
+
+status = function( self )
+ return self.model.get_status()
+end
+
+startstop = function( self )
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.get_status, self.clientdata)
+end
+
+expert = function( self )
+ return controllerfunctions.handle_form(self, self.model.get_configfile, self.model.update_configfile, self.clientdata, "Save", "Edit Configuration", "Configuration Saved")
+end
diff --git a/fetchcrl-expert-html.lsp b/fetchcrl-expert-html.lsp
new file mode 120000
index 0000000..207f324
--- /dev/null
+++ b/fetchcrl-expert-html.lsp
@@ -0,0 +1 @@
+../expert-html.lsp \ No newline at end of file
diff --git a/fetchcrl-model.lua b/fetchcrl-model.lua
new file mode 100644
index 0000000..7f34c9c
--- /dev/null
+++ b/fetchcrl-model.lua
@@ -0,0 +1,64 @@
+module (..., package.seeall)
+
+-- Load libraries
+require("modelfunctions")
+require("processinfo")
+require("fs")
+require("format")
+
+-- Set variables
+local packagename = "fetch-crl"
+local configfile = "/etc/fetch-crl/fetch-crl"
+local outputdirectory = "/etc/grid-security/certificates"
+
+local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+get_status = function()
+ local status = {}
+
+ local value, errtxt = processinfo.package_version(packagename)
+ status.version = cfe({
+ label="Program version",
+ value=value,
+ errtxt=errtxt,
+ name=packagename
+ })
+
+ return cfe({ type="group", value=status, label="Fetch-CRL Status" })
+end
+
+function startstop_service(action)
+ local cmdresult = cfe({ label="Start/Stop result" })
+
+ if (string.lower(action) == "download") then
+ local file = io.popen(path .. "fetch-crl 2>&1")
+ if file ~= nil then
+ cmdresult.value = file:read( "*a" )
+ file:close()
+ end
+ elseif (string.lower(action) == "delete") then
+ local config = format.parse_configfile(fs.read_file(configfile) or "")
+ local dir = config.CRLDIR or outputdirectory
+ for file in fs.find(".*\.r0", dir) do
+ os.remove(file)
+ end
+ cmdresult.value = "Deleted CRL Files"
+ else
+ cmdresult.errtxt = "Unknown command!"
+ end
+ return cmdresult
+end
+
+get_configfile = function()
+ return modelfunctions.getfiledetails(configfile)
+end
+
+update_configfile = function(filedetails)
+ return modelfunctions.setfiledetails(filedetails, {configfile})
+end
diff --git a/fetchcrl-startstop-html.lsp b/fetchcrl-startstop-html.lsp
new file mode 100644
index 0000000..b28dc97
--- /dev/null
+++ b/fetchcrl-startstop-html.lsp
@@ -0,0 +1,21 @@
+<% local data, viewlibrary, page_info = ... %>
+
+<H1>Management</H1>
+<DL>
+<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action) %>" method="POST">
+<DT>Download CRL</DT>
+<DD><input class="submit" type="submit" name="action" value="Download"></DD>
+<DT>Delete Local CRLs</DT>
+<DD><input class="submit" type="submit" name="action" value="Delete"></DD>
+</form>
+
+<% if data.value.result then %>
+<DT>Previous action result</DT>
+<DD>
+<% if data.value.result.value ~= "" then %>
+<P CLASS='descr'><%= string.gsub(html.html_escape(data.value.result.value), "\n", "<BR>") %></P>
+<% end if data.value.result.errtxt then %>
+<P CLASS='error'><%= string.gsub(html.html_escape(data.value.result.errtxt), "\n", "<BR>") %></P>
+<% end end %>
+</DD>
+</DL>
diff --git a/fetchcrl-status-html.lsp b/fetchcrl-status-html.lsp
new file mode 120000
index 0000000..b2f8480
--- /dev/null
+++ b/fetchcrl-status-html.lsp
@@ -0,0 +1 @@
+../status-html.lsp \ No newline at end of file
diff --git a/fetchcrl.menu b/fetchcrl.menu
new file mode 100644
index 0000000..a9bf42a
--- /dev/null
+++ b/fetchcrl.menu
@@ -0,0 +1,4 @@
+# Prefix and controller are already known at this point
+# Cat Group Tab Action
+Applications 95Fetch_CRL Status status
+Applications 95Fetch_CRL Expert expert
diff --git a/fetchcrl.roles b/fetchcrl.roles
new file mode 100644
index 0000000..db9defd
--- /dev/null
+++ b/fetchcrl.roles
@@ -0,0 +1,3 @@
+USER=fetchcrl:status,fetchcrl:startstop
+EXPERT=fetchcrl:expert
+ADMIN=fetchcrl:status,fetchcrl:startstop,fetchcrl:expert