summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-12-31 15:49:13 +0000
committerTed Trask <ttrask01@yahoo.com>2008-12-31 15:49:13 +0000
commit693030035ed1152f8ec7144a622e9122c373c026 (patch)
tree01bcee7809da8ef5d874e36df96fea6bf474d25f
downloadacf-postfix-693030035ed1152f8ec7144a622e9122c373c026.tar.bz2
acf-postfix-693030035ed1152f8ec7144a622e9122c373c026.tar.xz
Added postfix controller with basic functionality.
git-svn-id: svn://svn.alpinelinux.org/acf/postfix/trunk@1655 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--Makefile44
-rw-r--r--README1
-rw-r--r--config.mk10
-rw-r--r--postfix-controller.lua26
-rw-r--r--postfix-details-html.lsp17
l---------postfix-expert-html.lsp1
-rw-r--r--postfix-listfiles-html.lsp39
-rw-r--r--postfix-logfile-html.lsp7
-rw-r--r--postfix-model.lua53
l---------postfix-startstop-html.lsp1
l---------postfix-status-html.lsp1
-rw-r--r--postfix.menu4
-rw-r--r--postfix.roles3
13 files changed, 207 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..4ce698c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+APP_NAME=postfix
+PACKAGE=acf-$(APP_NAME)
+VERSION=0.1.0
+
+APP_DIST=\
+ postfix* \
+
+
+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..071aa75
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+ACF for postfix
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/postfix-controller.lua b/postfix-controller.lua
new file mode 100644
index 0000000..682192d
--- /dev/null
+++ b/postfix-controller.lua
@@ -0,0 +1,26 @@
+module(..., package.seeall)
+
+-- Load libraries
+require("controllerfunctions")
+
+default_action = "status"
+
+function status(self)
+ return self.model.getstatus()
+end
+
+function startstop(self)
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata)
+end
+
+function details(self)
+ return self.model.getstatusdetails()
+end
+
+function listfiles(self)
+ return self.model.getfilelist()
+end
+
+function expert(self)
+ return controllerfunctions.handle_form(self, function() return self.model.getfiledetails(self.clientdata.filename) end, self.model.updatefiledetails, self.clientdata, "Save", "Edit Postfix File", "File Saved")
+end
diff --git a/postfix-details-html.lsp b/postfix-details-html.lsp
new file mode 100644
index 0000000..f60bb13
--- /dev/null
+++ b/postfix-details-html.lsp
@@ -0,0 +1,17 @@
+<% local data, viewlibrary = ...
+require("viewfunctions")
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(data))
+io.write("</span>")
+--]]
+%>
+
+<% viewlibrary.dispatch_component("status") %>
+
+<H2><%= data.label %></H2>
+<DL>
+<%
+displayitem(data)
+%>
+</DL>
diff --git a/postfix-expert-html.lsp b/postfix-expert-html.lsp
new file mode 120000
index 0000000..207f324
--- /dev/null
+++ b/postfix-expert-html.lsp
@@ -0,0 +1 @@
+../expert-html.lsp \ No newline at end of file
diff --git a/postfix-listfiles-html.lsp b/postfix-listfiles-html.lsp
new file mode 100644
index 0000000..ea54404
--- /dev/null
+++ b/postfix-listfiles-html.lsp
@@ -0,0 +1,39 @@
+<% local data, viewlibrary, page_info, session = ...
+require("viewfunctions")
+%>
+<%
+--[[ DEBUG INFORMATION
+io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
+io.write(html.cfe_unpack(data))
+io.write("</span>")
+--]]
+%>
+
+<% displaycommandresults({"expert", "startstop"}, session) %>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
+
+<h1><%= 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;"><%= file.filesize %></TD>
+ <TD style="white-space:nowrap;" width="90%"><%= file.mtime %></TD>
+ </TR>
+<% end %>
+</TABLE>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/postfix-logfile-html.lsp b/postfix-logfile-html.lsp
new file mode 100644
index 0000000..20db6c2
--- /dev/null
+++ b/postfix-logfile-html.lsp
@@ -0,0 +1,7 @@
+<% local data, viewlibrary = ...
+require("viewfunctions")
+%>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {name="/var/log/messages", grep="postfix"})
+end %>
diff --git a/postfix-model.lua b/postfix-model.lua
new file mode 100644
index 0000000..87e6a00
--- /dev/null
+++ b/postfix-model.lua
@@ -0,0 +1,53 @@
+module(..., package.seeall)
+
+-- Load libraries
+require("modelfunctions")
+require("fs")
+require("format")
+
+-- Set variables
+local processname = "postfix"
+local packagename = "postfix"
+local baseurl = "/etc/postfix/"
+local filelist = {baseurl.."main.cf", baseurl.."master.cf", baseurl.."saslpass"}
+
+local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+function startstop_service(action)
+ return modelfunctions.startstop_service(processname, action)
+end
+
+function getstatus()
+ return modelfunctions.getstatus(processname, packagename, "Postfix Status")
+end
+
+function getstatusdetails()
+ return cfe({ type="longtext", value="", label="Postfix Status Details" })
+end
+
+function getfilelist()
+ local listed_files = {}
+
+ for i,name in ipairs(filelist) do
+ local filedetails = fs.stat(name)
+ table.insert ( listed_files , {filename=name, mtime=filedetails.mtime, filesize=filedetails.size} )
+ end
+
+ table.sort(listed_files, function (a,b) return (a.filename < b.filename) end )
+
+ return cfe({ type="list", value=listed_files, label="Postfix File List" })
+end
+
+function getfiledetails(filename)
+ return modelfunctions.getfiledetails(filename, filelist)
+end
+
+function updatefiledetails(filedetails)
+ return modelfunctions.setfiledetails(filedetails, filelist)
+end
diff --git a/postfix-startstop-html.lsp b/postfix-startstop-html.lsp
new file mode 120000
index 0000000..0ea2627
--- /dev/null
+++ b/postfix-startstop-html.lsp
@@ -0,0 +1 @@
+../startstop-html.lsp \ No newline at end of file
diff --git a/postfix-status-html.lsp b/postfix-status-html.lsp
new file mode 120000
index 0000000..b2f8480
--- /dev/null
+++ b/postfix-status-html.lsp
@@ -0,0 +1 @@
+../status-html.lsp \ No newline at end of file
diff --git a/postfix.menu b/postfix.menu
new file mode 100644
index 0000000..96e1198
--- /dev/null
+++ b/postfix.menu
@@ -0,0 +1,4 @@
+#CAT GROUP/DESC TAB ACTION
+Networking 25Postfix Status status
+Networking 25Postfix Expert listfiles
+Networking 25Postfix Logfile logfile
diff --git a/postfix.roles b/postfix.roles
new file mode 100644
index 0000000..21281a4
--- /dev/null
+++ b/postfix.roles
@@ -0,0 +1,3 @@
+USER=postfix:status,postfix:logfile,postfix:details,postfix:startstop
+EXPERT=postfix:listfiles,postfix:expert
+ADMIN=postfix:status,postfix:logfile,postfix:details,postfix:startstop,postfix:listfiles,postfix:expert