From 74632a4008ec27db2244f3ddeadabba58cc25f4c Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 17 Mar 2009 20:39:56 +0000 Subject: Changed the way startstop works in core to add a list of allowed actions. Modified all ACFs that don't use the standard functions to work with new library method. git-svn-id: svn://svn.alpinelinux.org/acf/fetch-crl/trunk@1730 ab2d0c66-481e-0410-8bed-d214d4d58bed --- fetchcrl-model.lua | 36 ++++++++++++++++++++---------------- fetchcrl-startstop-html.lsp | 19 +++++++++---------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/fetchcrl-model.lua b/fetchcrl-model.lua index 29617e4..a47543c 100644 --- a/fetchcrl-model.lua +++ b/fetchcrl-model.lua @@ -34,25 +34,29 @@ get_status = function() end function startstop_service(action) - local cmdresult = cfe({ label="Start/Stop result" }) + local result = {} + result.actions = cfe({ type="list", value={"download", "delete"}, label="Start/Stop actions" }) + if action then + result.result = 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() + if (string.lower(action) == "download") then + local file = io.popen(path .. "fetch-crl 2>&1") + if file ~= nil then + result.result.value = file:read( "*a" ) + file:close() + end + elseif (string.lower(action) == "delete") then + local config = format.parse_ini_file(fs.read_file(configfile) or "", "") + local dir = config.CRLDIR or outputdirectory + for file in fs.find(".*\.r0", dir) do + os.remove(file) + end + result.result.value = "Deleted CRL Files" + else + result.result.errtxt = "Unknown command!" end - elseif (string.lower(action) == "delete") then - local config = format.parse_ini_file(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 + return cfe({ type="group", value=result, label="Start/Stop result" }) end get_configfile = function() diff --git a/fetchcrl-startstop-html.lsp b/fetchcrl-startstop-html.lsp index b28dc97..3a5f6f7 100644 --- a/fetchcrl-startstop-html.lsp +++ b/fetchcrl-startstop-html.lsp @@ -1,21 +1,20 @@ <% local data, viewlibrary, page_info = ... %>

Management

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

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 %> -
+ +
+
" method="POST"> +
Download CRL
+
+
Delete Local CRLs
+
+
-- cgit v1.2.3