module (..., package.seeall) -- Load libraries require("modelfunctions") processinfo = require("acf.processinfo") fs = require("acf.fs") format = require("acf.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 get_startstop(self, clientdata) local actions = {"Download", "Delete"} return cfe({ type="group", label="Management", value={}, option=actions }) end function startstop_service(self, startstop, action) if (string.lower(action) == "download") then local file = io.popen(path .. "fetch-crl 2>&1") if file ~= nil then startstop.descr = 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 startstop.descr = "Deleted CRL Files" else startstop.errtxt = "Unknown command!" end return startstop end get_configfile = function() return modelfunctions.getfiledetails(configfile) end update_configfile = function(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, {configfile}) end