summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-01-07 21:58:00 +0000
committerTed Trask <ttrask01@yahoo.com>2009-01-07 21:58:00 +0000
commitaef4c4ae706483964aaa7569dff7fb9458552ab8 (patch)
treeddba29a84686d3b021b547d261b26bf7c4f6a567
parent03af194d9cd96d5cc840dc780fab76d741bf4b50 (diff)
downloadacf-chrony-aef4c4ae706483964aaa7569dff7fb9458552ab8.tar.bz2
acf-chrony-aef4c4ae706483964aaa7569dff7fb9458552ab8.tar.xz
Modified chrony to add online/offline buttons to startstop. part 1
git-svn-id: svn://svn.alpinelinux.org/acf/chrony/trunk@1669 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--chrony-model.lua24
l---------chrony-startstop-html.lsp1
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