summaryrefslogtreecommitdiffstats
path: root/syslog-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'syslog-model.lua')
-rw-r--r--syslog-model.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/syslog-model.lua b/syslog-model.lua
index 6fa4bce..2e7cae2 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -4,6 +4,7 @@ require("fs")
require("procps")
require("getopts")
require("format")
+require("daemoncontrol")
local configfile = "/etc/conf.d/syslog"
local config = {}
@@ -26,6 +27,10 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
+function startstop_service ( self, state )
+ return daemoncontrol.daemoncontrol("syslog", state)
+end
+
function getstatus()
local opts = getconfig()
local status = {}
@@ -43,29 +48,32 @@ end
function get_filedetails()
local filedetails = {}
local path = configfile
+ filedetails.details = {path=path, size="0",mtime=""}
+ filedetails.content = ""
if (fs.is_file(path)) then
filedetails.details = fs.stat(path)
filedetails.content = fs.read_file(path)
- else
- filedetails.details = {path="File is missing", size="0",mtime=""}
- filedetails.content = ""
end
return filedetails
end
function getconfig()
+ local config = {}
+ config['SYSLOGD_OPTS']={}
local errors = {}
errors["SYSLOGD_OPTS"] = {}
errors["KLOGD_OPTS"] = {}
if (fs.is_file(configfile)) then
- config = getopts.getoptsfromfile(configfile)
+ config = getopts.getoptsfromfile(configfile) or config
else
- config['SYSLOGD_OPTS']={}
+ errors["configfile"] = "Config file '".. configfile .. "' is missing!"
end
+ -- Next section is to set/show default values when a option is not configured in the configfile
config["SYSLOGD_OPTS"]["-O"] = config["SYSLOGD_OPTS"]["-O"] or "/var/log/messages"
config["SYSLOGD_OPTS"]["-l_list"] = getloglevels()
config["SYSLOGD_OPTS"]["-R"] = config["SYSLOGD_OPTS"]["-R"] or ""
config["SYSLOGD_OPTS"]["-s"] = config["SYSLOGD_OPTS"]["-s"] or ""
config["SYSLOGD_OPTS"]["-b"] = config["SYSLOGD_OPTS"]["-b"] or ""
+ -- Next section is to print errormessages when configs are wrong
if (config["SYSLOGD_OPTS"]["-l"]) and
((tonumber(config["SYSLOGD_OPTS"]["-l"]) == nil) or (tonumber(config["SYSLOGD_OPTS"]["-l"]) > 8)) then
errors["SYSLOGD_OPTS"]["-l"] = "Log value is out of range. Please select one of the above."