From c202aa26324b7c99bde4ad8614a177e703633cba Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Wed, 14 Mar 2012 00:52:44 -0300 Subject: asterisk - first relase of asterisk package for pfsense --- config/asterisk/asterisk.inc | 93 +++++++++++++ config/asterisk/asterisk.xml | 103 ++++++++++++++ config/asterisk/asterisk_calls.php | 167 ++++++++++++++++++++++ config/asterisk/asterisk_cmd.php | 120 ++++++++++++++++ config/asterisk/asterisk_edit_file.php | 246 +++++++++++++++++++++++++++++++++ config/asterisk/asterisk_log.php | 130 +++++++++++++++++ pkg_config.8.xml | 17 +++ pkg_config.8.xml.amd64 | 19 ++- 8 files changed, 894 insertions(+), 1 deletion(-) create mode 100644 config/asterisk/asterisk.inc create mode 100644 config/asterisk/asterisk.xml create mode 100644 config/asterisk/asterisk_calls.php create mode 100644 config/asterisk/asterisk_cmd.php create mode 100644 config/asterisk/asterisk_edit_file.php create mode 100644 config/asterisk/asterisk_log.php diff --git a/config/asterisk/asterisk.inc b/config/asterisk/asterisk.inc new file mode 100644 index 00000000..c4630114 --- /dev/null +++ b/config/asterisk/asterisk.inc @@ -0,0 +1,93 @@ + [a-z,A-Z,/]@'; + $replace[0]='astdbdir => /tmp'; + $pattern[1]='@astspooldir => [a-z,A-Z,/]@'; + $replace[1]='astspooldir => /tmp'; + $script_file=preg_replace($pattern,$replace,$script_file); + file_put_contents($script, $script_file, LOCK_EX); + } + + } + + $script='/usr/local/etc/rc.d/asterisk'; + if (file_exists($script)){ + $script_file=file_get_contents($script); + if (preg_match('/NO/',$script_file)){ + $script_file=preg_replace("/NO/","YES",$script_file); + file_put_contents($script, $script_file, LOCK_EX); + } + chmod ($script,0755); + mwexec("$script stop"); + mwexec_bg("$script start"); + } + #mount filesystem readonly + conf_mount_ro(); + +} + +?> diff --git a/config/asterisk/asterisk.xml b/config/asterisk/asterisk.xml new file mode 100644 index 00000000..b179b887 --- /dev/null +++ b/config/asterisk/asterisk.xml @@ -0,0 +1,103 @@ + + + + + + + + Asterisk status pacakge + Asterisk 1.8.x + Currently there are no FAQ items provided. + asterisk + 0.1 + asterisk + /usr/local/pkg/asterisk.inc + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/asterisk/asterisk.inc + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/asterisk/asterisk_calls.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/asterisk/asterisk_file_edit.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/asterisk/asterisk_log.php + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/asterisk/asterisk_cmd.php + + + asterisk + Asterisk +
status
+ asterisk_cmd.php +
+ + asterisk + asterisk + asterisk + + + + + + + + asterisk_install(); + + + asterisk_deinstall(); + + + + + + + + + sync_package_asterisk(); + +
\ No newline at end of file diff --git a/config/asterisk/asterisk_calls.php b/config/asterisk/asterisk_calls.php new file mode 100644 index 00000000..77131d8d --- /dev/null +++ b/config/asterisk/asterisk_calls.php @@ -0,0 +1,167 @@ +. + Copyright (C) 2012 robreg@zsurob.hu + All rights reserved. + + originally part of m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2005 Manuel Kasper . + Copyright (C) 2012 robreg@zsurob.hu + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* + pfSense_MODULE: asterisk +*/ + +##|+PRIV +##|*IDENT=page-status-asterisk +##|*NAME=Status: Asterisk Calls page +##|*DESCR=Allow access to the 'Status: Asterisk Calls' page. +##|*MATCH=status_asterisk_calls.php* +##|-PRIV + +require_once("guiconfig.inc"); + +$pgtitle = array(gettext("Status"),gettext("Asterisk Calls")); +include("head.inc"); + +/* Path to call log database */ +$callog = "/var/log/asterisk/cdr-csv/Master.csv"; + +/* Data input processing */ +$cmd = $_GET['cmd']; +//$cmd = str_replace("+", " ", $cmd); + +$file = $_SERVER["SCRIPT_NAME"]; +$break = Explode('/', $file); +$pfile = $break[count($break) - 1]; + +if (file_exists($callog)) + switch ($cmd){ + case "trim": + $trimres=shell_exec("tail -50 '$callog' > /tmp/trimmed.csv; rm '$callog'; mv /tmp/trimmed.csv '$callog'; chmod 666 '$callog'"); + break; + + case "clear": + $trimres=shell_exec("rm '$callog'; touch '$callog'; chmod 666 '$callog'"); + break; + + case "download": + // session_cache_limiter('none'); //*Use before session_start() + // session_start(); + + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename='.basename($callog)); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($callog)); + ob_clean(); + flush(); + readfile($callog); + exit; + break; + } +?> + + + + + + + + + + + +
+ +
+
+ /tmp/trimmed.csv; rm '$callog'; mv /tmp/trimmed.csv '$callog'"); + //print $trimres . "Last 50 calls:
"; + if (file_exists($callog)) + $file_handle = fopen($callog, "r"); + ?> + + + + + + + + + + + + + " . $out; + $out = "" . $out; + $out = "" . $out; + } + } + fclose($file_handle); + } + echo $out; + echo ""; + ?> +
Last 50 Asterisk calls
" . str_replace('"', '', $lin[4]) . "" . $lin[2] . "" . $lin[9] . "" . $lin[11] . "" . gmdate("G:i:s", $lin[12]) . "" . $lin[14] . "
"; + echo ""; + echo "
+
+
+ +

