diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-04-04 13:28:55 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-04-04 13:28:55 +0000 |
commit | 0a0ca2621d63d04a64004616c13253826c187e1d (patch) | |
tree | d45a123f153f7c224ac91e808c56525445593ce3 /ipsectools-model.lua | |
parent | 4f54a99126e25b88258c0a31cea66d7259a6fede (diff) | |
download | acf-ipsec-tools-0a0ca2621d63d04a64004616c13253826c187e1d.tar.bz2 acf-ipsec-tools-0a0ca2621d63d04a64004616c13253826c187e1d.tar.xz |
Show config errors in expert-tab.
git-svn-id: svn://svn.alpinelinux.org/acf/ipsec-tools/trunk@926 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'ipsectools-model.lua')
-rw-r--r-- | ipsectools-model.lua | 81 |
1 files changed, 46 insertions, 35 deletions
diff --git a/ipsectools-model.lua b/ipsectools-model.lua index 4b91fdf..d46f476 100644 --- a/ipsectools-model.lua +++ b/ipsectools-model.lua @@ -190,57 +190,68 @@ function getstatus() return status end -function get_filedetails() - local path = configfile - local filedetails = fs.stat(path) - local file = {} +function getconfig() + local config = {} + return config +end - file["filename"] = cfe({ - name="filename", - label="File name", - value=path, - }) - file["filesize"] = cfe({ - name="filesize", - label="File size", - value=filedetails.size or 0, - }) - file["mtime"] = cfe({ - name="mtime", - label="File date", - value=filedetails.mtime or "---", - }) - file["filecontent"] = cfe({ - type="longtext", - name="filecontent", - label="File content", - value=fs.read_file(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 - path = configfile2 - filedetails = fs.stat(path) - file["filename2"] = cfe({ - name="filename2", + file["filename" .. (num or "")] = cfe({ + name="filename" .. (num or ""), label="File name", value=path, + errtxt=filenameerrtxt }) - file["filesize2"] = cfe({ - name="filesize2", + file["filesize" .. (num or "")] = cfe({ + name="filesize" .. (num or ""), label="File size", value=filedetails.size or 0, }) - file["mtime2"] = cfe({ - name="mtime2", + file["mtime" .. (num or "")] = cfe({ + name="mtime" .. (num or ""), label="File date", value=filedetails.mtime or "---", }) - file["filecontent2"] = cfe({ + file["filecontent" .. (num or "")] = cfe({ type="longtext", - name="filecontent2", + 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 |