summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-08-25 11:59:53 +0000
committerTed Trask <ttrask01@yahoo.com>2009-08-25 11:59:53 +0000
commite5c610f887196986183d11cda9ced7735c355a37 (patch)
tree020633c78a1b80b1de7ba64e08efc9235e36960d
parent0ab4dcf45f28de3fca8fe35b7513da33da97b20d (diff)
downloadacf-dhcp-e5c610f887196986183d11cda9ced7735c355a37.tar.bz2
acf-dhcp-e5c610f887196986183d11cda9ced7735c355a37.tar.xz
Added ability to edit conf.d file, bumped to 0.4.2v0.4.2
-rw-r--r--Makefile2
-rw-r--r--dhcp-controller.lua6
l---------dhcp-expert-html.lsp2
-rw-r--r--dhcp-listfiles-html.lsp32
-rw-r--r--dhcp-model.lua19
-rw-r--r--dhcp.menu2
-rw-r--r--dhcp.roles4
7 files changed, 58 insertions, 9 deletions
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 %>
+
+<h1><%= html.html_escape(data.label) %></h1>
+<TABLE>
+ <TR style="background:#eee;font-weight:bold;">
+ <TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">File</TD>
+ <TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">Size</TD>
+ <TD style="white-space:nowrap;text-align:left;" class="header">Last Modified</TD>
+ </TR>
+
+<% for i,file in ipairs(data.value) do %>
+ <TR>
+ <TD style="padding-right:20px;white-space:nowrap;">
+ <%= html.link{value = "expert?filename=" .. file.filename.."&redir="..page_info.orig_action, label=file.filename} %>
+ </TD>
+ <TD style="padding-right:20px;white-space:nowrap;"><%= html.html_escape(file.filesize) %></TD>
+ <TD style="white-space:nowrap;" width="90%"><%= html.html_escape(file.mtime) %></TD>
+ </TR>
+<% end %>
+</TABLE>
+
+<% 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