summaryrefslogtreecommitdiffstats
path: root/openntpd-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'openntpd-model.lua')
-rw-r--r--openntpd-model.lua17
1 files changed, 10 insertions, 7 deletions
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)