summaryrefslogtreecommitdiffstats
path: root/chrony-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'chrony-model.lua')
-rw-r--r--chrony-model.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/chrony-model.lua b/chrony-model.lua
index 269b96c..ec0301d 100644
--- a/chrony-model.lua
+++ b/chrony-model.lua
@@ -49,6 +49,20 @@ function validate_config(config)
return success, config
end
+local function get_keyfilestatus(filedetails)
+ filedetails.value.filecontent.descr = "List of password numbers and passwords (ie. '10 cronpass')"
+
+ -- check to see if the file is being used
+ filedetails.value.status = cfe({ value="Key file in use", label="Key file status" })
+ local config = get_config()
+ if config.value.keyfile.value ~= keyfile then
+ filedetails.value.status.value = ""
+ filedetails.value.status.errtxt = "Key file is not in use"
+ end
+
+ return filedetails
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -184,6 +198,32 @@ function update_config(config)
return config
end
+function get_keyfiledetails()
+ return get_keyfilestatus(modelfunctions.getfiledetails(keyfile))
+end
+
+function update_keyfiledetails(filedetails)
+ return get_keyfilestatus(modelfunctions.setfiledetails(filedetails, {keyfile}))
+end
+
+function enable_keyfile()
+ local result = cfe({ value="Enabled key file", label="Enable Key file result" })
+ local config = get_config()
+ config.value.keyfile.value = keyfile
+ config = update_config(config)
+ if config.errtxt then
+ result.value = ""
+ result.errtxt = {config.errtxt}
+ for name,val in pairs(config.value) do
+ if val.errtxt then
+ table.insert(result.errtxt, name.." - "..val.errtxt)
+ end
+ end
+ result.errtxt = table.concat(result.errtxt, "\n")
+ end
+ return result
+end
+
function get_filedetails()
-- FIXME validate
return modelfunctions.getfiledetails(configfile)