diff options
-rw-r--r-- | openntpd-model.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/openntpd-model.lua b/openntpd-model.lua index 2c77e39..52bffd3 100644 --- a/openntpd-model.lua +++ b/openntpd-model.lua @@ -3,7 +3,7 @@ module (..., package.seeall) -- Load libraries require("modelfunctions") require("fs") -require("getopts") +require("format") -- Set variables local configfile = "/etc/ntpd.conf" @@ -83,7 +83,8 @@ function read_config () end end - if getopts.getoptsfromfile(confdfile, "", "NTPD_OPTS", true, "-s") then + local opts = string.sub(format.parse_configfile2(fs.read_file(confdfile), "", "NTPD_OPTS"), 2, -2) + if format.opts_to_table(opts, "-s") then config.setstimeonstartup.value = true end @@ -137,7 +138,7 @@ function update_config(config) -- Finally, handle setstimeonstartup local opts = {} if config.value.setstimeonstartup.value then opts["-s"] = "" end - getopts.setoptsinfile(confdfile, "", "NTPD_OPTS", '"'..getopts.table_to_opts(opts)..'"') + fs.write_file(confdfile, format.update_configfile2(fs.read_file(confdfile) or "", "", "NTPD_OPTS", '"'..format.table_to_opts(opts)..'"')) else config.errtxt = "Failed to save config" end |