From 7b53b6cc73de349af77ecd73e00f60a9e679abd2 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 26 Feb 2009 15:40:33 +0000 Subject: Added fetch-crl ACF. git-svn-id: svn://svn.alpinelinux.org/acf/fetch-crl/trunk@1709 ab2d0c66-481e-0410-8bed-d214d4d58bed --- Makefile | 44 +++++++++++++++++++++++++++++++ README | 0 config.mk | 11 ++++++++ fetchcrl-controller.lua | 19 ++++++++++++++ fetchcrl-expert-html.lsp | 1 + fetchcrl-model.lua | 64 +++++++++++++++++++++++++++++++++++++++++++++ fetchcrl-startstop-html.lsp | 21 +++++++++++++++ fetchcrl-status-html.lsp | 1 + fetchcrl.menu | 4 +++ fetchcrl.roles | 3 +++ 10 files changed, 168 insertions(+) create mode 100644 Makefile create mode 100644 README create mode 100644 config.mk create mode 100644 fetchcrl-controller.lua create mode 120000 fetchcrl-expert-html.lsp create mode 100644 fetchcrl-model.lua create mode 100644 fetchcrl-startstop-html.lsp create mode 120000 fetchcrl-status-html.lsp create mode 100644 fetchcrl.menu create mode 100644 fetchcrl.roles 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 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 = ... %> + +

Management

+
+
" method="POST"> +
Download CRL
+
+
Delete Local CRLs
+
+
+ +<% if data.value.result then %> +
Previous action result
+
+<% if data.value.result.value ~= "" then %> +

<%= string.gsub(html.html_escape(data.value.result.value), "\n", "
") %>

+<% end if data.value.result.errtxt then %> +

<%= string.gsub(html.html_escape(data.value.result.errtxt), "\n", "
") %>

+<% end end %> +
+
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 -- cgit v1.2.3