summaryrefslogtreecommitdiffstats
path: root/syslog-model.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-01-30 16:18:58 +0000
committerMika Havela <mika.havela@gmail.com>2008-01-30 16:18:58 +0000
commit86e67c5e0f5622b36ce792a6065e485b083e0f47 (patch)
treeffa975a6d0c41903a4873d61427975cc6fe6b81c /syslog-model.lua
parent9e5cf48cfb22cf85cca230e13312254dbf651e51 (diff)
downloadacf-alpine-baselayout-86e67c5e0f5622b36ce792a6065e485b083e0f47.tar.bz2
acf-alpine-baselayout-86e67c5e0f5622b36ce792a6065e485b083e0f47.tar.xz
Redoing mostly everything trying to present things as cfe (my own fault when not doing this from start)
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@666 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'syslog-model.lua')
-rw-r--r--syslog-model.lua45
1 files changed, 39 insertions, 6 deletions
diff --git a/syslog-model.lua b/syslog-model.lua
index f8563fc..2013b76 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -5,6 +5,7 @@ require("procps")
require("getopts")
require("format")
require("daemoncontrol")
+require("validator")
local configfile = "/etc/conf.d/syslog"
local config = {}
@@ -24,6 +25,13 @@ local function getloglevels()
end
return loglevels
end
+local function isrunning(process)
+ if (procps.pidof("syslogd")) then
+ return "Enabled"
+ else
+ return "Disabled"
+ end
+end
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -34,14 +42,23 @@ end
function getstatus()
local opts = getconfig()
local status = {}
- status.version = get_version()
- status.enabled = procps.pidof("syslogd")
+ status.version = cfe({ name="Program version",
+ value=get_version(),
+ })
+ status.status = cfe({ name="Program status",
+ value=isrunning("syslogd"),
+ })
if (opts["SYSLOGD_OPTS"]) and not ((opts["SYSLOGD_OPTS"]["-R"] ~= "") and not (opts["SYSLOGD_OPTS"]["-L"])) then
- status.logfile = opts["SYSLOGD_OPTS"]["-O"]
+ status.logfile = cfe({ name="Locally logging to",
+ value=opts["SYSLOGD_OPTS"]["-O"],
+ })
end
if (opts["SYSLOGD_OPTS"]) and (opts["SYSLOGD_OPTS"]["-R"]) and (opts["SYSLOGD_OPTS"]["-R"] ~= "") then
- status.remote = opts["SYSLOGD_OPTS"]["-R"]
+ status.remote = cfe({ name="Remote logging to",
+ value=opts["SYSLOGD_OPTS"]["-R"],
+ })
end
+--]]
return status
end
@@ -113,14 +130,30 @@ service_control = function ( self, srvcmd )
end
function setconfigs(self,variable,parameter,value)
+ if (errors == nil) then
+ errors = {}
+ end
--TODO: Validate so that user cant add values with '-' (could cause major breakage next time you do getopts)
--If file is missing... then create a new one
-- if not (fs.is_file(configfile)) then fs.write_file(configfile, "SYSLOGD_OPTS=\"\"\nKLOGD_OPTS=\"\"") end
if not (variable) or not (parameter) then return nil, "Usage setconfigs(variable,parameter,value)" end
if not (string.find(parameter, "-%a$")) then return nil, "Parameter must be formated '-a' (where a is one upper/lowercase letter [a-z])" end
- -- Set specific variables (and their values
+ if (value) and (parameter == "-O") then
+ value, errors["-O"] = validator.is_valid_filename(value, "/var/log" )
+ end
+ if (value) and (parameter == "-R") then
+ local port = string.match(value, ":(.-)$")
+ local host = string.match(value, "^(.-):?")
+ if (port) and not (validator.is_port(port)) then
+ errors["-R"] = "Port:'" .. tostring(port) .. "' is not a valid portnumber!"
+ end
+ errors["-R"] = "Port:'" .. tostring(port) .. "' Host:" .. tostring(host)
+ end
+
+ -- Set specific variables (and their values)
if (value) and ((parameter == "-S") or (parameter == "-L")) then value = "" end
- local retval, errors = getopts.setoptsinfile(configfile,variable,parameter,value)
+ local retval, errorscmd = getopts.setoptsinfile(configfile,variable,parameter,value)
+ errors["commit"] = errorscmd
return retval, errors
end