diff options
-rw-r--r-- | openntpd-config-html.lsp (renamed from openntpd-settings-html.lsp) | 37 | ||||
-rw-r--r-- | openntpd-controller.lua | 30 | ||||
-rw-r--r-- | openntpd-expert-html.lsp (renamed from openntpd-advanced-html.lsp) | 46 | ||||
-rw-r--r-- | openntpd-model.lua | 12 | ||||
-rw-r--r-- | openntpd-read-html.lsp | 27 | ||||
-rw-r--r-- | openntpd-status-html.lsp | 29 | ||||
-rw-r--r-- | openntpd.menu | 2 |
7 files changed, 114 insertions, 69 deletions
diff --git a/openntpd-settings-html.lsp b/openntpd-config-html.lsp index a44eb19..b389ad6 100644 --- a/openntpd-settings-html.lsp +++ b/openntpd-config-html.lsp @@ -1,11 +1,22 @@ <? local view = ... ?> +<h1>CONFIGURATION</h1> + +<H2>Enable/Disable</H2> +<DT>Change status for this program</DT> +<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> + +<? --[[ ?> <h1>System time</h1> <h2>SYSTEM INFO</h2> <dt>Process status</dt> -<dd><? io.write(view.statusinfo.status) ?><? if (view.startstop.status) then io.write(" (" .. view.startstop.status .. ")") end ?></dd> +<dd><? io.write(view.status.status) ?><? if (view.startstop.status) then io.write(" (" .. view.startstop.status .. ")") end ?></dd> <dt>Start or stop process</dt> <dd><form name="start" action="" method="POST"> @@ -13,12 +24,12 @@ <form name="stop" action="" method="POST"> <input type=submit class="submit" name="cmd" value="stop"></form></dd> -<h2>NTPD SETTINGS</h2> +<? --]] ?> <form name="cmd" action="" method="POST"> <dt>Set time immediately at startup</dt> -<dd><input type="checkbox" name="settings_startup" <? if (view.statusinfo.setstimeonstartup) then io.write("checked") end ?>></dd> +<dd><input type="checkbox" name="settings_startup" <? if (view.status.setstimeonstartup) then io.write("checked") end ?>></dd> <dt>Save the above settings</dt> <dd><input name="settings_cmd" class="submit" type="submit" value="Save"> (see above)</dd> @@ -30,13 +41,13 @@ <dt>Timeserver hosts...</dt> <dd> <select name="hosts_list" size="3"> -<? if (view.statusinfo.servers) then -for i = 1, table.maxn(view.statusinfo.servers) do ?> - <option value="servers <? io.write(view.statusinfo.servers[i].value) ?>"><? io.write(view.statusinfo.servers[i].value) ?> (pool)</option> +<? if (view.status.servers) then +for i = 1, table.maxn(view.status.servers) do ?> + <option value="servers <? io.write(view.status.servers[i].value) ?>"><? io.write(view.status.servers[i].value) ?> (pool)</option> <? end end ?> -<? if (view.statusinfo.server) then -for i = 1, table.maxn(view.statusinfo.server) do ?> - <option value="server <? io.write(view.statusinfo.server[i].value) ?>"><? io.write(view.statusinfo.server[i].value) ?></option> +<? if (view.status.server) then +for i = 1, table.maxn(view.status.server) do ?> + <option value="server <? io.write(view.status.server[i].value) ?>"><? io.write(view.status.server[i].value) ?></option> <? end end ?> </select><BR> In most cases you could use <i><b>pool.ntp.org</b></i> or <i><b>[countryname].pool.ntp.org</i></b> (if listed in <i><b>http://www.pool.ntp.org/</b></i>). @@ -60,9 +71,9 @@ In most cases you could use <i><b>pool.ntp.org</b></i> or <i><b>[countryname].po <dt>Listen on address...</dt> <dd> <select name="listen_list" size="3"> -<? if (view.statusinfo.listen) then -for i = 1, table.maxn(view.statusinfo.listen) do ?> - <option value="listen on <? io.write(view.statusinfo.listen[i].value) ?>"><? io.write(view.statusinfo.listen[i].value) ?></option> +<? if (view.status.listen) then +for i = 1, table.maxn(view.status.listen) do ?> + <option value="listen on <? io.write(view.status.listen[i].value) ?>"><? io.write(view.status.listen[i].value) ?></option> <? end end ?> </select><BR>Empty list = Listening (acting as server) is disabled<br>"*" = Listen on all local addresses <? if (view.errors.listen_list) then io.write("<p class=error>"..view.errors.listen_list.."</p>") end ?> @@ -75,10 +86,10 @@ for i = 1, table.maxn(view.statusinfo.listen) do ?> <dd><input name="listen_add" type="text" class="text" value=""> <input name="listen_cmd" type="submit" class="submit" value="Add"><? if (view.errors.listen_add) then io.write("<p class=error>"..view.errors.listen_add.."</p>") end ?></dd> </form> - <? --[[ DEBUG INFORMATION require("debugs") io.write(debugs.variables(view)) --]] ?> + diff --git a/openntpd-controller.lua b/openntpd-controller.lua index 6a22744..b7d8c8e 100644 --- a/openntpd-controller.lua +++ b/openntpd-controller.lua @@ -19,7 +19,7 @@ mvc.on_load = function(self, parent) end -settings = function (self) +config = function (self) local cmd = self.clientdata.cmd local errors = {} local modify_opts = nil @@ -76,12 +76,12 @@ settings = function (self) if ( cmd ~= nil ) then local startstop = self.model:startstop_service( cmd ) posix.sleep(1) -- Wait for the process to start|stop - return ( {statusinfo = self.model:get(), + return ( {status = self.model:get(), startstop = "", modify_opts=modify_opts, url = url } ) else - return ( {statusinfo = self.model:get(), startstop = "", + return ( {status = self.model:get(), startstop = "", errors = errors, modify_opts=modify_opts, url = url, @@ -94,35 +94,35 @@ logfile = function (self) return ( {logfile = self.model:get_logfile(), url = url } ) end -read = function (self) +status = function (self) local cmd = self.clientdata.cmd local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller - return ( {statusinfo = self.model:get(), url = url } ) + return ( {status = self.model:get(), url = url } ) end -advanced = function (self) - local filecontent = self.clientdata.modifications or "" +expert = function (self) + local file = self.clientdata.modifications or "" local cmd = self.clientdata.cmd local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller - if ( filecontent ~= "") then - local me = ( {filecontent = self.model:update_filecontent(filecontent), url = url } ) + if ( file ~= "") then + local me = ( {file = self.model:update_filecontent(file), url = url } ) return ( {startstop = "", - statusinfo = self.model:get(), - filecontent = self.model:get_filecontent(), + status = self.model:get(), + file = self.model:get_filecontent(), url = url } ) else if ( cmd ~= nil ) then local startstop = self.model:startstop_service( cmd ) posix.sleep(1) -- Wait for the process to start|stop return ( {startstop = startstop, - statusinfo = self.model:get(), - filecontent = self.model:get_filecontent(), + status = self.model:get(), + filec = self.model:get_filecontent(), url = url } ) else return ( {startstop = "", - statusinfo = self.model:get(), - filecontent = self.model:get_filecontent(), + status = self.model:get(), + file = self.model:get_filecontent(), url = url } ) end end diff --git a/openntpd-advanced-html.lsp b/openntpd-expert-html.lsp index 7baaa56..c74b30d 100644 --- a/openntpd-advanced-html.lsp +++ b/openntpd-expert-html.lsp @@ -1,5 +1,43 @@ <? local view = ... ?> +<? +--[[ DEBUG INFORMATION +require("debugs") +io.write(debugs.variables(view)) +--]] +?> + +<h1>CONFIGURATION</h1> +<H2>Enable/Disable</H2> +<DT>Change status for this program</DT> +<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><?= view.file.details.path ?></dd> + +<dt>File size</dt> +<dd><?= view.file.details.size ?></dd> + +<dt>Last modified</dt> +<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"><?= view.file.content ?></textarea> + +<H2>Save and apply above settings</H2> +<DT>Apply settings</DT> +<DD><input class="submit" type="submit" value="Apply"/></DD> +</form> + +<? --[[ ?> <h1>System time</h1> @@ -34,10 +72,6 @@ <input type="submit" name="cmd" class="submit" value="update"></form> -<? ---[[ DEBUG INFORMATION -require("debugs") -io.write(debugs.variables(view)) ---]] -?> +<? --]] ?> + diff --git a/openntpd-model.lua b/openntpd-model.lua index f74f941..4960534 100644 --- a/openntpd-model.lua +++ b/openntpd-model.lua @@ -40,7 +40,7 @@ local function file_info ( path ) filedetails["group"]=rawget((posix.getgroup(filedetails["gid"])),"name") filedetails["atimelong"]=os.date("%c", filedetails["atime"]) filedetails["mtimelong"]=os.date("%c", filedetails["mtime"]) - filedetails["longname"]=path + filedetails["path"]=path filedetails["name"]=basename(path) if ( filedetails["size"] > 1073741824 ) then @@ -69,9 +69,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 @@ -209,7 +207,7 @@ function get () end config["version"] = string.match(get_version(), "^(%S*)" ) config["date"] = os.date() - config["status"] = startstop + config["enabled"] = startstop config["confd"],config["setstimeonstartup"] = get_confdopts("-s") config["listenstate"] = server config["timechanged"] = last_time_change() @@ -235,8 +233,8 @@ function get_filecontent (self) local configstatus = get() local file = io.open( path ) local file_result = file:read("*a") or "unknown" - file_content["filedetails"]=filedetails - file_content["value"]=file_result + file_content["details"]=filedetails + file_content["content"]=file_result file:close() else file_content = {value="", errtxt="File is missing, but will be created when you save your new settings",filedetails={longname=path, size="0", mtimelong=""}} diff --git a/openntpd-read-html.lsp b/openntpd-read-html.lsp deleted file mode 100644 index 4d1e840..0000000 --- a/openntpd-read-html.lsp +++ /dev/null @@ -1,27 +0,0 @@ -<? local view = ... ?> - -<h1>System time</h1> - -<h2>SYSTEM INFO</h2> - -<dt>Program version</dt> -<dd><? io.write(view.statusinfo.version) ?></dd> - -<dt>Process status</dt> -<dd><? io.write(view.statusinfo.status) ?></dd> - -<dt>Configured as server (listens)</dt> -<dd><? io.write(view.statusinfo.listenstate) ?></dd> - -<dt>Current time</dt> -<dd><? io.write(view.statusinfo.date) ?></dd> - -<dt>Previous time adjustment</dt> -<dd><? io.write(view.statusinfo.timechanged) ?></dd> - -<? ---[[ DEBUG INFORMATION -require("debugs") -io.write(debugs.variables(view)) ---]] -?> diff --git a/openntpd-status-html.lsp b/openntpd-status-html.lsp new file mode 100644 index 0000000..d1211c5 --- /dev/null +++ b/openntpd-status-html.lsp @@ -0,0 +1,29 @@ +<? local view = ... ?> + +<h1>SYSTEM INFO</h1> + +<h2>SYSTEM INFO</h2> + +<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>PROGRAM SPECIFIC OPTIONS/INFORMATION</H3> + +<dt>Configured as server (listens)</dt> +<dd><? io.write(view.status.listenstate) ?></dd> + +<dt>Current time</dt> +<dd><? io.write(view.status.date) ?></dd> + +<dt>Previous time adjustment</dt> +<dd><? io.write(view.status.timechanged) ?></dd> + +<? +--[[ DEBUG INFORMATION +require("debugs") +io.write(debugs.variables(view)) +--]] +?> diff --git a/openntpd.menu b/openntpd.menu index 2274c41..46706ab 100644 --- a/openntpd.menu +++ b/openntpd.menu @@ -1,2 +1,2 @@ #CAT GROUP/DESC TAB ACTION -Networking 20NTPD_config NTPD_config read +Networking 20NTPD_config NTPD_config status |