From 6f8bd836d7be61dd04b3521a2ffefe7e927de18d Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Fri, 7 Dec 2007 10:36:41 +0000 Subject: Cleaning up code. Adding functionallity to add/remove listen address. Error message displayed when something is missing for the desired action. The controller keeps track of things needed before asking the model. git-svn-id: svn://svn.alpinelinux.org/acf/openntpd/trunk@418 ab2d0c66-481e-0410-8bed-d214d4d58bed --- openntpd-model.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'openntpd-model.lua') diff --git a/openntpd-model.lua b/openntpd-model.lua index 454db5d..f74f941 100644 --- a/openntpd-model.lua +++ b/openntpd-model.lua @@ -141,18 +141,22 @@ local addremove_config = function ( addremove, file, variable ) -- Notes on known/unknown bugs: Remove 'server www.test.org' wont work if config has multiple space/tab e.g. 'server www.test.org' -- FIXME: Make num-space unsensetive. -- FIXME: Can hold multiple rows with same values (when deleting... every equal row is deleted) - if (string.lower(addremove) == "delete" ) then + local cmdoutput = nil + if (addremove == "delete" ) then cmdtxt = "/bin/sed -i '/" .. variable .. "/d' " .. file local cmd, error = io.popen ( cmdtxt ) - local cmdoutput = cmd:read("*a") + cmdoutput = cmd:read("*a") cmd:close() - elseif (string.lower(addremove) == "add" ) then + elseif (addremove == "add" ) then cmdtxt = "/bin/echo '" .. variable .. "' >> " .. file local cmd, error = io.popen ( cmdtxt ) - local cmdoutput = cmd:read("*a") + cmdoutput = cmd:read("*a") cmd:close() end - return cmdtxt + if (cmdoutput) then + cmdresult = "Config is modified! (" .. cmdtxt .. ")" + end + return cmdresult end -- ################################################################################ -- PUBLIC FUNCTIONS @@ -171,13 +175,12 @@ function startstop_service ( self, state ) end -function modify_config (self, addremove, file, variable, opts) +function modify_config (self, addremove, file, variable) if (file == nil) then file = ntpdconfig end -- See to that only *my* configs are modyfied. if (file == ntpdconfig) or (file == ntpdconfd) then return addremove_config(addremove, file, variable) end - end function modify_opts (self, addremove, file, variable, opts) -- cgit v1.2.3