summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-03-28 13:59:36 +0000
committerMika Havela <mika.havela@gmail.com>2008-03-28 13:59:36 +0000
commit68bb42a9a8664aee80f56c2b67cdd9e73f39890f (patch)
treed7290ab2504e032d840dee655a86daaf8173e45a
parent036c4b77855cfcd6e7a31692624e349420774f07 (diff)
downloadacf-snort-68bb42a9a8664aee80f56c2b67cdd9e73f39890f.tar.bz2
acf-snort-68bb42a9a8664aee80f56c2b67cdd9e73f39890f.tar.xz
Added info about autostart sequence.
Bugfix on version numbering when program is not installed. git-svn-id: svn://svn.alpinelinux.org/acf/snort/trunk@862 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--snort-model.lua44
-rw-r--r--snort-status-html.lsp2
2 files changed, 37 insertions, 9 deletions
diff --git a/snort-model.lua b/snort-model.lua
index 3666e6e..06809b7 100644
--- a/snort-model.lua
+++ b/snort-model.lua
@@ -16,11 +16,31 @@ local configfile = "/etc/snort/snort.conf"
-- LOCAL FUNCTIONS
local function get_version()
- local cmd = "/sbin/apk_version -v -s " .. processname .. " | cut -d ' ' -f 1"
- local cmd_output = io.popen( cmd )
- local cmd_output_result = cmd_output:read("*a") or ""
- cmd_output:close()
- return cmd_output_result
+ local cmd_output_result, cmd_output_error
+ local cmd = "/sbin/apk_version -vs " .. processname .." 2>/dev/null"
+ local f = io.popen( cmd )
+ local cmdresult = f:read("*l")
+ if (cmdresult) and (#cmdresult > 0) then
+ cmd_output_result = string.match(cmdresult,"^%S*") or "Unknown"
+ else
+ cmd_output_error = "Program not installed"
+ end
+ f:close()
+ return cmd_output_result,cmd_output_error
+end
+
+local function autostarts()
+ local cmd_output_result, cmd_output_error
+ local cmd = "/sbin/rc_status | egrep '^S' | egrep '" .. processname .."' 2>/dev/null"
+ local f = io.popen( cmd )
+ local cmdresult = f:read("*a")
+ if (cmdresult) and (#cmdresult > 0) then
+ cmd_output_result = "Process will autostart at next boot (at sequence '" .. string.match(cmdresult,"^%a+(%d%d)") .. "')"
+ else
+ cmd_output_error = "Not programmed to autostart"
+ end
+ f:close()
+ return cmd_output_result,cmd_output_error
end
-- ################################################################################
@@ -29,10 +49,11 @@ end
function getstatus ()
local status = {}
- status.version = cfe({
- name = "version",
+ local value, errtxt = get_version()
+ status.version = cfe({ name = "version",
label="Program version",
- value=get_version(),
+ value=value,
+ errtxt=errtxt,
})
status.status = cfe({
@@ -41,6 +62,13 @@ function getstatus ()
value=procps.pidof(processname) or "",
})
+ local autostart_sequense, autostart_errtxt = autostarts()
+ status.autostart = cfe({ name="autostart",
+ label="Autostart sequence",
+ value=autostart_sequense,
+ errtxt=autostart_errtxt,
+ })
+
return status
end
diff --git a/snort-status-html.lsp b/snort-status-html.lsp
index c7c8cef..9233f84 100644
--- a/snort-status-html.lsp
+++ b/snort-status-html.lsp
@@ -28,7 +28,7 @@ end
<DL>
<?
local myform = view.status
-local tags = { "status", "version", }
+local tags = { "status", "version", "autostart", }
displayinfo(myform,tags,"viewonly")
?>
</DL>