summaryrefslogtreecommitdiffstats
path: root/syslog-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-06-05 17:41:22 +0000
committerTed Trask <ttrask01@yahoo.com>2008-06-05 17:41:22 +0000
commit68c7979c8ed1628fee78b9c47214997e0c47f0e2 (patch)
tree2e5fe26d43e4f52f36cd303ea3cc17d53d799d5d /syslog-model.lua
parent4d30eff878f33f2d07811c8f5ccce09c538ebb8d (diff)
downloadacf-alpine-baselayout-68c7979c8ed1628fee78b9c47214997e0c47f0e2.tar.bz2
acf-alpine-baselayout-68c7979c8ed1628fee78b9c47214997e0c47f0e2.tar.xz
Modified syslog to move clientdata processing from model to controller.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1201 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'syslog-model.lua')
-rw-r--r--syslog-model.lua29
1 files changed, 9 insertions, 20 deletions
diff --git a/syslog-model.lua b/syslog-model.lua
index 3a8ffa5..3d50031 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -137,8 +137,9 @@ end
-- PUBLIC FUNCTIONS
function startstop_service ( self, action )
+ -- action is validated in daemoncontrol
local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, action)
- return cfe({ type="boolean", value=cmdresult, descr=cmdmessage, errtxt=cmderror, label=action.." result" })
+ return cfe({ type="boolean", value=cmdresult, descr=cmdmessage, errtxt=cmderror, label="Start/Stop result" })
end
function getversion()
@@ -219,17 +220,8 @@ function getconfig()
return config
end
-function updateconfig (clientdata)
- local config = getconfig()
+function updateconfig (config)
local success = true
- for name in pairs(config.value) do
- if config.value[name].type == "boolean" then
- config.value[name].value = (clientdata[name] == "true")
- elseif clientdata[name] then
- config.value[name].value = clientdata[name]
- end
- end
-
success, config = validateconfig(config)
if success == true then
@@ -241,26 +233,23 @@ function updateconfig (clientdata)
return config
end
-function update_filecontent (self, modifications)
+function update_filecontent (modifications)
-- Validation before writing
local configcontent = getopts.getoptsfromfile(format.dostounix(modifications), "", "SYSLOGD_OPTS", true) or {}
local config = makeconfig(configcontent)
- local success
+ local success, errtxt
success, config = validateconfig(config)
if success == true then
fs.write_file(configfile, format.dostounix(modifications))
- return get_filedetails()
else
- local details = get_filedetails()
- details.value.filecontent.value = modifications
- local errormessages = { "Failed to save config!" }
+ local errormessages = {}
for x,y in pairs(config.value) do
if y.errtxt then
errormessages[#errormessages + 1] = y.label .. " - " .. y.errtxt
end
end
- details.errtxt = table.concat(errormessages, "\n")
- return details
+ errtxt = table.concat(errormessages, "\n")
end
-end
+ return cfe({ type="boolean", value=success, errtxt=errtxt, label="Update filecontent result" })
+end