summaryrefslogtreecommitdiffstats
path: root/dhcp-controller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'dhcp-controller.lua')
-rw-r--r--dhcp-controller.lua73
1 files changed, 58 insertions, 15 deletions
diff --git a/dhcp-controller.lua b/dhcp-controller.lua
index cf9d307..9e0d428 100644
--- a/dhcp-controller.lua
+++ b/dhcp-controller.lua
@@ -6,7 +6,7 @@ module (..., package.seeall)
-- 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)
local list_redir = function (self)
- self.conf.action = "home"
+ self.conf.action = "status"
self.conf.type = "redir"
error (self.conf)
end
@@ -214,6 +214,18 @@ createnet = function ( self )
end
end
+status = function ( self )
+ return cfe({ option = { script = ENV["SCRIPT_NAME"],
+ prefix = self.conf.prefix,
+ controller = self.conf.controller,
+ action = self.conf.action,
+ extra = "",
+ },
+ value = "",
+ genmsg = genmsg,
+ info = self.model.getstatus() })
+end
+
home = function ( self )
-- dependancy check for neccessary libs/packages et al.
@@ -242,25 +254,56 @@ home = function ( self )
action = self.conf.action,
extra = ""
}
- local info = { status = { value = "stopped" }, version = { value = self.model.get_dhcpd_version() }, srvctrl = { value = srvctrl} };
- if self.model.is_running( "dhcpd" ) then
- info.status.value = "running"
- end
+
+ local info = self.model.getstatus()
info.subnets = self.model.get_subnets()
- return ( cfe({ option = option, value = "", genmsg = genmsg, info = info }) )
+ -- Add a management buttons
+ local management = {}
+ management.start = cfe({ name="cmdmanagement",
+ label="Program control-panel",
+ value="Start",
+ type="submit",
+ })
+ management.stop = cfe({ name="cmdmanagement",
+ label="Program control-panel",
+ value="Stop",
+ type="submit",
+ })
+ management.restart = cfe({ name="cmdmanagement",
+ label="Program control-panel",
+ value="Restart",
+ type="submit",
+ })
+ -- Disable management buttons based on if the process is running or not
+ if (string.lower(info.status.value) == "enabled") then management.start.disabled = "yes" end
+ if (string.lower(info.status.value) == "disabled") then management.stop.disabled = "yes" end
+ if (string.lower(info.status.value) == "disabled") then management.restart.disabled = "yes" end
+
+ return ( cfe({ option = option, value = "", genmsg = genmsg, info = info, management = management, }) )
end
-view = function ( self )
+viewleases = function ( self )
- local filename = ""
- if self.clientdata.conf then
- filename = "/etc/dhcp/dhcpd.conf"
- elseif self.clientdata.leases then
- filename = "/var/lib/dhcpd/dhcpd.leases";
- else
- list_redir(self)
- end
+ local filename = "/var/lib/dhcp/dhcpd.leases";
+
+ local option = { script = ENV["SCRIPT_NAME"],
+ prefix = self.conf.prefix,
+ controller = self.conf.controller,
+ action = self.conf.action,
+ extra = ""
+ }
+
+ local value = { filename = { value=filename },
+ contents = { value=self.model.read_file(filename) }
+ }
+
+ return ( cfe({ option = option, value = value }) )
+end
+
+viewconfig = function ( self )
+
+ local filename = "/etc/dhcp/dhcpd.conf"
local option = { script = ENV["SCRIPT_NAME"],
prefix = self.conf.prefix,