summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--syslog-config-html.lsp2
-rw-r--r--syslog-controller.lua12
-rw-r--r--syslog-model.lua23
3 files changed, 28 insertions, 9 deletions
diff --git a/syslog-config-html.lsp b/syslog-config-html.lsp
index 1167751..6c1d6c3 100644
--- a/syslog-config-html.lsp
+++ b/syslog-config-html.lsp
@@ -67,7 +67,7 @@
<H3>Remote logging</H3>
<DL>
<DT>Activate remote logging</DT>
- <DD><input type="checkbox" name="remotelogging" <? if (view.config["SYSLOGD_OPTS"]["-R"]) then io.write('checked=yes') end ?> />
+ <DD><input type="checkbox" name="remotelogging" <? if (view.config["SYSLOGD_OPTS"]["-R"] ~= "") then io.write('checked=yes') end ?> />
<? if (view.errors["SYSLOGD_OPTS"]) and (view.errors["SYSLOGD_OPTS"]["-R"]) then
io.write("<p class='error'>",view.errors["SYSLOGD_OPTS"]["-R"] ,"</p>")
end ?>
diff --git a/syslog-controller.lua b/syslog-controller.lua
index 288ae7b..77cd0ab 100644
--- a/syslog-controller.lua
+++ b/syslog-controller.lua
@@ -1,9 +1,17 @@
module(..., package.seeall)
-mvc = {}
-function mvc.on_load(self)
+local list_redir = function (self)
+ self.conf.action = "status"
+ self.conf.type = "redir"
+ error (self.conf)
end
+mvc = {}
+mvc.on_load = function(self, parent)
+ if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then
+ self.worker[self.conf.action] = list_redir(self)
+ end
+end
function status(self)
return { status=self.model.getstatus() }
diff --git a/syslog-model.lua b/syslog-model.lua
index 1d402d3..6fa4bce 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -6,6 +6,7 @@ require("getopts")
require("format")
local configfile = "/etc/conf.d/syslog"
+local config = {}
local function get_version()
local cmd = "/sbin/apk_version -v -s busybox | cut -d ' ' -f 1"
@@ -30,10 +31,10 @@ function getstatus()
local status = {}
status.version = get_version()
status.enabled = procps.pidof("syslogd")
- if not ((opts["SYSLOGD_OPTS"]["-R"] ~= "") and not (opts["SYSLOGD_OPTS"]["-L"])) then
+ if (opts["SYSLOGD_OPTS"]) and not ((opts["SYSLOGD_OPTS"]["-R"] ~= "") and not (opts["SYSLOGD_OPTS"]["-L"])) then
status.logfile = opts["SYSLOGD_OPTS"]["-O"]
end
- if (opts["SYSLOGD_OPTS"]["-R"]) and (opts["SYSLOGD_OPTS"]["-R"] ~= "") then
+ if (opts["SYSLOGD_OPTS"]) and (opts["SYSLOGD_OPTS"]["-R"]) and (opts["SYSLOGD_OPTS"]["-R"] ~= "") then
status.remote = opts["SYSLOGD_OPTS"]["-R"]
end
return status
@@ -42,25 +43,35 @@ end
function get_filedetails()
local filedetails = {}
local path = configfile
- filedetails.details = fs.stat(path)
- filedetails.content = fs.read_file(path)
+ 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 errors = {}
errors["SYSLOGD_OPTS"] = {}
errors["KLOGD_OPTS"] = {}
- local config = getopts.getoptsfromfile(configfile)
+ if (fs.is_file(configfile)) then
+ config = getopts.getoptsfromfile(configfile)
+ else
+ config['SYSLOGD_OPTS']={}
+ end
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 ""
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."
else
config["SYSLOGD_OPTS"]["-l"] = config["SYSLOGD_OPTS"]["-l"] or 8
end
-
return config, errors
end