summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile44
-rw-r--r--README0
-rw-r--r--config.mk11
-rw-r--r--freeswitch-controller.lua21
l---------freeswitch-edit-html.lsp1
-rw-r--r--freeswitch-listfiles-html.lsp28
-rw-r--r--freeswitch-model.lua58
l---------freeswitch-startstop-html.lsp1
l---------freeswitch-status-html.lsp1
-rw-r--r--freeswitch.menu4
-rw-r--r--freeswitch.roles3
11 files changed, 172 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7b558a9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+APP_NAME=freeswitch
+PACKAGE=acf-$(APP_NAME)
+VERSION=0.1.0
+
+APP_DIST=\
+ freeswitch* \
+
+
+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..e69de29
--- /dev/null
+++ b/README
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..b859a2b
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,11 @@
+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
+squid-cfg-dir=/etc/squid
diff --git a/freeswitch-controller.lua b/freeswitch-controller.lua
new file mode 100644
index 0000000..04d6ea7
--- /dev/null
+++ b/freeswitch-controller.lua
@@ -0,0 +1,21 @@
+module (..., package.seeall)
+
+require("controllerfunctions")
+
+default_action = "status"
+
+status = function( self )
+ return self.model.get_status()
+end
+
+startstop = function( self )
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.clientdata)
+end
+
+listfiles = function( self )
+ return self.model.list_files()
+end
+
+edit = function( self )
+ return controllerfunctions.handle_form(self, function() return self.model.get_file(self.clientdata.filename) end, self.model.update_file, self.clientdata, "Save", "Edit File", "File Saved")
+end
diff --git a/freeswitch-edit-html.lsp b/freeswitch-edit-html.lsp
new file mode 120000
index 0000000..15b1930
--- /dev/null
+++ b/freeswitch-edit-html.lsp
@@ -0,0 +1 @@
+../filedetails-html.lsp \ No newline at end of file
diff --git a/freeswitch-listfiles-html.lsp b/freeswitch-listfiles-html.lsp
new file mode 100644
index 0000000..caff231
--- /dev/null
+++ b/freeswitch-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>
+<DL><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></DL>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/freeswitch-model.lua b/freeswitch-model.lua
new file mode 100644
index 0000000..3095cde
--- /dev/null
+++ b/freeswitch-model.lua
@@ -0,0 +1,58 @@
+module (..., package.seeall)
+
+-- Load libraries
+require("modelfunctions")
+require("posix")
+require("fs")
+require("format")
+require("validator")
+
+-- Set variables
+local processname = "freeswitch"
+local packagename = "freeswitch"
+local baseurl = "/etc/freeswitch"
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+local is_valid_filename = function(filename)
+ local dirname = posix.dirname(filename)
+ return validator.is_valid_filename(filename) and string.match(dirname, baseurl) and not string.match(dirname, "%.%.")
+end
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+get_status = function()
+ return modelfunctions.getstatus(processname, packagename, "Freeswitch Status")
+end
+
+function startstop_service(action)
+ return modelfunctions.startstop_service(processname, action, {"Start", "Stop", "Restart"})
+end
+
+get_file = function(filename)
+ return modelfunctions.getfiledetails(filename, is_valid_filename)
+end
+
+update_file = function(filedetails)
+ local ret = modelfunctions.setfiledetails(filedetails, is_valid_filename)
+ if not ret.errtxt then
+ posix.chmod(filedetails.value.filename.value, "rw-------")
+ posix.chown(filedetails.value.filename.value, posix.getpasswd("freeswitch", "uid") or 0, posix.getpasswd("freeswitch", "gid") or 0)
+ end
+ return ret
+end
+
+list_files = function()
+ 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 Freeswitch files" })
+end
diff --git a/freeswitch-startstop-html.lsp b/freeswitch-startstop-html.lsp
new file mode 120000
index 0000000..0ea2627
--- /dev/null
+++ b/freeswitch-startstop-html.lsp
@@ -0,0 +1 @@
+../startstop-html.lsp \ No newline at end of file
diff --git a/freeswitch-status-html.lsp b/freeswitch-status-html.lsp
new file mode 120000
index 0000000..b2f8480
--- /dev/null
+++ b/freeswitch-status-html.lsp
@@ -0,0 +1 @@
+../status-html.lsp \ No newline at end of file
diff --git a/freeswitch.menu b/freeswitch.menu
new file mode 100644
index 0000000..0cb8d87
--- /dev/null
+++ b/freeswitch.menu
@@ -0,0 +1,4 @@
+# Prefix and controller are already known at this point
+# Cat Group Tab Action
+Applications 87Freeswitch Status status
+Applications 87Freeswitch Expert listfiles
diff --git a/freeswitch.roles b/freeswitch.roles
new file mode 100644
index 0000000..e4a48cf
--- /dev/null
+++ b/freeswitch.roles
@@ -0,0 +1,3 @@
+USER=freeswitch:status,freeswitch:startstop
+EXPERT=freeswitch:listfiles,freeswitch:edit
+ADMIN=freeswitch:status,freeswitch:startstop,freeswitch:listfiles,freeswitch:edit