diff options
-rw-r--r-- | chrony-model.lua | 24 | ||||
l--------- | chrony-startstop-html.lsp | 1 |
2 files changed, 24 insertions, 1 deletions
diff --git a/chrony-model.lua b/chrony-model.lua index 517efa4..269b96c 100644 --- a/chrony-model.lua +++ b/chrony-model.lua @@ -53,6 +53,30 @@ end -- PUBLIC FUNCTIONS function startstop_service(action) + local lower = action:lower() + if lower == "online" or lower == "offline" then + local retval = cfe({ label="Start/Stop result" }) + -- try to find the password + local config = get_config() + if config.value.keyfile.value == "" then + retval.errtxt = "No key file defined" + elseif config.value.commandkey.value == "" then + retval.errtxt = "No command key defined" + else + local content = fs.read_file(config.value.keyfile.value) or "" + local password = string.match("\n"..content, "\n"..config.value.commandkey.value.."%s+(%S+)") + if not password then + retval.errtxt = "Could not find password in key file" + else + local cmd = path.."chronyc <<EOF\npassword "..password.."\n"..lower.."\nEOF" + local f = io.popen(cmd) + retval.value = f:read("*a") + f:close() + if not retval.value then retval.errtxt = "Command failed" end + end + end + return retval + end return modelfunctions.startstop_service(processname, action) end diff --git a/chrony-startstop-html.lsp b/chrony-startstop-html.lsp deleted file mode 120000 index 0ea2627..0000000 --- a/chrony-startstop-html.lsp +++ /dev/null @@ -1 +0,0 @@ -../startstop-html.lsp
\ No newline at end of file |