diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-04-04 12:44:31 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-04-04 12:44:31 +0000 |
commit | 83273f459abc31ba8450d7abef3ff7deb609c42d (patch) | |
tree | a69b64af86df8580d110cf776013e47b7d351deb /openntpd-model.lua | |
parent | 8babf85857c2a4262401298f99063e77330c1f8d (diff) | |
download | acf-openntpd-83273f459abc31ba8450d7abef3ff7deb609c42d.tar.bz2 acf-openntpd-83273f459abc31ba8450d7abef3ff7deb609c42d.tar.xz |
Now showing config errors in the expert tab.
git-svn-id: svn://svn.alpinelinux.org/acf/openntpd/trunk@916 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'openntpd-model.lua')
-rw-r--r-- | openntpd-model.lua | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/openntpd-model.lua b/openntpd-model.lua index 78ea4c6..d537629 100644 --- a/openntpd-model.lua +++ b/openntpd-model.lua @@ -389,32 +389,64 @@ function get_logfile () return file end -function get_filedetails() - local path = configfile - local filedetails = fs.stat(path) +function get_filedetails(self,num) + local path + if (num == "2") then + path = configfile2 + else + path = configfile + end local file = {} + local filedetails = {} + local config = {} + local filenameerrtxt + if (path) and (fs.is_file(path)) then + filedetails = fs.stat(path) + config = getconfig(path) + else + config = {} + config.filename = {} + config["filename"]["errtxt"]="Config file '".. path .. "' is missing!" + end - file["filename"] = cfe({ - name="filename", + file["filename" .. (num or "")] = cfe({ + name="filename" .. (num or ""), label="File name", value=path, + errtxt=filenameerrtxt }) - file["filesize"] = cfe({ - name="filesize", + file["filesize" .. (num or "")] = cfe({ + name="filesize" .. (num or ""), label="File size", value=filedetails.size or 0, }) - file["mtime"] = cfe({ - name="mtime", + file["mtime" .. (num or "")] = cfe({ + name="mtime" .. (num or ""), label="File date", value=filedetails.mtime or "---", }) - file["filecontent"] = cfe({ + file["filecontent" .. (num or "")] = cfe({ type="longtext", - name="filecontent", + name="filecontent" .. (num or ""), label="File content", value=fs.read_file(path), }) + + -- Sum all errors into one cfe + local sumerrors = "" + for k,v in pairs(config) do + if (config[k]) and (config[k]["errtxt"]) and (config[k]["errtxt"] ~= "") then + sumerrors = sumerrors .. config[k]["errtxt"] .. "\n" + end + end + if (sumerrors ~= "") then + file["sumerrors" .. (num or "")] = cfe ({ + name="sumerrors" .. (num or ""), + label = "Configuration errors", + errtxt = string.match(sumerrors, "(.-)\n$"), + }) + end + return file end |