summaryrefslogtreecommitdiffstats
path: root/syslog-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-07-04 13:35:07 +0000
committerTed Trask <ttrask01@yahoo.com>2008-07-04 13:35:07 +0000
commit9fcda9ad78f8c42ed291c10e8bfea3e3000c30a3 (patch)
tree82e16c3a24e531d759062933e3dcaa714ccfcbd9 /syslog-model.lua
parent32d91ea7a92c5edee22900e8da1cafda058ca400 (diff)
downloadacf-alpine-baselayout-9fcda9ad78f8c42ed291c10e8bfea3e3000c30a3.tar.bz2
acf-alpine-baselayout-9fcda9ad78f8c42ed291c10e8bfea3e3000c30a3.tar.xz
Modified syslog to use controllerfunctions, modelfunctions, and common lsp files. Changed status->loginfo and basicstatus->status. Stopped expert from adding blank lines to the end.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1274 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'syslog-model.lua')
-rw-r--r--syslog-model.lua61
1 files changed, 16 insertions, 45 deletions
diff --git a/syslog-model.lua b/syslog-model.lua
index 3d50031..273cc27 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -1,14 +1,14 @@
module(..., package.seeall)
+require("modelfunctions")
require("fs")
-require("procps")
require("getopts")
require("format")
-require("daemoncontrol")
require("validator")
local configfile = "/etc/conf.d/syslog"
-local processname = "syslog"
+local processinitname = "syslog"
+local processname = "syslogd"
local function get_version()
local cmd = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin apk_version -v -s busybox | cut -d ' ' -f 1"
@@ -136,10 +136,8 @@ 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="Start/Stop result" })
+function startstop_service(action)
+ return modelfunctions.startstop_service(processinitname, action)
end
function getversion()
@@ -150,16 +148,7 @@ function getversion()
end
function getstatus()
- local status = cfe({
- label="Program status",
- value=procps.pidof("syslogd"),
- })
- if (#status.value > 0) then
- status.value = "Enabled"
- else
- status.value = "Disabled"
- end
- return status
+ return modelfunctions.getenabled(processname)
end
function getlogging()
@@ -182,29 +171,7 @@ function getlogging()
end
function get_filedetails()
- local path = configfile
- local filedetails = fs.stat(path)
- local config = getconfig(path)
- local file = {}
- file["filename"] = cfe({
- label="File name",
- value=path,
- })
- file["filesize"] = cfe({
- label="File size",
- value=filedetails.size or "0",
- })
- file["mtime"] = cfe({
- label="File date",
- value=filedetails.mtime or "---",
- })
- file["filecontent"] = cfe({
- type="longtext",
- label="File content",
- value=fs.read_file(path),
- })
-
- return cfe({ type="group", value=file, label="Config file details" })
+ return modelfunctions.getfiledetails(configfile)
end
function getconfig()
@@ -233,14 +200,17 @@ function updateconfig (config)
return config
end
-function update_filecontent (modifications)
+function update_filedetails (filedetails)
-- Validation before writing
- local configcontent = getopts.getoptsfromfile(format.dostounix(modifications), "", "SYSLOGD_OPTS", true) or {}
+ filedetails.value.filecontent.value = format.dostounix(filedetails.value.filecontent.value)
+ filedetails.value.filecontent.value = filedetails.value.filecontent.value:gsub("\n+$", "")
+ local configcontent = getopts.getoptsfromfile(filedetails.value.filecontent.value, "", "SYSLOGD_OPTS", true) or {}
local config = makeconfig(configcontent)
local success, errtxt
success, config = validateconfig(config)
if success == true then
- fs.write_file(configfile, format.dostounix(modifications))
+ fs.write_file(configfile, filedetails.value.filecontent.value)
+ filedetails = get_filedetails()
else
local errormessages = {}
for x,y in pairs(config.value) do
@@ -248,8 +218,9 @@ function update_filecontent (modifications)
errormessages[#errormessages + 1] = y.label .. " - " .. y.errtxt
end
end
- errtxt = table.concat(errormessages, "\n")
+ filedetails.value.filecontent.errtxt = table.concat(errormessages, "\n")
+ filedetials.errtxt = "Failed to set configuration"
end
- return cfe({ type="boolean", value=success, errtxt=errtxt, label="Update filecontent result" })
+ return filedetails
end