summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-01-10 13:00:07 +0000
committerMika Havela <mika.havela@gmail.com>2008-01-10 13:00:07 +0000
commit0fdb99dbc860a6f106eb09074adcb78b670c08c3 (patch)
tree8fcc7799ee52e4633a97c4891fe61ef3284eac0d
parent70be7065ce8aae06eb0e06a600f9176ebf460799 (diff)
downloadacf-alpine-baselayout-0fdb99dbc860a6f106eb09074adcb78b670c08c3.tar.bz2
acf-alpine-baselayout-0fdb99dbc860a6f106eb09074adcb78b670c08c3.tar.xz
Current status is now displayed. Apply settings doesn't work!
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@528 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--syslog-config-html.lsp59
-rw-r--r--syslog-controller.lua5
-rw-r--r--syslog-expert-html.lsp19
-rw-r--r--syslog-model.lua54
-rw-r--r--syslog-status-html.lsp7
5 files changed, 95 insertions, 49 deletions
diff --git a/syslog-config-html.lsp b/syslog-config-html.lsp
index 7396d25..abb1f75 100644
--- a/syslog-config-html.lsp
+++ b/syslog-config-html.lsp
@@ -4,48 +4,59 @@
<H2>Enable/Disable</H2>
<DT>Change status for this program</DT>
-<DD><input class="radio" type="radio" name="loglevel" value="2" <? if (tostring(view.config.loglevel) == "2") then io.write('checked') end ?>>Enable
-<input class="radio" type="radio" name="loglevel" value="3" <? if (tostring(view.config.loglevel) == "3") then io.write('checked') end ?>>Disable</DD>
+<DD><input class="radio" type="radio" name="enabled" value="2" <? if (view.status.enabled) then io.write('checked') end ?> >Enable
+<input class="radio" type="radio" name="enabled" value="3" <? if not (view.status.enabled) then io.write('checked') end ?> >Disable</DD>
<H2>Guided config</H2>
<H3>General settings</H3>
-<DT>Log to given file</DT>
-<DD><input type="text" class="text" name="smallerlogg" value="<?= view.config.logfile ?>"/>
-<P>(default=/var/log/messages)</P></DD>
-
-<DT>Set local log level</DT>
-<DD><input class="radio" type="radio" name="loglevel" value="1" <? if (tostring(view.config.loglevel) == "1") then io.write('checked') end ?>>1
-<input class="radio" type="radio" name="loglevel" value="2" <? if (tostring(view.config.loglevel) == "2") then io.write('checked') end ?>>2
-<input class="radio" type="radio" name="loglevel" value="3" <? if (tostring(view.config.loglevel) == "3") then io.write('checked') end ?>>3
-<input class="radio" type="radio" name="loglevel" value="4" <? if (tostring(view.config.loglevel) == "4") then io.write('checked') end ?>>4
-<input class="radio" type="radio" name="loglevel" value="5" <? if (tostring(view.config.loglevel) == "5") then io.write('checked') end ?>>5
-<input class="radio" type="radio" name="loglevel" value="" <? if (tostring(view.config.loglevel) == "") then io.write('checked') end ?>>Default
-<p>(1=Quiet, 5=Noisy, Default=Not specifyed any loglevel in the config)</P>
+<DT><?= view.config.logfile.label ?></DT>
+<DD><input type="text" class="text" name="smallerlogg" value="<?= view.config.logfile.value ?>"/>
+<P>(default=/var/log/messages)</P>
+<p class="error"><?= view.config.logfile.errtxt ?></p>
</DD>
-<DT>Smaller logging output</DT>
-<DD><input type="checkbox" name="smallog" <? if (view.config.smallog) then io.write('checked') end ?>/></DD>
+<DT><?= view.config.loglevel.label ?></DT>
+<DD><input class="radio" type="radio" name="loglevel" value="1" <? if (tostring(view.config.loglevel.value) == "1") then io.write('checked') end ?>>1
+<input class="radio" type="radio" name="loglevel" value="2" <? if (tostring(view.config.loglevel.value) == "2") then io.write('checked') end ?>>2
+<input class="radio" type="radio" name="loglevel" value="3" <? if (tostring(view.config.loglevel.value) == "3") then io.write('checked') end ?>>3
+<input class="radio" type="radio" name="loglevel" value="4" <? if (tostring(view.config.loglevel.value) == "4") then io.write('checked') end ?>>4
+<input class="radio" type="radio" name="loglevel" value="5" <? if (tostring(view.config.loglevel.value) == "5") then io.write('checked') end ?>>5
+<input class="radio" type="radio" name="loglevel" value="" <? if (tostring(view.config.loglevel.value) == "") then io.write('checked') end ?>>Default
+<p><?= view.config.loglevel.helptxt ?></P>
+<p class="error"><?= view.config.loglevel.errtxt ?></p></DD>
+
+<DT><?= view.config.smallog.label ?></DT>
+<DD><input type="checkbox" name="smallog" <? if (view.config.smallog.value ~= "") then io.write('checked') end ?>/><p class="error"><?= view.config.smallog.errtxt ?></p></DD>
<H3>Save logs for a longer period</H3>
-<DT>Max size (KB) before rotate</DT>
-<DD><input type="text" class="text" name="maxsize" value="<?= view.config.maxsize ?>"/>
+<DT><?= view.config.maxsize.label ?></DT>
+<DD><input type="text" class="text" name="maxsize" value="<?= view.config.maxsize.value ?>"/>
<p>(default=200KB, 0=off)</p>
+<p class="error"><?= view.config.maxsize.errtxt ?></p>
</DD>
-<DT>Number of rotated logs to keep</DT>
-<DD><input type="text" class="text" name="logrotate" value="<?= view.config.logrotate ?>"/>
+<DT><?= view.config.logrotate.label ?></DT>
+<DD><input type="text" class="text" name="logrotate" value="<?= view.config.logrotate.value ?>"/>
<p>(default=1, max=99, 0=purge)</p>
+<p class="error"><?= view.config.logrotate.errtxt ?></p>
</DD>
<H3>Remote logging</H3>
-<DT>Log to IP or hostname on PORT</DT>
-<DD><input type="text" class="text" name="host" value="<?= view.config.remote ?>"/>
-<P>(default PORT=514/UDP)</P></DD>
+<DT><?= view.config.remote.label ?></DT>
+<DD><input type="text" class="text" name="host" value="<?= view.config.remote.value ?>"/>
+<P>(default PORT=514/UDP)</P>
+<p class="error"><?= view.config.remote.errtxt ?></p>
+</DD>
<H2>Save and apply above settings</H2>
<DT>Apply settings</DT>
<DD><input class="submitxxx" type="submit" value="Apply"/></DD>
-
+<?
+--[[ DEBUG INFORMATION
+require("debugs")
+io.write(debugs.variables(view))
+--]]
+?>
diff --git a/syslog-controller.lua b/syslog-controller.lua
index d0d05eb..0bdc2f5 100644
--- a/syslog-controller.lua
+++ b/syslog-controller.lua
@@ -24,5 +24,8 @@ function config(self)
return { status = self.model.getstatus(), srvcmdresult=srvcmdresult, config= self.model.getconfig() }
end
-expert = config
+function expert(self)
+ return { file = self.model:get_filedetails(), status = self.model.getstatus(),}
+
+end
diff --git a/syslog-expert-html.lsp b/syslog-expert-html.lsp
index 9d74227..5f5d6ec 100644
--- a/syslog-expert-html.lsp
+++ b/syslog-expert-html.lsp
@@ -4,28 +4,35 @@
<H2>Enable/Disable</H2>
<DT>Change status for this program</DT>
-<DD><input class="radio" type="radio" name="loglevel" value="2" <? if (tostring(view.config.loglevel) == "2") then io.write('checked') end ?>>Enable
-<input class="radio" type="radio" name="loglevel" value="3" <? if (tostring(view.config.loglevel) == "3") then io.write('checked') end ?>>Disable</DD>
+<DD><input class="radio" type="radio" name="enabled" value="2" <? if (view.status.enabled) then io.write('checked') end ?> >Enable
+<input class="radio" type="radio" name="enabled" value="3" <? if not (view.status.enabled) then io.write('checked') end ?> >Disable</DD>
<H2>Expert config</H2>
<h3>File details</h3>
<dt>File name</dt>
-<dd>/etc/conf.d/syslogd</dd>
+<dd><?= view.file.details.path ?></dd>
<dt>File size</dt>
-<dd>60</dd>
+<dd><?= view.file.details.size ?></dd>
<dt>Last modified</dt>
-<dd>Mon Aug 20 16:58:19 2007</dd>
+<dd><?= view.file.details.mtimelong ?></dd>
<h3>File content</h3>
<form name="myform" action="" method="POST">
<input name="name" type=hidden value="">
-<textarea name="modifications"></textarea>
+<textarea name="modifications"><?= view.file.content ?></textarea>
<H2>Save and apply above settings</H2>
<DT>Apply settings</DT>
<DD><input class="submitxxx" type="submit" value="Apply"/></DD>
+
+<?
+--[[ DEBUG INFORMATION
+require("debugs")
+io.write(debugs.variables(view))
+--]]
+?>
diff --git a/syslog-model.lua b/syslog-model.lua
index ac37572..2ec8b3b 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -1,7 +1,7 @@
module(..., package.seeall)
---require("pidof")
-require("split")
+require("fs")
+require("posix")
local function get_version()
local cmd = "/sbin/apk_version -v -s busybox | cut -d ' ' -f 1"
@@ -18,9 +18,7 @@ local is_running = function( process )
local cmdoutput = string.gsub(cmd:read("*a"), "%s", "")
cmd:close()
if (cmdoutput ~= "") then
- statusreport = "Running"
- else
- statusreport = "Stopped"
+ statusreport = "Yes"
end
return statusreport
end
@@ -59,6 +57,27 @@ local function readopts(optname)
return opts
end
+local function file_info ( path )
+ local filedetails = posix.stat(path)
+ filedetails["owner"]=rawget((posix.getpasswd(filedetails["uid"])),"name")
+ filedetails["group"]=rawget((posix.getgroup(filedetails["gid"])),"name")
+ filedetails["atimelong"]=os.date("%c", filedetails["atime"])
+ filedetails["mtimelong"]=os.date("%c", filedetails["mtime"])
+ filedetails["path"]=path
+ filedetails["name"]=basename(path)
+
+ if ( filedetails["size"] > 1073741824 ) then
+ filedetails["size"]=((filedetails["size"]/1073741824) - (filedetails["size"]/1073741824%0.1)) .. "G"
+ elseif ( filedetails["size"] > 1048576 ) then
+ filedetails["size"]=((filedetails["size"]/1048576) - (filedetails["size"]/1048576%0.1)) .. "M"
+ elseif ( filedetails["size"] > 1024 ) then
+ filedetails["size"]=((filedetails["size"]/1024) - (filedetails["size"]/1024%0.1)) .. "k"
+ else
+ filedetails["size"]=filedetails["size"]
+ end
+ return filedetails
+
+end
-- ################################################################################
-- EXPERIMENTAL LOCAL FUNCTIONS
@@ -69,25 +88,30 @@ end
function getstatus()
local opts = readopts("SYSLOGD_OPTS")
local status = {}
- local version = get_version()
- status.version = version
- local isrunning = is_running("syslogd")
- status.status = isrunning
+ status.version = get_version()
+ status.enabled = is_running("syslogd")
status.logfile = opts["-O"] or "/var/log/messages"
status.remote = opts["-R"]
return status
end
+function get_filedetails()
+ local filedetails = {}
+ local path = "/etc/conf.d/syslog"
+ filedetails.details = file_info(path)
+ filedetails.content = fs.read_file(path)
+ return filedetails
+end
function getconfig()
local opts = readopts("SYSLOGD_OPTS")
local config = {}
config.debug = opts
- config.logfile = opts["-O"] or ""
- config.loglevel = opts["-l"] or ""
- config.smallog = opts["-S"] --FIXME: DOESNT WORK!!!
- config.maxsize = opts["-s"] or ""
- config.logrotate = opts["-b"] or ""
- config.remote = opts["-R"] or ""
+ config.logfile = cfe({value=opts["-O"], type="text", option="", errtxt="" ,label="Log to given file", })
+ config.loglevel = cfe({value=opts["-l"], type="radio", option="", errtxt="", helptxt="(1=Quiet, 5=Noisy, Default=Not specifyed any loglevel in the config)", label="Set local log level", })
+ config.smallog = cfe({value=opts["-S"], type="select", option="", errtxt="", label="Smaller logging output", })
+ config.maxsize = cfe({value=opts["-s"], type="text", option="", errtxt="", label="Max size (KB) before rotate", })
+ config.logrotate = cfe({value=opts["-b"], type="text", option="", errtxt="", label="Number of rotated logs to keep", })
+ config.remote = cfe({value=opts["-R"], type="text", option="", errtxt="", label="Log to IP or hostname on PORT", })
return config
end
diff --git a/syslog-status-html.lsp b/syslog-status-html.lsp
index 20dae6b..6cd46a4 100644
--- a/syslog-status-html.lsp
+++ b/syslog-status-html.lsp
@@ -4,13 +4,14 @@
<h2>SYSTEM INFO</h2>
-<dt>Process status</dt>
-<dd><?= view.status.status ?></dd>
+<dt>Program status</dt>
+<DD><? if (view.status.enabled) then io.write('Enabled') else io.write('Disabled') end ?>
+</DD>
<dt>Program version</dt>
<dd><?= view.status.version ?></dd>
-<H3>GENERAL CONFIGURATIONS</H3>
+<H3>PROGRAM SPECIFIC OPTIONS</H3>
<? if (view.status.logfile) then ?>
<dt>Locally logging to</dt>
<dd><?= view.status.logfile ?></dd>