From 2b516983f2168b85b6cc94c976a1b29cad0f95bb Mon Sep 17 00:00:00 2001 From: ttrask Date: Tue, 17 Mar 2009 20:39:56 +0000 Subject: Changed the way startstop works in core to add a list of allowed actions. Modified all ACFs that don't use the standard functions to work with new library method. git-svn-id: svn://svn.alpinelinux.org/acf/chrony/trunk@1730 ab2d0c66-481e-0410-8bed-d214d4d58bed --- chrony-model.lua | 47 ++++++++++++++++++++++++++--------------------- chrony-startstop-html.lsp | 19 +++++++++---------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/chrony-model.lua b/chrony-model.lua index c1001ed..14e8082 100644 --- a/chrony-model.lua +++ b/chrony-model.lua @@ -67,31 +67,36 @@ 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" + 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" 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
@@ -15,14 +24,4 @@ >
- -<% 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 %> -
-- cgit v1.2.3