summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-08 15:13:05 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-08 15:13:05 +0000
commitdff2e5d4e7b7ef808d146ea64653701021a27ab2 (patch)
tree59cb11f9be55cef79359965ee3946433f48e6339
parentefe2a271ebf5894f581ddb151fb446e830782870 (diff)
downloadacf-openntpd-dff2e5d4e7b7ef808d146ea64653701021a27ab2.tar.bz2
acf-openntpd-dff2e5d4e7b7ef808d146ea64653701021a27ab2.tar.xz
Cleaning up code.
git-svn-id: svn://svn.alpinelinux.org/acf/openntpd/trunk@959 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--openntpd-config-html.lsp81
-rw-r--r--openntpd-controller.lua174
-rw-r--r--openntpd-expert-html.lsp79
-rw-r--r--openntpd-logfile-html.lsp47
-rw-r--r--openntpd-model.lua55
-rw-r--r--openntpd-status-html.lsp32
6 files changed, 117 insertions, 351 deletions
diff --git a/openntpd-config-html.lsp b/openntpd-config-html.lsp
index 77a38dc..87f2134 100644
--- a/openntpd-config-html.lsp
+++ b/openntpd-config-html.lsp
@@ -1,5 +1,6 @@
-<? local form = ... ?>
-
+<? local form = ...
+require("viewfunctions")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -8,40 +9,6 @@ io.write("</span>")
--]]
?>
-<?
-function displayinfo(myform,tags,viewtype)
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\n\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>")
- io.write("\n\t\t<DD>")
- if (viewtype == "viewonly") then
- io.write(val.value)
- elseif (val.type == "radio") and (type(val.option) == "table") and (#val.option > 0) then
- io.write("<span style='display:inline' class='" .. ( val.class or "") .. "'>")
- for k1,v1 in pairs(val.option) do
- io.write(tostring(v1.label) .. ":")
- io.write("<input style='margin-right:20px;margin-left:5px;' type='radio' class='" .. ( val.class or "") .. "' name='" .. val.name .. "'")
- if (tostring(val.value) == tostring(v1.value)) then io.write(" checked='yes'") end
- io.write(" value='" .. v1.value .. "'>")
- end
- io.write("</input></span>")
- else
- io.write(html.form[val.type](val))
- end
- if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>") end
- if (#val.errtxt > 0) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>") end
- io.write("\n\t\t</DD>\n")
- end
- end
-end
-?>
-
<H1>SYSTEM INFO</H1>
<DL>
<?
@@ -51,7 +18,6 @@ displayinfo(myform,tags,"viewonly")
?>
</DL>
-
<form name="cmd" action="" method="POST">
<h1>CONFIGURATION</h1>
<H2>Advanced config</H2>
@@ -92,37 +58,14 @@ displayinfo(myform,tags)
?>
</DL>
-</form>
-
-<? -- MANAGEMENT BUTTONS
-local cmdform = form.management
-local cmdresult = form.cmdmanagement
-local tags = { "start", "stop", "restart" }
-if (cmdform) and (cmdform[tags[1]]) then
-
- io.write('<form name="management" action="" method="POST">')
- io.write('<H1>MANAGEMENT</H1>')
- io.write('<dl>')
- io.write('<dt>' .. cmdform[tags[1]]["label"] .. '</dt>')
- io.write('<dd>')
- for k,v in pairs(tags) do
- if (cmdform[v]) then
- io.write(html.form[cmdform[v].type](cmdform[v]))
- end
- end
- io.write('</dd>')
-
- if (cmdresult) and (cmdresult.action) and (#cmdresult.action.descr > 0) then
- io.write('<dt>' .. cmdresult.label .. '</dt>')
- io.write('<dd><pre>' .. cmdresult.action.descr .. '</pre></dd>')
- end
- io.write('</dl></form>')
-end ?>
-
<?
---[[ 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>")
---]]
+-- Management buttons
+local myform = form.management
+local tags = { "start", "stop", "restart" }
+if (myform) then
+ io.write("<H1>MANAGEMENT</H1>\n<DL>")
+ displaymanagement(myform,tags)
+ io.write("</DL>")
+end
?>
+</form>
diff --git a/openntpd-controller.lua b/openntpd-controller.lua
index 006b353..6291e6c 100644
--- a/openntpd-controller.lua
+++ b/openntpd-controller.lua
@@ -1,36 +1,19 @@
--- Controller module
module (..., package.seeall)
--- Cause an http redirect to our "read" action
--- We use the self.conf table because it already has prefix,controller,etc
--- The redir code is defined in the application error handler (acf-controller)
+-- Load libraries
require("posix")
require("validator")
-local list_redir = function (self)
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+local function list_redir(self)
self.conf.action = "read"
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
-
-local function displaycmdmanagement(disablestart,disablestop,disablerestart)
+local function displaycmdmanagement(pidofstatus)
-- Add a management buttons
local management = {}
management.start = cfe({ name="cmdmanagement",
@@ -48,11 +31,20 @@ local function displaycmdmanagement(disablestart,disablestop,disablerestart)
value="Restart",
type="submit",
})
+ -- next CFE can be used to present the result of the previous action
+ management.actionresult = cfe({ name="actionresult",
+ label="Previous action result",
+ descr="", --Content of this variable is displayed as <PRE> ... </PRE> in BLACK text
+ errtxt="", --Content of this variable is displayed as <PRE> ... </PRE> in RED text
+ })
-- Disable management buttons based on if the process is running or not
- if (disablestart) then management.start.disabled = "yes" end
- if (disablestop) then management.stop.disabled = "yes" end
- if (disablerestart) then management.restart.disabled = "yes" end
+ if (pidofstatus) then
+ management.start.disabled = "yes"
+ else
+ management.stop.disabled = "yes"
+ management.restart.disabled = "yes"
+ end
return management
end
@@ -67,14 +59,24 @@ local function displaycmdsave(self)
return cmdsave
end
-config = function (self)
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+mvc={}
+function mvc.on_load(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 config(self)
local errors = {}
local modify_opts = nil
local cmdsavereply = {}
local cmdsaveresult = {}
-- Start/Stop/Restart process
- local cmdmanagement
+ local cmdmanagement, actionresult
if ( self.clientdata.cmdmanagement) then
cmdmanagement = cfe({
name="cmdmanagement",
@@ -84,7 +86,7 @@ config = function (self)
value=string.lower(self.clientdata.cmdmanagement), -- This row contains start/stop/restart (one of these commands)
}),
})
- local actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action )
+ actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action )
end
if (self.clientdata.cmdsavesetstimeonstartup) then
@@ -164,49 +166,8 @@ config = function (self)
end
end
-
---[[
- -- SECTION WHERE YOU SAVE NEW SETTINGS
- if ( self.clientdata.hosts_cmd_delete ) then
- if not (self.clientdata.hosts_list) then
- errors["hosts_list"]="You need to choose something in the list to delete"
- end
-
- if (self.clientdata.hosts_list) then
- modify_opts = self.model:modify_config(string.lower(tostring(self.clientdata.hosts_cmd)), nil, self.clientdata.hosts_list)
- end
-
-
-
- if (string.lower(tostring(self.clientdata.hosts_cmd)) == "add") then
- if (self.clientdata.hosts_add == "") then
- errors["hosts_add"]="You need to enter a server/IP"
- end
- if (self.clientdata.hosts_type == nil) then
- errors["hosts_type"]="You need to choose type of server"
- errors["hosts_add_orgvalue"] = self.clientdata.hosts_add
- end
- if (self.clientdata.hosts_add ~= "") and (self.clientdata.hosts_type ~= nil) then
- modify_opts = self.model:modify_config(string.lower(tostring(self.clientdata.hosts_cmd)), nil, self.clientdata.hosts_type .. " " .. self.clientdata.hosts_add)
- end
- elseif (string.lower(tostring(self.clientdata.listen_cmd)) == "add") then
- if (self.clientdata.listen_add == "") then
- errors["listen_add"]="You need to enter what you want to listen at"
- end
- if (self.clientdata.listen_add ~= "") then
- modify_opts = self.model:modify_config(string.lower(tostring(self.clientdata.listen_cmd)), nil, "listen on " .. self.clientdata.listen_add)
- end
- elseif (string.lower(tostring(self.clientdata.listen_cmd)) == "delete") then
- if not (self.clientdata.listen_list) then
- errors["listen_list"]="You need to choose something in the list to delete"
- end
- if (self.clientdata.listen_list) then
- modify_opts = self.model:modify_config(string.lower(tostring(self.clientdata.listen_cmd)), nil, self.clientdata.listen_list)
- end
---]]
-
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
- local status = getstatus(self)
+ local status = self.model:getstatus(self)
local config = self.model:getconfig()
-- Add buttons
@@ -250,25 +211,19 @@ config = function (self)
})
config.listen_cmd_add.descr="Enter your values in '" .. config.listen_add.label .. "' before pressing [" .. config.listen_cmd_add.value .. "]."
- -- Management buttons
- local disablestart,disablestop,disablerestart
- -- Disable management buttons based on if the process is running or not
- if (string.lower(status.status.value) == "enabled" ) then
- disablestart = "yes"
- else
- disablestop = "yes"
+ -- Management buttons (Hide/show buttons
+ local pidofstatus
+ if (string.lower(status.status.value) == "enabled" ) then pidofstatus = true end
+ management = displaycmdmanagement(pidofstatus)
+ if (actionresult) then
+ management.actionresult.descr=cmdmanagement.descr
+ management.actionresult.errtxt=cmdmanagement.errtxt
end
- -- Disable management buttons if there exist errors in the config
- for k,v in pairs(config) do
- if (config[k]["errtxt"] ~= "") then
- disablestart = "yes"
- disablestop = "yes"
- disablerestart = "yes"
- break
- end
+ if (status) and (status.version) and (#status.version.value == 0) then
+ management.start.disabled = "yes"
+ management.stop.disabled = "yes"
+ management.restart.disabled = "yes"
end
- -- Display management buttons
- local management = displaycmdmanagement(disablestart,disablestop,disablerestart)
-- Write out erros and descriptions from previous actions
for k,v in pairs(cmdsavereply) do
@@ -283,14 +238,11 @@ config = function (self)
end
end
- DEBUGMODEL = modify_opts -- <<< DEBUG INFO >>>
return ( {status = status,
config = config,
management = management,
url = url,
errors = errors,
- cmdmanagement = cmdmanagement,
-
cmdsavereply = cmdsavereply,
cmdsaveresult = cmdsaveresult,
modify_opts = modify_opts,
@@ -298,27 +250,25 @@ config = function (self)
} )
end
-logfile = function (self)
+function logfile(self)
- local status = getstatus(self)
+ local status = self.model:getstatus(self)
local logfile = self.model:get_logfile()
return ({
- management = management,
- cmdmanagement = cmdmanagement,
status = status,
logfile = logfile,
url = url,
})
end
-status = function (self)
+function status (self)
local cmd = self.clientdata.cmd
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
- return ( {status = getstatus(self), url = url } )
+ return ( {status = self.model:getstatus(self), url = url } )
end
-expert = function (self)
+function expert (self)
local modifications = self.clientdata.filecontent or ""
if ( self.clientdata.cmdsave ) then
modifications = self.model:update_filecontent(modifications)
@@ -326,7 +276,7 @@ expert = function (self)
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
-- Start/Stop/Restart process
- local cmdmanagement
+ local cmdmanagement, actionresult
if ( self.clientdata.cmdmanagement) then
cmdmanagement = cfe({
name="cmdmanagement",
@@ -336,10 +286,10 @@ expert = function (self)
value=string.lower(self.clientdata.cmdmanagement), -- This row contains start/stop/restart (one of these commands)
}),
})
- local actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action )
+ actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action )
end
- local status = getstatus(self)
+ local status = self.model:getstatus(self)
local file = self.model:get_filedetails()
-- Add buttons
@@ -354,23 +304,25 @@ expert = function (self)
end
- -- Management buttons
- local disablestart,disablestop,disablerestart
- -- Disable management buttons based on if the process is running or not
- if (string.lower(status.status.value) == "enabled" ) then
- disablestart = "yes"
- else
- disablestop = "yes"
+ -- Management buttons (Hide/show buttons
+ local pidofstatus
+ if (string.lower(status.status.value) == "enabled" ) then pidofstatus = true end
+ management = displaycmdmanagement(pidofstatus)
+ if (actionresult) then
+ management.actionresult.descr=cmdmanagement.descr
+ management.actionresult.errtxt=cmdmanagement.errtxt
+ end
+ if (status) and (status.version) and (#status.version.value == 0) then
+ management.start.disabled = "yes"
+ management.stop.disabled = "yes"
+ management.restart.disabled = "yes"
end
- -- Display management buttons
- management = displaycmdmanagement(disablestart,disablestop,disablerestart)
return ( {
status = status,
file = file,
modifications = modifications,
management = management,
- cmdmanagement = cmdmanagement,
url = url, } )
end
diff --git a/openntpd-expert-html.lsp b/openntpd-expert-html.lsp
index cf70091..4f77e5e 100644
--- a/openntpd-expert-html.lsp
+++ b/openntpd-expert-html.lsp
@@ -1,4 +1,6 @@
-<? local form = ... ?>
+<? local form = ...
+require("viewfunctions")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -6,39 +8,6 @@ io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
?>
-<?
-function displayinfo(myform,tags,viewtype)
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\n\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>")
- io.write("\n\t\t<DD>")
- if (viewtype == "viewonly") then
- io.write(val.value)
- elseif (val.type == "radio") and (type(val.option) == "table") and (#val.option > 0) then
- io.write("<span style='display:inline' class='" .. ( val.class or "") .. "'>")
- for k1,v1 in pairs(val.option) do
- io.write(tostring(v1.label) .. ":")
- io.write("<input style='margin-right:20px;margin-left:5px;' type='radio' class='" .. ( val.class or "") .. "' name='" .. val.name .. "'")
- if (tostring(val.value) == tostring(v1.value)) then io.write(" checked='yes'") end
- io.write(" value='" .. v1.value .. "'>")
- end
- io.write("</input></span>")
- else
- io.write(html.form[val.type](val))
- end
- if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>") end
- if (#val.errtxt > 0) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>") end
- io.write("\n\t\t</DD>\n")
- end
- end
-end
-?>
<H1>SYSTEM INFO</H1>
<DL>
@@ -49,7 +18,6 @@ displayinfo(myform,tags,"viewonly")
?>
</DL>
-
<form name="myform" action="" method="POST">
<h1>CONFIGURATION</h1>
<H2>Expert config</H2>
@@ -76,38 +44,15 @@ displayinfo(myform,tags)
?>
</DL>
-</form>
-
-<? -- MANAGEMENT BUTTONS
-local cmdform = form.management
-local cmdresult = form.cmdmanagement
-local tags = { "start", "stop", "restart" }
-if (cmdform) and (cmdform[tags[1]]) then
-
- io.write('<form name="management" action="" method="POST">')
- io.write('<H1>MANAGEMENT</H1>')
- io.write('<dl>')
- io.write('<dt>' .. cmdform[tags[1]]["label"] .. '</dt>')
- io.write('<dd>')
- for k,v in pairs(tags) do
- if (cmdform[v]) then
- io.write(html.form[cmdform[v].type](cmdform[v]))
- end
- end
- io.write('</dd>')
-
- if (cmdresult) and (cmdresult.action) and (#cmdresult.action.descr > 0) then
- io.write('<dt>' .. cmdresult.label .. '</dt>')
- io.write('<dd><pre>' .. cmdresult.action.descr .. '</pre></dd>')
- end
- io.write('</dl></form>')
-end ?>
-
<?
---[[ 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>")
---]]
+-- Management buttons
+local myform = form.management
+local tags = { "start", "stop", "restart" }
+if (myform) then
+ io.write("<H1>MANAGEMENT</H1>\n<DL>")
+ displaymanagement(myform,tags)
+ io.write("</DL>")
+end
?>
+</form>
diff --git a/openntpd-logfile-html.lsp b/openntpd-logfile-html.lsp
index 6f8f8f7..f01b751 100644
--- a/openntpd-logfile-html.lsp
+++ b/openntpd-logfile-html.lsp
@@ -1,5 +1,6 @@
-<? local form = ... ?>
-
+<? local form = ...
+require("viewfunctions")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -7,39 +8,6 @@ io.write(html.cfe_unpack(form))
io.write("</span>")
--]]
?>
-<?
-function displayinfo(myform,tags,viewtype)
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\n\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>")
- io.write("\n\t\t<DD>")
- if (viewtype == "viewonly") then
- io.write(val.value)
- elseif (val.type == "radio") and (type(val.option) == "table") and (#val.option > 0) then
- io.write("<span style='display:inline' class='" .. ( val.class or "") .. "'>")
- for k1,v1 in pairs(val.option) do
- io.write(tostring(v1.label) .. ":")
- io.write("<input style='margin-right:20px;margin-left:5px;' type='radio' class='" .. ( val.class or "") .. "' name='" .. val.name .. "'")
- if (tostring(val.value) == tostring(v1.value)) then io.write(" checked='yes'") end
- io.write(" value='" .. v1.value .. "'>")
- end
- io.write("</input></span>")
- else
- io.write(html.form[val.type](val))
- end
- if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>") end
- if (#val.errtxt > 0) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>") end
- io.write("\n\t\t</DD>\n")
- end
- end
-end
-?>
<H1>SYSTEM INFO</H1>
<DL>
@@ -50,7 +18,6 @@ displayinfo(myform,tags,"viewonly")
?>
</DL>
-
<? local myform = form.logfile ?>
<form name="myform" action="" method="POST">
<h1>LOGFILE</h1>
@@ -68,11 +35,3 @@ io.write(html.form[myform.filecontent.type](myform.filecontent))
?>
</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>")
---]]
-?>
diff --git a/openntpd-model.lua b/openntpd-model.lua
index d537629..f62c826 100644
--- a/openntpd-model.lua
+++ b/openntpd-model.lua
@@ -1,17 +1,18 @@
module (..., package.seeall)
---require("date")
---require("posix")
+-- Load libraries
require("format")
require("fs")
require("procps")
require("getopts")
require("daemoncontrol")
+require("processinfo")
+-- Set variables
local configfile = "/etc/ntpd.conf"
local confdfile = "/etc/conf.d/ntpd"
-local processname = "openntpd"
-local processname_short = "ntpd"
+local packagename = "openntpd"
+local processname = "ntpd"
-- ################################################################################
-- LOCAL FUNCTIONS
@@ -41,15 +42,6 @@ local function config_content( f )
return config
end
-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
-end
-
-
local function last_time_change()
local cmdoutput = {}
local cmd, error = io.popen("cat /var/log/messages | grep ntpd | grep adjusting | tail -1" ,r)
@@ -60,19 +52,6 @@ local function last_time_change()
return cmdoutput1 .. cmdoutput2
end
-local function autostarts()
- local cmd_output_result
- local cmd = "/sbin/rc_status | egrep '^S' | egrep '" .. processname_short .."' 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
-- This function needs:
-- addremove = [add|remove]
@@ -182,6 +161,16 @@ local function addremove_config( addremove, variable, value )
errtxt="Something went wrong! You entered '" .. tostring(addremove) .. "' as function.",
})
end
+
+local function process_status_text(procname)
+ local t = procps.pidof(procname)
+ if (t) and (#t > 0) then
+ return "Enabled"
+ else
+ return "Disabled"
+ end
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -219,19 +208,19 @@ function getstatus ()
local file_result,err = fs.write_file(path, "")
end
- status.version = cfe({
- name = "version",
+ local value, errtxt = processinfo.package_version(packagename)
+ status.version = cfe({ name = "version",
label="Program version",
- value=get_version(),
+ value=value,
+ errtxt=errtxt,
})
- status.status = cfe({
- name="status",
+ status.status = cfe({ name="status",
label="Program status",
- value=procps.pidof(processname_short),
+ value=process_status_text(processname),
})
- local autostart_sequense, autostart_errtxt = autostarts()
+ local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname)
status.autostart = cfe({ name="autostart",
label="Autostart sequence",
value=autostart_sequense,
diff --git a/openntpd-status-html.lsp b/openntpd-status-html.lsp
index 8ca80d8..7c10d67 100644
--- a/openntpd-status-html.lsp
+++ b/openntpd-status-html.lsp
@@ -1,4 +1,6 @@
-<? local form = ... ?>
+<? local form = ...
+require("viewfunctions")
+?>
<?
--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
@@ -7,38 +9,14 @@ io.write("</span>")
--]]
?>
-<?
-function displayinfo(myform,tags,viewonly)
- io.write("<DL>")
- for k,v in pairs(tags) do
- if (myform[v]) and (myform[v]["value"]) then
- local val = myform[v]
- io.write("\t<DT")
- if (#val.errtxt > 0) then
- val.class = "error"
- io.write(" class='error'")
- end
- io.write(">" .. val.label .. "</DT>\n")
- if (viewonly) then
- io.write("\t\t<DD>" .. val.value .. "\n")
- else
- io.write("\t\t<DD>" .. html.form[val.type](val) .. "\n")
- end
- 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
-?>
-
<H1>SYSTEM INFO</H1>
+<DL>
<?
local myform = form.status
local tags = { "status", "version", "autostart", }
displayinfo(myform,tags,"viewonly")
?>
+</DL>
<H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2>
<?