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 --- fetchcrl-model.lua | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 fetchcrl-model.lua (limited to 'fetchcrl-model.lua') 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 -- cgit v1.2.3