diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-01-24 16:48:28 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-01-24 16:48:28 +0000 |
commit | 7b5422d3943e6243d3b48da4f24cc024c01e49bb (patch) | |
tree | 1deb2b2e9d47a3f43a54f7b0140baa6cb8958315 /syslog-model.lua | |
parent | 4aaf7226430f480eb75e3653958d2f1f448fc186 (diff) | |
download | acf-alpine-baselayout-7b5422d3943e6243d3b48da4f24cc024c01e49bb.tar.bz2 acf-alpine-baselayout-7b5422d3943e6243d3b48da4f24cc024c01e49bb.tar.xz |
Fixed so that acf doesnt brake if the confi-file is missing or is empty
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@641 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'syslog-model.lua')
-rw-r--r-- | syslog-model.lua | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/syslog-model.lua b/syslog-model.lua index 1d402d3..6fa4bce 100644 --- a/syslog-model.lua +++ b/syslog-model.lua @@ -6,6 +6,7 @@ require("getopts") require("format") local configfile = "/etc/conf.d/syslog" +local config = {} local function get_version() local cmd = "/sbin/apk_version -v -s busybox | cut -d ' ' -f 1" @@ -30,10 +31,10 @@ function getstatus() local status = {} status.version = get_version() status.enabled = procps.pidof("syslogd") - if not ((opts["SYSLOGD_OPTS"]["-R"] ~= "") and not (opts["SYSLOGD_OPTS"]["-L"])) then + if (opts["SYSLOGD_OPTS"]) and not ((opts["SYSLOGD_OPTS"]["-R"] ~= "") and not (opts["SYSLOGD_OPTS"]["-L"])) then status.logfile = opts["SYSLOGD_OPTS"]["-O"] end - if (opts["SYSLOGD_OPTS"]["-R"]) and (opts["SYSLOGD_OPTS"]["-R"] ~= "") then + if (opts["SYSLOGD_OPTS"]) and (opts["SYSLOGD_OPTS"]["-R"]) and (opts["SYSLOGD_OPTS"]["-R"] ~= "") then status.remote = opts["SYSLOGD_OPTS"]["-R"] end return status @@ -42,25 +43,35 @@ end function get_filedetails() local filedetails = {} local path = configfile - filedetails.details = fs.stat(path) - filedetails.content = fs.read_file(path) + if (fs.is_file(path)) then + filedetails.details = fs.stat(path) + filedetails.content = fs.read_file(path) + else + filedetails.details = {path="File is missing", size="0",mtime=""} + filedetails.content = "" + end return filedetails end function getconfig() local errors = {} errors["SYSLOGD_OPTS"] = {} errors["KLOGD_OPTS"] = {} - local config = getopts.getoptsfromfile(configfile) + if (fs.is_file(configfile)) then + config = getopts.getoptsfromfile(configfile) + else + config['SYSLOGD_OPTS']={} + end config["SYSLOGD_OPTS"]["-O"] = config["SYSLOGD_OPTS"]["-O"] or "/var/log/messages" config["SYSLOGD_OPTS"]["-l_list"] = getloglevels() config["SYSLOGD_OPTS"]["-R"] = config["SYSLOGD_OPTS"]["-R"] or "" + config["SYSLOGD_OPTS"]["-s"] = config["SYSLOGD_OPTS"]["-s"] or "" + config["SYSLOGD_OPTS"]["-b"] = config["SYSLOGD_OPTS"]["-b"] or "" if (config["SYSLOGD_OPTS"]["-l"]) and ((tonumber(config["SYSLOGD_OPTS"]["-l"]) == nil) or (tonumber(config["SYSLOGD_OPTS"]["-l"]) > 8)) then errors["SYSLOGD_OPTS"]["-l"] = "Log value is out of range. Please select one of the above." else config["SYSLOGD_OPTS"]["-l"] = config["SYSLOGD_OPTS"]["-l"] or 8 end - return config, errors end |