From e5c610f887196986183d11cda9ced7735c355a37 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 25 Aug 2009 11:59:53 +0000 Subject: Added ability to edit conf.d file, bumped to 0.4.2 --- Makefile | 2 +- dhcp-controller.lua | 6 +++++- dhcp-expert-html.lsp | 2 +- dhcp-listfiles-html.lsp | 32 ++++++++++++++++++++++++++++++++ dhcp-model.lua | 19 ++++++++++++++++--- dhcp.menu | 2 +- dhcp.roles | 4 ++-- 7 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 dhcp-listfiles-html.lsp diff --git a/Makefile b/Makefile index 7d5252b..07acd4a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ APP_NAME=dhcp PACKAGE=acf-$(APP_NAME) -VERSION=0.4.1 +VERSION=0.4.2 APP_DIST=\ dhcp* \ diff --git a/dhcp-controller.lua b/dhcp-controller.lua index b444a89..a3bda73 100644 --- a/dhcp-controller.lua +++ b/dhcp-controller.lua @@ -53,6 +53,10 @@ viewleases = function ( self ) return self.model.getleases() end +listfiles = function(self) + return self.model.listconfigfiles() +end + expert = function(self) - return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Config", "Configuration Set") + return controllerfunctions.handle_form(self, function() return self.model.getconfigfile(self.clientdata.filename) end, self.model.setconfigfile, self.clientdata, "Save", "Edit DHCP File", "File Saved") end diff --git a/dhcp-expert-html.lsp b/dhcp-expert-html.lsp index 207f324..15b1930 120000 --- a/dhcp-expert-html.lsp +++ b/dhcp-expert-html.lsp @@ -1 +1 @@ -../expert-html.lsp \ No newline at end of file +../filedetails-html.lsp \ No newline at end of file diff --git a/dhcp-listfiles-html.lsp b/dhcp-listfiles-html.lsp new file mode 100644 index 0000000..ef5687f --- /dev/null +++ b/dhcp-listfiles-html.lsp @@ -0,0 +1,32 @@ +<% local data, viewlibrary, page_info, session = ... +require("viewfunctions") +%> + +<% displaycommandresults({"expert", "startstop"}, session) %> + +<% if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("status") +end %> + +

<%= html.html_escape(data.label) %>

+ + + + + + + +<% for i,file in ipairs(data.value) do %> + + + + + +<% end %> +
FileSizeLast Modified
+ <%= html.link{value = "expert?filename=" .. file.filename.."&redir="..page_info.orig_action, label=file.filename} %> + <%= html.html_escape(file.filesize) %><%= html.html_escape(file.mtime) %>
+ +<% if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("startstop") +end %> diff --git a/dhcp-model.lua b/dhcp-model.lua index d5a676f..247b6c3 100644 --- a/dhcp-model.lua +++ b/dhcp-model.lua @@ -8,6 +8,8 @@ require("validator") local subnet = {} local configfile = "/etc/dhcp/dhcpd.conf" +local confdfile = "/etc/conf.d/dhcpd" +local filelist = {configfile, confdfile} local processname = "dhcpd" local packagename = "dhcp" local leasefile = "/var/lib/dhcp/dhcpd.leases" @@ -765,12 +767,23 @@ update_settings = function ( settings ) return settings end -getconfigfile = function() - return modelfunctions.getfiledetails(configfile) +listconfigfiles = function() + local listed_files = {} + for i,name in ipairs(filelist) do + local filedetails = fs.stat(name) or {} + table.insert ( listed_files , {filename=name, mtime=filedetails.mtime or "---", filesize=filedetails.size or "0"} ) + end + table.sort(listed_files, function (a,b) return (a.filename < b.filename) end ) + + return cfe({ type="list", value=listed_files, label="DHCP File List" }) +end + +getconfigfile = function(filename) + return modelfunctions.getfiledetails(filename, filelist) end setconfigfile = function(filedetails) - return modelfunctions.setfiledetails(filedetails, {configfile}) + return modelfunctions.setfiledetails(filedetails, filelist) end getleases = function() diff --git a/dhcp.menu b/dhcp.menu index 7da5522..26f6a09 100644 --- a/dhcp.menu +++ b/dhcp.menu @@ -3,4 +3,4 @@ Networking 45DHCP Status status Networking 45DHCP Config home Networking 45DHCP View_leases viewleases -Networking 45DHCP Expert expert +Networking 45DHCP Expert listfiles diff --git a/dhcp.roles b/dhcp.roles index 89737ae..7e4af3b 100644 --- a/dhcp.roles +++ b/dhcp.roles @@ -1,4 +1,4 @@ USER=dhcp:viewleases,dhcp:status,dhcp:startstop,dhcp:listsubnets,dhcp:listhosts EDITOR=dhcp:home,dhcp:createsubnet,dhcp:createhost,dhcp:delsubnet,dhcp:delhost,dhcp:settings,dhcp:editsubnet,dhcp:edithost -EXPERT=dhcp:expert -ADMIN=dhcp:viewleases,dhcp:status,dhcp:startstop,dhcp:listsubnets,dhcp:listhosts,dhcp:home,dhcp:createsubnet,dhcp:createhost,dhcp:delsubnet,dhcp:delhost,dhcp:settings,dhcp:editsubnet,dhcp:edithost,dhcp:expert +EXPERT=dhcp:listfiles,dhcp:expert +ADMIN=dhcp:viewleases,dhcp:status,dhcp:startstop,dhcp:listsubnets,dhcp:listhosts,dhcp:home,dhcp:createsubnet,dhcp:createhost,dhcp:delsubnet,dhcp:delhost,dhcp:settings,dhcp:editsubnet,dhcp:edithost,dhcp:listfiles,dhcp:expert -- cgit v1.2.3