summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-11-05 15:27:43 +0000
committerTed Trask <ttrask01@yahoo.com>2009-11-05 15:27:43 +0000
commit5261ae2fa86ae090a2923b502646aa03c6a275a9 (patch)
tree4bc0f92f7d8b0a844197d3bab6c1c9879b82cf0d
downloadacf-kamailio-5261ae2fa86ae090a2923b502646aa03c6a275a9.tar.bz2
acf-kamailio-5261ae2fa86ae090a2923b502646aa03c6a275a9.tar.xz
First cut at kamailio ACF. Just status, listfiles, edit, startstop.v0.1.0
-rw-r--r--Makefile44
-rw-r--r--README1
-rw-r--r--config.mk10
-rw-r--r--kamailio-controller.lua22
l---------kamailio-edit-html.lsp1
-rw-r--r--kamailio-listfiles-html.lsp28
-rw-r--r--kamailio-model.lua53
l---------kamailio-startstop-html.lsp1
l---------kamailio-status-html.lsp1
-rw-r--r--kamailio.menu4
-rw-r--r--kamailio.roles3
11 files changed, 168 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..50d9b3d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+APP_NAME=kamailio
+PACKAGE=acf-$(APP_NAME)
+VERSION=0.1.0
+
+APP_DIST=\
+ kamailio* \
+
+
+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..ec521f5
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+ACF for kamailio
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/kamailio-controller.lua b/kamailio-controller.lua
new file mode 100644
index 0000000..45a8fd7
--- /dev/null
+++ b/kamailio-controller.lua
@@ -0,0 +1,22 @@
+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.clientdata)
+end
+
+function listfiles(self)
+ return self.model.list_files()
+end
+
+function edit(self)
+ return controllerfunctions.handle_form(self, function() return self.model.get_filedetails(self.clientdata.filename) end, self.model.update_filedetails, self.clientdata, "Save", "Edit File", "File Saved")
+end
diff --git a/kamailio-edit-html.lsp b/kamailio-edit-html.lsp
new file mode 120000
index 0000000..15b1930
--- /dev/null
+++ b/kamailio-edit-html.lsp
@@ -0,0 +1 @@
+../filedetails-html.lsp \ No newline at end of file
diff --git a/kamailio-listfiles-html.lsp b/kamailio-listfiles-html.lsp
new file mode 100644
index 0000000..0719f76
--- /dev/null
+++ b/kamailio-listfiles-html.lsp
@@ -0,0 +1,28 @@
+<% local view, viewlibrary, page_info, session = ...
+require("viewfunctions")
+%>
+
+<% displaycommandresults({"edit", "startstop"}, session) %>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
+
+<h1>Configuration</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 k,v in ipairs( view.value ) do
+ io.write( "<tr><td><a href=\"" .. html.html_escape(page_info.script .. page_info.prefix .. page_info.controller) .. "/edit?filename=" .. html.html_escape(v.filename) .. "&redir=" .. html.html_escape(page_info.orig_action) .. "\">" .. html.html_escape(v.filename) .. "</a></td><td>" .. html.html_escape(v.size) .."</td><td>" .. html.html_escape(v.mtime) .."</td></tr>\n" )
+ end
+%>
+</TABLE>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/kamailio-model.lua b/kamailio-model.lua
new file mode 100644
index 0000000..4915787
--- /dev/null
+++ b/kamailio-model.lua
@@ -0,0 +1,53 @@
+module(..., package.seeall)
+
+-- Load libraries
+require("modelfunctions")
+require("fs")
+require("validator")
+
+-- Set variables
+local processname = "kamailio"
+local packagename = "kamailio"
+local baseurl = "/etc/kamailio"
+
+local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+local is_valid_filename = function(filename)
+ local dirname = dirname(filename)
+ return validator.is_valid_filename(filename) and string.match(dirname, baseurl) and not string.match(dirname, "%.%.")
+end
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+function startstop_service(action)
+ return modelfunctions.startstop_service(processname, action)
+end
+
+function getstatus()
+ return modelfunctions.getstatus(processname, packagename, "Kamailio Status")
+end
+
+function get_filedetails(filename)
+ return modelfunctions.getfiledetails(filename, is_valid_filename)
+end
+
+function update_filedetails(filedetails)
+ return modelfunctions.setfiledetails(filedetails, is_valid_filename)
+end
+
+function list_files()
+ local retval = {}
+ for file in fs.find(null, baseurl) do
+ local details = fs.stat(file)
+ if details.type == "regular" then
+ details.filename = file
+ table.insert(retval, details)
+ end
+ end
+ table.sort(retval, function(a,b) return a.filename < b.filename end)
+ return cfe({ type="structure", value=retval, label="List of Kamailio files" })
+end
diff --git a/kamailio-startstop-html.lsp b/kamailio-startstop-html.lsp
new file mode 120000
index 0000000..0ea2627
--- /dev/null
+++ b/kamailio-startstop-html.lsp
@@ -0,0 +1 @@
+../startstop-html.lsp \ No newline at end of file
diff --git a/kamailio-status-html.lsp b/kamailio-status-html.lsp
new file mode 120000
index 0000000..b2f8480
--- /dev/null
+++ b/kamailio-status-html.lsp
@@ -0,0 +1 @@
+../status-html.lsp \ No newline at end of file
diff --git a/kamailio.menu b/kamailio.menu
new file mode 100644
index 0000000..f806819
--- /dev/null
+++ b/kamailio.menu
@@ -0,0 +1,4 @@
+# Prefix and controller are already known at this point
+# Cat Group Tab Action
+Applications 86Kamailio Status status
+Applications 86Kamailio Expert listfiles
diff --git a/kamailio.roles b/kamailio.roles
new file mode 100644
index 0000000..b40dd8a
--- /dev/null
+++ b/kamailio.roles
@@ -0,0 +1,3 @@
+USER=kamailio:status,kamailio:startstop
+EXPERT=kamailio:listfiles,kamailio:edit
+ADMIN=kamailio:status,kamailio:startstop,kamailio:listfiles,kamailio:edit