aboutsummaryrefslogtreecommitdiffstats
path: root/config/asterisk
diff options
context:
space:
mode:
Diffstat (limited to 'config/asterisk')
-rw-r--r--config/asterisk/asterisk.inc1
-rw-r--r--config/asterisk/asterisk_calls.php14
-rw-r--r--config/asterisk/asterisk_cmd.php8
-rw-r--r--config/asterisk/asterisk_edit_file.php90
-rw-r--r--config/asterisk/asterisk_log.php31
5 files changed, 119 insertions, 25 deletions
diff --git a/config/asterisk/asterisk.inc b/config/asterisk/asterisk.inc
index e66227da..3ddb05c9 100644
--- a/config/asterisk/asterisk.inc
+++ b/config/asterisk/asterisk.inc
@@ -376,3 +376,4 @@ function sync_package_asterisk() {
}
?>
+
diff --git a/config/asterisk/asterisk_calls.php b/config/asterisk/asterisk_calls.php
index 7fd75274..6a4f973e 100644
--- a/config/asterisk/asterisk_calls.php
+++ b/config/asterisk/asterisk_calls.php
@@ -61,11 +61,13 @@ $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'");
+ $trimres=shell_exec("tail -50 '$callog' > /tmp/trimmed_asterisk.csv && rm '$callog' && mv /tmp/trimmed_asterisk.csv '$callog' && chown asterisk:asterisk '$callog' && chmod g+w '$callog'");
+ header( 'Location: asterisk_calls.php?savemsg=Calls+log+trimmed.') ;
break;
case "clear":
- $trimres=shell_exec("rm '$callog'; touch '$callog'; chmod 666 '$callog'");
+ $trimres=shell_exec("rm '$callog' && touch '$callog' && chown asterisk:asterisk '$callog' && chmod g+w '$callog'");
+ header( 'Location: asterisk_calls.php?savemsg=Calls+log+cleared.') ;
break;
case "download":
@@ -91,6 +93,12 @@ if (file_exists($callog))
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
+ <?php
+ $savemsg = $_GET["savemsg"];
+ if ($savemsg) {
+ print_info_box($savemsg);
+ }
+ ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
@@ -159,7 +167,7 @@ if (file_exists($callog))
<?
if ($g['platform'] == "nanobsd")
- echo "<br>This log is lost when rebooting the system.";
+ echo "<br>This log may be lost when rebooting the system.";
?>
diff --git a/config/asterisk/asterisk_cmd.php b/config/asterisk/asterisk_cmd.php
index 2278b982..d689a4c2 100644
--- a/config/asterisk/asterisk_cmd.php
+++ b/config/asterisk/asterisk_cmd.php
@@ -4,7 +4,7 @@
status_asterisk.php
part of pfSense
Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
- Copyright (C) 2012 robi <robreg@zsurob.hu>
+ Copyright (C) 2013 robi <robreg@zsurob.hu>
All rights reserved.
originally part of m0n0wall (http://m0n0.ch/wall)
@@ -96,14 +96,14 @@ $pfile = $break[count($break) - 1];
echo "<td align='center'><a href='$pfile?cmd=core+show+codecs+audio'><input type='button' name='command' value='Codecs' class='formbtns' style='width: 100px'></a></td>";
echo "<td align='center'><a href='$pfile?cmd=core+show+translation+recalc+10'><input type='button' name='command' value='Translation' class='formbtns' style='width: 100px'></a></td>";
echo "<td align='center'><a href='$pfile?cmd=sip+show+settings'><input type='button' name='command' value='SIP Settings' class='formbtns' style='width: 100px'></a></td>";
- echo "</tr></tr>";
- echo "<td></td>";
+ echo "</tr><tr>";
+ //echo "<td></td>";
echo "<td align='center'><a href='$pfile?cmd=sip+reload'><input type='button' name='command' value='Reload SIP' class='formbtns' style='width: 100px'></a></td>";
echo "<td align='center'><a href='$pfile?cmd=dialplan+reload'><input type='button' name='command' value='Reload Extensions' class='formbtns' style='width: 100px'></a></td>";
echo "<td align='center'><a href='$pfile?cmd=core+reload'><input type='button' name='command' value='Reload Core' class='formbtns' style='width: 100px'></a></td>";
echo "<td align='center'><a href='$pfile?cmd=core+show+uptime'><input type='button' name='command' value='Uptime' class='formbtns' style='width: 100px'></a></td>";
echo "<td align='center'><a href='$pfile?cmd=core+restart+now'><input type='button' name='command' value='Restart Asterisk' class='formbtns' style='width: 100px'></a></td>";
- echo "<td></td>";
+ echo "<td align='right' colspan='2'><form name='input' action='$pfile' method='get'><input type='text' name='cmd' style='width: 145px'><input type='submit' value='SEND' class='formbtns' style='width: 50px'></form> </td>";
?>
</tr></table>
</td>
diff --git a/config/asterisk/asterisk_edit_file.php b/config/asterisk/asterisk_edit_file.php
index 495703a2..648078f1 100644
--- a/config/asterisk/asterisk_edit_file.php
+++ b/config/asterisk/asterisk_edit_file.php
@@ -50,7 +50,8 @@ $downname = "asterisk-config-{$host}-".date("YmdHis").".bak.tgz"; //put the dat
if (($_GET['a'] == "download") && $_GET['t'] == "backup") {
conf_mount_rw();
- system("cd {$files_dir} && tar czf {$backup_path} *");
+// system("cd {$files_dir} && tar czf {$backup_path} *");
+ system("cd {$files_dir} && tar czf {$backup_path} --exclude 'dist/*' --exclude dist *");
conf_mount_ro();
}
@@ -75,10 +76,8 @@ if ($_GET['a'] == "other") {
if (file_exists($backup_path)) {
//echo "The file $filename exists";
conf_mount_rw();
- //$sysretval = system("tar -xzC {$files_dir} -f {$backup_path} 2>&1");
exec("tar -xzC {$files_dir} -f {$backup_path} 2>&1", $sysretval);
- $savemsg = "Backup has been restored " . $sysretval[1];
- //$savemsg = "Backup has been restored " . $sysretval;
+ $savemsg = "Backup has been restored, please restart Asterisk now " . $sysretval[1];
system("chmod -R 644 {$files_dir}/*");
header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ;
conf_mount_ro();
@@ -87,6 +86,30 @@ if ($_GET['a'] == "other") {
}
exit;
}
+ if ($_GET['t'] == "factrest") {
+ //extract files to $files_dir (/conf/asterisk)
+ if (file_exists('/conf.default/asterisk_factory_defaults_config.tgz')) {
+ //echo "The file $filename exists";
+ conf_mount_rw();
+ exec("tar -xzC {$files_dir} -f /conf.default/asterisk_factory_defaults_config.tgz 2>&1", $sysretval);
+ $savemsg = "Factory configuration restored, please restart Asterisk now " . $sysretval[1];
+ system("chmod -R 644 {$files_dir}/*");
+ header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ;
+ conf_mount_ro();
+ }
+ exit;
+ }
+ if ($_GET['t'] == "deldist") {
+ //delete dist directory from $files_dir/dist (/conf/asterisk/dist)
+ if (file_exists($files_dir . "/dist")) {
+ conf_mount_rw();
+ exec("rm -r {$files_dir}/dist 2>&1", $sysretval);
+ $savemsg = "Deleted dist files " . $sysretval[1];
+ header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ;
+ conf_mount_ro();
+ }
+ exit;
+ }
}
if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
@@ -222,6 +245,26 @@ if ($savemsg) {
}
);
}
+
+
+
+ function ckrest() {
+ if(document.getElementById('ckrest').checked==true) {
+ document.getElementById('restfactdef').disabled=false;
+ } else {
+ document.getElementById('restfactdef').disabled=true;
+ }
+ }
+
+ function ckdist() {
+ if(document.getElementById('ckdist').checked==true) {
+ document.getElementById('deldistdire').disabled=false;
+ } else {
+ document.getElementById('deldistdire').disabled=true;
+ }
+ }
+
+
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -244,11 +287,11 @@ if ($savemsg) {
<!-- backup options -->
<div style="background:#eeeeee;">
<div class="vexpl" style="padding-left:15px;">
-
+ <br />
<table width='98%' cellpadding='0' cellspacing='0' border='0'>
<tr>
- <td width='80%'><br />
- <b>Backup / Restore</b><br />
+ <td width='80%'>
+ <b>Backup / Restore</b>
The 'Backup' button will tar gzip asterisk configuration files to <? echo $backup_path; ?> it then offers it to download.<br>
The 'Restore' button will be visible only if the <? echo $backup_path; ?> backup file exists.<br>
You can upload a backup file to the system, if one already exists at <? echo $backup_path; ?>, it will be overwritten.
@@ -354,6 +397,27 @@ if ($savemsg) {
<?php endif; ?>
</script>
+
+ <div style="background:#eeeeee;">
+ <div class="vexpl" style="padding-left:15px;">
+ <table width='98%' cellpadding='0' cellspacing='0' border='0'>
+ <tr>
+ <td width='80%' valign='middle' align='right'><br />
+ <?php
+ if (file_exists($files_dir . "/dist")) {
+ echo "<input name='ckdist' id='ckdist' type='checkbox' onclick='return ckdist();' style='vertical-align:-3px;'>enable <input type='button' value='Delete dist files' name='deldistdire' id='deldistdire' disabled='disabled' onclick=\"document.location.href='asterisk_edit_file.php?a=other&t=deldist';\" />&nbsp;&nbsp;\n";
+ }
+ if (file_exists("/conf.default/asterisk_factory_defaults_config.tgz")) {
+ echo "<input name='ckrest' id='ckrest' type='checkbox' onclick='return ckrest();' style='vertical-align:-3px;'>enable <input type='button' value='Restore to factory defaults' name='restfactdef' id='restfactdef' disabled='disabled' onclick=\"document.location.href='asterisk_edit_file.php?a=other&t=factrest';\" />\n";
+ }
+ ?>
+ <br /></td>
+ </tr>
+ </table><br />
+ </div>
+ </div>
+
+
</div>
</td>
</tr>
@@ -367,6 +431,18 @@ if ($savemsg) {
</span>
<?=gettext("Please back up your Asterisk configuration regularly.");?><br>
<?=gettext("It's worth to preserve the automatically generated filename of the downloaded backup file. It contains the backup creation date, which is used when uploading it back to the system.");?>
+ <?php
+ $sipconf=$files_dir . "/sip.conf";
+ if (file_exists($sipconf)){
+ $sipconf_file=file_get_contents($sipconf);
+ if (strpos($sipconf_file,"demo extension for pfSense") !== false) {
+ ?><br />
+ <?=gettext("This Asterisk configuration on pfSense contains two demo SIP accounts, 301 and 302 with password 1234, for you to test functionality. Check sip.conf for more details. These accounts can be safely removed at any time.");?>
+ <?php
+ }
+ }
+ ?>
+
</span>
<?php include("fend.inc"); ?>
diff --git a/config/asterisk/asterisk_log.php b/config/asterisk/asterisk_log.php
index b8d454bd..42cf8e8b 100644
--- a/config/asterisk/asterisk_log.php
+++ b/config/asterisk/asterisk_log.php
@@ -50,10 +50,10 @@ $pgtitle = array(gettext("Status"),gettext("Asterisk Log"));
include("head.inc");
/* Path to Asterisk log file */
-if ($g['platform'] == "nanobsd")
- $log = "/tmp/asterisk.log";
-else
- $log = "/var/log/asterisk/messages";
+//if ($g['platform'] == "nanobsd")
+// $log = "/tmp/asterisk.log";
+//else
+$log = "/var/log/asterisk/messages";
?>
@@ -66,18 +66,27 @@ $file = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
-if ($cmd == "trim") {
- $trimres=shell_exec("tail -50 '$log' > /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'");
+if (file_exists($log) {
+ if ($cmd == "trim") {
+ $trimres=shell_exec("tail -50 '$log' > /tmp/trimmed_asterisk.log && rm '$log' && mv /tmp/trimmed_asterisk.log '$log' && chown asterisk:asterisk '$log' && chmod g+w '$log'");
+ header( 'Location: asterisk_log.php?savemsg=Log+trimmed.') ;
+ }
+ if ($cmd == "clear") {
+ $trimres=shell_exec("rm '$log' && touch '$log' && chown asterisk:asterisk '$log' && chmod g+w '$log'");
+ header( 'Location: asterisk_log.php?savemsg=Log+cleared.') ;
+ }
}
-
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
+ <?php
+ $savemsg = $_GET["savemsg"];
+ if ($savemsg) {
+ print_info_box($savemsg);
+ }
+ ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
@@ -125,7 +134,7 @@ if ($cmd == "clear") {
<?=gettext("Trim keeps the last 50 lines of the log.");?>
<?
if ($g['platform'] == "nanobsd")
- echo "<br>This log is lost when rebooting the system.";
+ echo "<br>This log may be lost when rebooting the system.";
?>