diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-02-13 17:51:51 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-02-13 17:51:51 +0000 |
commit | e3b7de100ac11887cb8abfa9336be995eda1520f (patch) | |
tree | 2371eb038d46437b3d4610bf17ab4d00c924c00d | |
parent | fb1884b0373955cc0233587a6b7a5e47092c3a83 (diff) | |
download | acf-tinydns-e3b7de100ac11887cb8abfa9336be995eda1520f.tar.bz2 acf-tinydns-e3b7de100ac11887cb8abfa9336be995eda1520f.tar.xz |
Initial commit on tinydns
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@716 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | tinydns-controller.lua | 29 | ||||
-rw-r--r-- | tinydns-model.lua | 50 | ||||
-rw-r--r-- | tinydns-status-html.lsp | 28 | ||||
-rw-r--r-- | tinydns.menu | 2 | ||||
-rw-r--r-- | viewfunctions.lua | 38 |
5 files changed, 147 insertions, 0 deletions
diff --git a/tinydns-controller.lua b/tinydns-controller.lua new file mode 100644 index 0000000..b6840d1 --- /dev/null +++ b/tinydns-controller.lua @@ -0,0 +1,29 @@ +module(..., package.seeall) + +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 + +local function getstatus(self) + local status = self.model.getstatus() + if (#status.status.value > 0) then + status.status.value = "Enabled" + else + status.status.value = "Disabled" + end + return status +end + +function status(self) + return { status=getstatus(self) } +end + diff --git a/tinydns-model.lua b/tinydns-model.lua new file mode 100644 index 0000000..176da46 --- /dev/null +++ b/tinydns-model.lua @@ -0,0 +1,50 @@ +module(..., package.seeall) + +require("procps") + +local processname = "tinydns" +local configfile = "???" + +-- ################################################################################ +-- LOCAL FUNCTIONS + +local function get_version() + local cmd = "/sbin/apk_version -vs " .. processname .." 2>/dev/null" + local f = io.popen( cmd ) + local cmd_output_result = f:read("*l") + f:close() + return cmd_output_result +end + +-- ################################################################################ +-- PUBLIC FUNCTIONS + +function getstatus() +-- local opts = getconfig() + local status = {} + status.version = cfe({ name = "version", + label="Program version", + value=get_version(), + }) + status.status = cfe({ name="status", + label="Program status", + value=procps.pidof(processname), + }) + +--[[ + if (opts["remotelogging"]) and not ((opts["remotelogging"]["value"] ~= "") and not (opts["localandnetworklog"]["value"])) then + status.logfile = cfe({ name="logfile", + label="Locally logging to", + value=opts["logfile"]["value"], + }) + end + if (opts["SYSLOGD_OPTS"]) and (opts["SYSLOGD_OPTS"]["-R"]) and (opts["SYSLOGD_OPTS"]["-R"] ~= "") then + status.remote = cfe({ name="remotelogging", + label="Remote logging to", + value=opts["SYSLOGD_OPTS"]["-R"], + }) + end +--]] + return status +end + diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp new file mode 100644 index 0000000..2a9ac66 --- /dev/null +++ b/tinydns-status-html.lsp @@ -0,0 +1,28 @@ +<? local form = ... ?> +<? +---[[ DEBUG INFORMATION +io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") +io.write(html.cfe_unpack(form)) +io.write("</span>") +--]] +?> + +<? +require("viewfunctions") +?> + +<H1>SYSTEM INFO</H1> +<? +local myform = form.status +local tags = { "status", "version", } +informationform(myform,tags) +?> + +<? +--[[ DEBUG INFORMATION +io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") +io.write(html.cfe_unpack(form)) +io.write("</span>") +--]] +?> + diff --git a/tinydns.menu b/tinydns.menu new file mode 100644 index 0000000..88f2449 --- /dev/null +++ b/tinydns.menu @@ -0,0 +1,2 @@ +#CAT GROUP/DESC TAB ACTION +Networking 10DNS Status status diff --git a/viewfunctions.lua b/viewfunctions.lua new file mode 100644 index 0000000..ed590cf --- /dev/null +++ b/viewfunctions.lua @@ -0,0 +1,38 @@ +module (..., package.seeall) + +function informationform(myform,tags) + io.write("<DL>") + for k,v in pairs(tags) do + if (myform[v]) then + local val = myform[v] + io.write("\t<DT") + if (#val.errtxt > 0) then io.write(" class='error'") end + io.write(">" .. val.label .. "</DT>\n") + + io.write("\t\t<DD>" .. val.value .. "\n") + if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end + if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end + io.write("\t\t</DD>\n") + end + end + io.write("</DL>") +end + +function configform(myform,tags) + io.write("<DL>") + for k,v in pairs(tags) do + if (myform[v]) then + local val = myform[v] + io.write("\t<DT") + if (#val.errtxt > 0) then io.write(" class='error'") end + io.write(">" .. val.label .. "</DT>\n") + + io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n") + if (val.descr) and (#val.descr > 0) then io.write("\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>\n") end + if (#val.errtxt > 0) then io.write("\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>\n") end + io.write("\t\t</DD>\n") + end + end + io.write("</DL>") +end + |