+ + + +
+
+
+
+ +
+ + + + diff --git a/config/asterisk/asterisk_cmd.php b/config/asterisk/asterisk_cmd.php new file mode 100644 index 00000000..504c3cd1 --- /dev/null +++ b/config/asterisk/asterisk_cmd.php @@ -0,0 +1,120 @@ +. + Copyright (C) 2012 robreg@zsurob.hu + All rights reserved. + + originally part of m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2005 Manuel Kasper . + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* + pfSense_MODULE: asterisk +*/ + +##|+PRIV +##|*IDENT=page-status-asterisk +##|*NAME=Status: Asterisk page +##|*DESCR=Allow access to the 'Status: Asterisk' page. +##|*MATCH=status_asterisk.php* +##|-PRIV + +require_once("guiconfig.inc"); + +$pgtitle = array(gettext("Status"),gettext("Asterisk")); +include("head.inc"); + +?> + + + + + + + + + + + + +
+ +
+
+ + + + + + + +
+ "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + ?> +
+ "; + echo $asterisk_command; + echo ""; + ?> +
+
+
+ \ No newline at end of file diff --git a/config/asterisk/asterisk_edit_file.php b/config/asterisk/asterisk_edit_file.php new file mode 100644 index 00000000..50d00279 --- /dev/null +++ b/config/asterisk/asterisk_edit_file.php @@ -0,0 +1,246 @@ + strlen($_REQUEST['data'])) { + echo "|" . gettext("Error while writing file") . ".|"; + } else { + echo "|" . gettext("File successfully saved") . ".|"; + } + } + exit; + } + exit; +} + +require("head.inc"); +outputJavaScriptFileInline("filebrowser/browser.js"); +outputJavaScriptFileInline("javascript/base64.js"); + +?> + + + + + + + + + + + + + +
+ +
+
+ + + + + + + + + +
+ + + + + + +
+ : + + + + +
+
+ + + + + + + + + +
+
+ +
+
+ +
+ + + +
+
+ + + + diff --git a/config/asterisk/asterisk_log.php b/config/asterisk/asterisk_log.php new file mode 100644 index 00000000..7d1328ed --- /dev/null +++ b/config/asterisk/asterisk_log.php @@ -0,0 +1,130 @@ +. + Copyright (C) 2012 robreg@zsurob.hu + Copyright (C) 2012 Marcello Coutinho + All rights reserved. + + originally part of m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2005 Manuel Kasper . + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* + pfSense_MODULE: asterisk +*/ + +##|+PRIV +##|*IDENT=page-status-asterisk +##|*NAME=Status: Asterisk Calls page +##|*DESCR=Allow access to the 'Status: Asterisk Log' page. +##|*MATCH=status_asterisk_log.php* +##|-PRIV + +require_once("guiconfig.inc"); + +$pgtitle = array(gettext("Status"),gettext("Asterisk Log")); +include("head.inc"); + +/* Path to Asterisk log file */ +if ($g['platform'] == "nanobsd") + $log = "/tmp/log_asterisk"; +else + $log = "/var/log/asterisk/messages"; + +?> + + /tmp/trimmed.csv; rm '$log'; mv /tmp/trimmed.csv '$log'; chmod 666 '$log'"); +} + +if ($cmd == "clear") { + $trimres=shell_exec("rm '$log'; touch '$log'; chmod 666 '$log'"); +} + +?> + + + + + + + + + + +
+ +
+
+ + + + + + + "; + ?> +
Last 50 Asterisk log entries
+ + +
"; + echo "
+
+
+ +

+ + + +
+
+ +
+ + + + diff --git a/pkg_config.8.xml b/pkg_config.8.xml index cd48e1c5..4dadf330 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -5,6 +5,23 @@ packagecopy@files.pfsense.org /usr/local/www/files/packages/8/All/ + + Asterisk + http://forum.pfsense.org/index.php/topic,47210.0.html + Asterisk turns an ordinary computer into a communications server.]]> + http://www.asterisk.org/ + Services + 1.8.8.1 pkg v 0.1 + Beta + 2.0 + http://www.pfsense.com/packages/config/asterisk/asterisk.xml + http://e-sac.siteseguro.ws/packages/8/All/ + asterisk18-1.8.8.1.tbz + openldap-sasl-client-2.4.26.tbz + marcellocoutinho@gmail.com robreg@zsurob.hu + asterisk.xml + Please visit the Asterisk tab on status menu. + Filer diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index d6770740..9ee66667 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -5,6 +5,23 @@ packagecopy@files.pfsense.org /usr/local/www/files/packages/amd64/8/All/ + + Asterisk + http://forum.pfsense.org/index.php/topic,47210.0.html + Asterisk turns an ordinary computer into a communications server.]]> + http://www.asterisk.org/ + Services + 1.8.8.1 pkg v 0.1 + Beta + 2.0 + http://www.pfsense.com/packages/config/asterisk/asterisk.xml + http://e-sac.siteseguro.ws/packages/amd64/8/All/ + asterisk18-1.8.8.1.tbz + openldap-sasl-client-2.4.26.tbz + marcellocoutinho@gmail.com robreg@zsurob.hu + asterisk.xml + Please visit the Asterisk tab on status menu. + Filer @@ -214,7 +231,7 @@ /usr/ports/net/haproxy - haproxy-legacy + haproxy-full http://doc.pfsense.org/index.php/haproxy_package This package implements both TCP and HTTP balance features from Haproxy.]]> -- cgit v1.2.3