From e3b7de100ac11887cb8abfa9336be995eda1520f Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 13 Feb 2008 17:51:51 +0000 Subject: Initial commit on tinydns git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@716 ab2d0c66-481e-0410-8bed-d214d4d58bed --- tinydns-controller.lua | 29 ++++++++++++++++++++++++++++ tinydns-model.lua | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ tinydns-status-html.lsp | 28 +++++++++++++++++++++++++++ tinydns.menu | 2 ++ viewfunctions.lua | 38 +++++++++++++++++++++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 tinydns-controller.lua create mode 100644 tinydns-model.lua create mode 100644 tinydns-status-html.lsp create mode 100644 tinydns.menu create mode 100644 viewfunctions.lua 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 @@ + +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +?> + + + +

SYSTEM INFO

+ + +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +?> + 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("
") + for k,v in pairs(tags) do + if (myform[v]) then + local val = myform[v] + io.write("\t 0) then io.write(" class='error'") end + io.write(">" .. val.label .. "\n") + + io.write("\t\t
" .. val.value .. "\n") + if (val.descr) and (#val.descr > 0) then io.write("\t\t

" .. string.gsub(val.descr, "\n", "
") .. "

\n") end + if (#val.errtxt > 0) then io.write("\t\t

" .. string.gsub(val.errtxt, "\n", "
") .. "

\n") end + io.write("\t\t
\n") + end + end + io.write("
") +end + +function configform(myform,tags) + io.write("
") + for k,v in pairs(tags) do + if (myform[v]) then + local val = myform[v] + io.write("\t 0) then io.write(" class='error'") end + io.write(">" .. val.label .. "\n") + + io.write("\t\t
" .. html.form[val.type](val) .. "\n") + if (val.descr) and (#val.descr > 0) then io.write("\t\t

" .. string.gsub(val.descr, "\n", "
") .. "

\n") end + if (#val.errtxt > 0) then io.write("\t\t

" .. string.gsub(val.errtxt, "\n", "
") .. "

\n") end + io.write("\t\t
\n") + end + end + io.write("
") +end + -- cgit v1.2.3