summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-05-07 17:37:37 +0000
committerTed Trask <ttrask01@yahoo.com>2008-05-07 17:37:37 +0000
commit4edb509c7cd97280eb93d1ec87e5b2ed310de056 (patch)
tree8637b3648654d7cb46c7e1c02c1ac300e91c85be
parent1e19837422b9dcab2de6b461716f7e3f9c4597a6 (diff)
downloadacf-alpine-baselayout-4edb509c7cd97280eb93d1ec87e5b2ed310de056.tar.bz2
acf-alpine-baselayout-4edb509c7cd97280eb93d1ec87e5b2ed310de056.tar.xz
Rewrote getopts.getoptsfromfile function to handle more complicated config files and removed getopts.getoptsfromfile_onperline function
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1111 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--syslog-model.lua29
1 files changed, 13 insertions, 16 deletions
diff --git a/syslog-model.lua b/syslog-model.lua
index 0709883..f7aaa08 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -101,10 +101,7 @@ end
function getconfig()
local config = {}
if (fs.is_file(configfile)) then
- configcontent = getopts.getoptsfromfile(configfile) or config
- if (type(config["SYSLOGD_OPTS"]) == "string") then
- config["SYSLOGD_OPTS"] = {}
- end
+ configcontent = getopts.getoptsfromfile(configfile, "", "SYSLOGD_OPTS", true) or {}
else
config["configfile"] = "Config file '".. configfile .. "' is missing!"
end
@@ -112,12 +109,12 @@ function getconfig()
config["logfile"] = cfe({
name="logfile",
label = "Log to given file",
- value = configcontent["SYSLOGD_OPTS"]["-O"] or "/var/log/messages",
+ value = configcontent["-O"] or "/var/log/messages",
})
config["loglevel"] = cfe({
name="loglevel",
label = "Set local log level",
- value = tonumber(configcontent["SYSLOGD_OPTS"]["-l"]) or 8,
+ value = tonumber(configcontent["-l"]) or 8,
type = "select",
option = getloglevels(),
descr = "1=Quiet, ... , " .. table.maxn(getloglevels()) .. "=Debug",
@@ -125,7 +122,7 @@ function getconfig()
config["smallerlogs"] = cfe({
name="smallerlogs",
label = "Smaller logging output",
- checked = configcontent["SYSLOGD_OPTS"]["-S"],
+ checked = configcontent["-S"],
value = "smallerlogs",
type = "checkbox",
})
@@ -133,17 +130,17 @@ function getconfig()
name="maxsize",
label = "Max size (KB) before rotate",
descr = "Default=200KB, 0=off",
- value = configcontent["SYSLOGD_OPTS"]["-s"],
+ value = configcontent["-s"],
})
config["numrotate"] = cfe ({ name="numrotate",
label = "Number of rotated logs to keep",
descr = "Default=1, max=99, 0=purge",
- value = configcontent["SYSLOGD_OPTS"]["-b"],
+ value = configcontent["-b"],
})
config["localandnetworklog"] = cfe ({
name="localandnetworklog",
label = "Log locally and via network",
- checked = configcontent["SYSLOGD_OPTS"]["-L"],
+ checked = configcontent["-L"],
value = "localandnetworklog",
type = "checkbox",
descr = "Default is network only if -R",
@@ -152,19 +149,19 @@ function getconfig()
name="remotelogging",
label = "Log to IP or hostname on PORT",
descr = "host[:PORT] - Default PORT=514/UDP",
- value = configcontent["SYSLOGD_OPTS"]["-R"],
+ value = configcontent["-R"],
})
-- Next section is to print errormessages when configs are wrong
- if (configcontent["SYSLOGD_OPTS"]["-l"]) and
- ((tonumber(configcontent["SYSLOGD_OPTS"]["-l"]) == nil) or (tonumber(configcontent["SYSLOGD_OPTS"]["-l"]) > 8)) then
+ if (configcontent["-l"]) and
+ ((tonumber(configcontent["-l"]) == nil) or (tonumber(configcontent["-l"]) > 8)) then
config["loglevel"]["errtxt"] = "Log value is out of range!\nCurrent value in config is '" ..
- configcontent["SYSLOGD_OPTS"]["-l"] ..
+ configcontent["-l"] ..
"' - This is invalid!\nPlease select one of the above and save your changes."
- table.insert(config["loglevel"]["option"], tonumber(configcontent["SYSLOGD_OPTS"]["-l"]))
+ table.insert(config["loglevel"]["option"], tonumber(configcontent["-l"]))
end
- if (configcontent["SYSLOGD_OPTS"]["-L"] ~= nil) and ((configcontent["SYSLOGD_OPTS"]["-R"] == nil) or (configcontent["SYSLOGD_OPTS"]["-R"] == "")) then
+ if (configcontent["-L"] ~= nil) and ((configcontent["-R"] == nil) or (configcontent["-R"] == "")) then
config["localandnetworklog"]["errtxt"] = "Logging to local and network (-L) is not possible unless you define a host (-R) for remote logging or remove this option."
end