From d7460a8bd3b2fd106957434e2c1ae5135f72fddd Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 1 Jan 2013 15:48:13 +0000 Subject: Replaced io.popen with modelfunctions.run_executable and subprocess.popen --- chrony-model.lua | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/chrony-model.lua b/chrony-model.lua index 0bc53d5..d63ec63 100644 --- a/chrony-model.lua +++ b/chrony-model.lua @@ -6,6 +6,8 @@ format = require("acf.format") fs = require("acf.fs") validator = require("acf.validator") processinfo = require("acf.processinfo") +require("subprocess") +require("posix") -- Set variables local configfile = "/etc/chrony/chrony.conf" @@ -89,13 +91,30 @@ function startstop_service(self, startstop, action) if not password then startstop.errtxt = "Could not find password in key file" else - local cmd = path.."chronyc < 0 then - local cmd = path.."chronyc sources" - local f = io.popen(cmd) - details.sources.value = f:read("*a") or "" - f:close() - cmd = path.."chronyc sourcestats" - f = io.popen(cmd) - details.sourcestats.value = f:read("*a") or "" - f:close() - cmd = path.."chronyc tracking" - f = io.popen(cmd) - details.tracking.value = f:read("*a") or "" - f:close() + details.sources.value, details.sources.errtxt = modelfunctions.run_executable({"chronyc", "sources"}) + details.sourcestats.value, details.sourcestats.errtxt = modelfunctions.run_executable({"chronyc", "sourcestats"}) + details.tracking.value, details.tracking.errtxt = modelfunctions.run_executable({"chronyc", "tracking"}) end return cfe({ type="group", value=details, label="Chrony Status Details" }) -- cgit v1.2.3