summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-04-18 16:03:38 +0000
committerTed Trask <ttrask01@yahoo.com>2012-04-18 16:03:38 +0000
commit89d6fe43417668b06c24852c217a9487b1caa139 (patch)
treed05cd69035d6502953a47174dc322a1c97195f2b
parent014a64f9b06cae003da8c2a5905277922807f5f1 (diff)
downloadacf-chrony-89d6fe43417668b06c24852c217a9487b1caa139.tar.bz2
acf-chrony-89d6fe43417668b06c24852c217a9487b1caa139.tar.xz
Modified startstop to add Online and Offline buttons and remove custom view
-rw-r--r--chrony-model.lua57
-rw-r--r--chrony-startstop-html.lsp27
2 files changed, 27 insertions, 57 deletions
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 <<EOF\npassword "..format.escapespecialcharacters(password).."\n"..lower.."\nEOF"
- local f = io.popen(cmd)
- result.value.result.value = f:read("*a") or ""
- f:close()
- if (result.value.result.value == "") then result.value.result.errtxt = "Command failed" end
+ local cmd = path.."chronyc <<EOF\npassword "..format.escapespecialcharacters(password).."\n"..lower.."\nEOF"
+ local f = io.popen(cmd)
+ startstop.descr = f:read("*a") or ""
+ f:close()
+ if (startstop.descr == "") then
+ startstop.descr = nil
+ startstop.errtxt = "Command failed"
end
end
end
+ else
+ startstop = modelfunctions.startstop_service(startstop, action)
end
- return result
+ return startstop
end
function getstatus()
diff --git a/chrony-startstop-html.lsp b/chrony-startstop-html.lsp
deleted file mode 100644
index 95c2a60..0000000
--- a/chrony-startstop-html.lsp
+++ /dev/null
@@ -1,27 +0,0 @@
-<% local data, viewlibrary, page_info = ... %>
-
-<H1>Management</H1>
-
-<% if data.value.result then %>
-<H2>Previous action result</H2>
-<% if data.value.result.value ~= "" then %>
-<P CLASS='descr'><%= string.gsub(html.html_escape(data.value.result.value), "\n", "<BR>") %></P>
-<% end if data.value.result.errtxt then %>
-<P CLASS='error'><%= string.gsub(html.html_escape(data.value.result.errtxt), "\n", "<BR>") %></P>
-<% end end %>
-
-<DL>
-<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action) %>" method="POST">
-<DT>Program control-panel</DT>
-<DD>
-<input class="submit" type="submit" name="action" value="Start">
-<input class="submit" type="submit" name="action" value="Stop">
-<input class="submit" type="submit" name="action" value="Restart">
-</DD>
-<DT>Connection control</DT>
-<DD>
-<input class="submit" type="submit" name="action" value="Online">
-<input class="submit" type="submit" name="action" value="Offline">
-</DD>
-</form>
-</DL>