diff options
Diffstat (limited to 'fetchcrl-model.lua')
-rw-r--r-- | fetchcrl-model.lua | 36 |
1 files changed, 20 insertions, 16 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() |