summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile44
-rw-r--r--README1
-rw-r--r--config.mk10
-rw-r--r--unbound-controller.lua21
l---------unbound-expert-html.lsp1
-rw-r--r--unbound-logfile-html.lsp8
-rw-r--r--unbound-model.lua57
l---------unbound-status-html.lsp1
-rw-r--r--unbound.menu4
-rw-r--r--unbound.roles3
10 files changed, 150 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..403f43e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+APP_NAME=unbound
+PACKAGE=acf-$(APP_NAME)
+VERSION=0.0.1
+
+APP_DIST=\
+ unbound* \
+
+
+EXTRA_DIST=README Makefile config.mk
+
+DISTFILES=$(APP_DIST) $(EXTRA_DIST)
+
+TAR=tar
+
+P=$(PACKAGE)-$(VERSION)
+tarball=$(P).tar.bz2
+install_dir=$(DESTDIR)/$(appdir)/$(APP_NAME)
+
+all:
+clean:
+ rm -rf $(tarball) $(P)
+
+dist: $(tarball)
+
+install:
+ mkdir -p "$(install_dir)"
+ cp -a $(APP_DIST) "$(install_dir)"
+
+$(tarball): $(DISTFILES)
+ rm -rf $(P)
+ mkdir -p $(P)
+ cp -a $(DISTFILES) $(P)
+ $(TAR) -jcf $@ $(P)
+ rm -rf $(P)
+
+# target that creates a tar package, unpacks is and install from package
+dist-install: $(tarball)
+ $(TAR) -jxf $(tarball)
+ $(MAKE) -C $(P) install DESTDIR=$(DESTDIR)
+ rm -rf $(P)
+
+include config.mk
+
+.PHONY: all clean dist install dist-install
diff --git a/README b/README
new file mode 100644
index 0000000..d6e51df
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+ACF for unbound DNS server
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..45f4d21
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,10 @@
+prefix=/usr
+datadir=${prefix}/share
+sysconfdir=${prefix}/etc
+localstatedir=${prefix}/var
+acfdir=${datadir}/acf
+wwwdir=${acfdir}/www
+cgibindir=${acfdir}/cgi-bin
+appdir=${acfdir}/app
+acflibdir=${acfdir}/lib
+sessionsdir=${localstatedir}/lib/acf/sessions
diff --git a/unbound-controller.lua b/unbound-controller.lua
new file mode 100644
index 0000000..cca194e
--- /dev/null
+++ b/unbound-controller.lua
@@ -0,0 +1,21 @@
+local mymodule = {}
+
+mymodule.default_action = "status"
+
+function mymodule.status(self)
+ return self.model.getstatus()
+end
+
+function mymodule.startstop(self)
+ return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata)
+end
+
+function mymodule.expert(self)
+ return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Unbound Config", "Configuration Set")
+end
+
+function mymodule.logfile(self)
+ return self.model.get_logfile()
+end
+
+return mymodule
diff --git a/unbound-expert-html.lsp b/unbound-expert-html.lsp
new file mode 120000
index 0000000..207f324
--- /dev/null
+++ b/unbound-expert-html.lsp
@@ -0,0 +1 @@
+../expert-html.lsp \ No newline at end of file
diff --git a/unbound-logfile-html.lsp b/unbound-logfile-html.lsp
new file mode 100644
index 0000000..d718396
--- /dev/null
+++ b/unbound-logfile-html.lsp
@@ -0,0 +1,8 @@
+<% local data, viewlibrary = ...
+%>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ for i,logfile in ipairs(data.value) do
+ viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename=logfile.path, grep=logfile.grep})
+ end
+end %>
diff --git a/unbound-model.lua b/unbound-model.lua
new file mode 100644
index 0000000..1743f72
--- /dev/null
+++ b/unbound-model.lua
@@ -0,0 +1,57 @@
+local mymodule = {}
+
+-- Load libraries
+modelfunctions = require("modelfunctions")
+fs = require("acf.fs")
+format = require("acf.format")
+
+-- Set variables
+local configfile = "/etc/unbound/unbound.conf"
+local processname = "unbound"
+local packagename = "unbound"
+
+local config
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+function mymodule.get_startstop(self, clientdata)
+ return modelfunctions.get_startstop(processname)
+end
+
+function mymodule.startstop_service(self, startstop, action)
+ return modelfunctions.startstop_service(startstop, action)
+end
+
+function mymodule.getstatus()
+ return modelfunctions.getstatus(processname, packagename, "Unbound Status")
+end
+
+function mymodule.get_filedetails()
+ return modelfunctions.getfiledetails(configfile)
+end
+
+function mymodule.update_filedetails(self, filedetails)
+ return modelfunctions.setfiledetails(self, filedetails, {configfile})
+end
+
+function mymodule.get_logfile(f)
+ -- Determine the log file from the config file
+ -- TODO determine how best to parse the file
+--[[
+ config = config or format.parse_ini_file(fs.read_file(configfile) or "", "")
+ local files = {}
+ if config and config.logfile then
+ files[#files+1] = {path = config.logfile}
+ end
+--]]
+ if 0 == #files then
+ files[#files+1] = {path = "/var/log/messages", grep = "unbound"}
+ end
+ return cfe({ value=files, label="Unbound Log Files" })
+end
+
+return mymodule
diff --git a/unbound-status-html.lsp b/unbound-status-html.lsp
new file mode 120000
index 0000000..b2f8480
--- /dev/null
+++ b/unbound-status-html.lsp
@@ -0,0 +1 @@
+../status-html.lsp \ No newline at end of file
diff --git a/unbound.menu b/unbound.menu
new file mode 100644
index 0000000..e39b171
--- /dev/null
+++ b/unbound.menu
@@ -0,0 +1,4 @@
+#CAT GROUP/DESC TAB ACTION
+Networking 30Unbound Status status
+Networking 30Unbound Expert expert
+Networking 30Unbound Logfile logfile
diff --git a/unbound.roles b/unbound.roles
new file mode 100644
index 0000000..97a89ae
--- /dev/null
+++ b/unbound.roles
@@ -0,0 +1,3 @@
+USER=unbound:status,unbound:logfile,unbound:startstop
+EXPERT=unbound:expert
+ADMIN=unbound:status,unbound:logfile,unbound:startstop,unbound:expert