From 89d6fe43417668b06c24852c217a9487b1caa139 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 18 Apr 2012 16:03:38 +0000 Subject: Modified startstop to add Online and Offline buttons and remove custom view --- chrony-model.lua | 57 ++++++++++++++++++++++------------------------- chrony-startstop-html.lsp | 27 ---------------------- 2 files changed, 27 insertions(+), 57 deletions(-) delete mode 100644 chrony-startstop-html.lsp diff --git a/chrony-model.lua b/chrony-model.lua index 3f3f9ed..0a4ab7c 100644 --- a/chrony-model.lua +++ b/chrony-model.lua @@ -68,44 +68,41 @@ end -- PUBLIC FUNCTIONS function get_startstop(clientdata) - return modelfunctions.get_startstop(processname) + local retval = modelfunctions.get_startstop(processname) + retval.option[#retval.option+1] = "Online" + retval.option[#retval.option+1] = "Offline" + return retval end function startstop_service(startstop, action) - return modelfunctions.startstop_service(startstop, action) -end - -function old_startstop_service(action) - local result = modelfunctions.startstop_service(processname, action) - table.insert(result.value.actions.value, "Online") - table.insert(result.value.actions.value, "Offline") - if action then - local lower = action:lower() - if lower == "online" or lower == "offline" then - result.value.result.value = "" - result.value.result.errtxt = nil - -- try to find the password - local config = get_config() - if config.value.keyfile.value == "" then - result.value.result.errtxt = "No key file defined" - elseif config.value.commandkey.value == "" then - result.value.result.errtxt = "No command key defined" + local lower = action:lower() + if lower == "online" or lower == "offline" then + -- try to find the password + local config = get_config() + if config.value.keyfile.value == "" then + startstop.errtxt = "No key file defined" + elseif config.value.commandkey.value == "" then + startstop.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 + startstop.errtxt = "Could not find password in key file" 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 - result.value.result.errtxt = "Could not find password in key file" - else - local cmd = path.."chronyc < - -

Management

- -<% if data.value.result then %> -

Previous action result

-<% if data.value.result.value ~= "" then %> -

<%= string.gsub(html.html_escape(data.value.result.value), "\n", "
") %>

-<% end if data.value.result.errtxt then %> -

<%= string.gsub(html.html_escape(data.value.result.errtxt), "\n", "
") %>

-<% end end %> - -
-
" method="POST"> -
Program control-panel
-
- - - -
-
Connection control
-
- - -
-
-
-- cgit v1.2.3