aboutsummaryrefslogtreecommitdiffstats
path: root/config/asterisk
diff options
context:
space:
mode:
Diffstat (limited to 'config/asterisk')
-rw-r--r--config/asterisk/asterisk.inc362
-rw-r--r--config/asterisk/asterisk.xml4
-rw-r--r--config/asterisk/asterisk_calls.php55
-rw-r--r--config/asterisk/asterisk_cmd.php33
-rw-r--r--config/asterisk/asterisk_edit_file.php220
-rw-r--r--config/asterisk/asterisk_log.php43
6 files changed, 643 insertions, 74 deletions
diff --git a/config/asterisk/asterisk.inc b/config/asterisk/asterisk.inc
index b2f93532..4f9baa53 100644
--- a/config/asterisk/asterisk.inc
+++ b/config/asterisk/asterisk.inc
@@ -4,6 +4,7 @@
asterisk.inc
part of pfSense (http://www.pfSense.com)
Copyright (C) 2012 Marcello Coutinho
+ Copyright (C) 2013 robi <robreg@zsurob.hu>
All rights reserved.
*/
/* ========================================================================== */
@@ -50,44 +51,375 @@ function sync_package_asterisk() {
#mount filesystem writeable
conf_mount_rw();
- #fix asterisk options for nanobsd
- if ($g['platform'] == "nanobsd"){
- $script='/usr/local/etc/asterisk/logger.conf';
+ //for NanoBSD compatibility, move the /etc/asterisk configuration directory to /conf, and symlink it back
+ if (file_exists("/usr/pbi/asterisk-i386/etc/asterisk/")) {
+ //this should occur only on i386 systems v2.1 and up
+ system("mv -f /usr/pbi/asterisk-i386/etc/asterisk/ /conf/asterisk/ && ln -s /conf/asterisk /usr/pbi/asterisk-i386/etc/asterisk");
+ }
+ if (file_exists("/usr/pbi/asterisk-amd64/etc/asterisk/")) {
+ //this should occur only on amd64 systems v2.1 and up
+ system("mv -f /usr/pbi/asterisk-amd64/etc/asterisk/ /conf/asterisk/ && ln -s /conf/asterisk /usr/pbi/asterisk-amd64/etc/asterisk");
+ }
+ if (file_exists("/conf/asterisk/")) {
+ if (file_exists("/usr/local/etc/asterisk/")) {
+ system("mv -f /usr/local/etc/asterisk /usr/local/etc/asterisk.bak");
+ }
+ system("ln -s /conf/asterisk /usr/local/etc/asterisk");
+ system("cd /conf/asterisk && mkdir dist && mv *-dist dist");
+ } else {
+ //should reach here only on non-pbi installs (2.0.x)
+ system("mv -f /usr/local/etc/asterisk/ /conf/asterisk/ && ln -s /conf/asterisk /usr/local/etc/asterisk");
+ }
+
+ //fix asterisk options for nanobsd: logging, db and calls log in /tmp
+// if ($g['platform'] == "nanobsd"){
+ $script='/conf/asterisk/logger.conf';
if (file_exists($script)){
$script_file=file_get_contents($script);
- $pattern[0]='/messages =/';
- $replace[0]='/tmp/log_asterisk =';
+ $pattern[0]=';rotatestrategy';
+ $replace[0]='rotatestrategy = rotate ;by pfSense ;';
$script_file=preg_replace($pattern,$replace,$script_file);
file_put_contents($script, $script_file, LOCK_EX);
}
- $script='/usr/local/etc/asterisk/asterisk.conf';
+ $script='/conf/asterisk/asterisk.conf';
if (file_exists($script)){
+ //point to the /var subdirs in the writable area in RAM
$script_file=file_get_contents($script);
- $pattern[0]='@astdbdir => [a-z,A-Z,/]+@';
- $replace[0]='astdbdir => /tmp';
- $pattern[1]='@astspooldir => [a-z,A-Z,/]+@';
- $replace[1]='astspooldir => /tmp';
+ $pattern[0]='[directories](!)';
+ $replace[0]='[directories]';
+ $pattern[1]='@astetcdir => [A-Z,a-z,0-9,_,-,/]+@';
+ $replace[1]='astetcdir => /conf/asterisk';
+ $pattern[2]='@astdbdir => [A-Z,a-z,0-9,_,-,/]+@';
+ $replace[2]='astdbdir => /var/db/asterisk';
+ $pattern[3]='@astspooldir => [A-Z,a-z,0-9,_,-,/]+@';
+ $replace[3]='astspooldir => /var/spool/asterisk';
+ $pattern[4]='@astrundir => [A-Z,a-z,0-9,_,-,/]+@';
+ $replace[4]='astrundir => /var/run/asterisk';
+ $pattern[5]='@astlogdir => [A-Z,a-z,0-9,_,-,/]+@';
+ $replace[5]='astlogdir => /var/log/asterisk';
$script_file=preg_replace($pattern,$replace,$script_file);
file_put_contents($script, $script_file, LOCK_EX);
}
-
- }
+// }
+
+ //add modules settings, for disabling those not required on pfSense
+ $script='/conf/asterisk/modules.conf';
+ if (file_exists($script)){
+ $script_file=file_get_contents($script);
+ if (strpos($script_file,'pfSense') === false) { //first check if already added...
+ $add_modules_settings = "\n";
+ $add_modules_settings .= ";The following modules settings work out of the box on pfSense (note: do not remove this comment line).\n";
+ $add_modules_settings .= ";Should you need any disabled module, check for its functionality individually in your environment.\n";
+ $add_modules_settings .= ";For more information check asterisk's online documentation.\n";
+ $add_modules_settings .= "noload => res_ael_share.so\n";
+ $add_modules_settings .= "noload => res_adsi.so\n";
+ $add_modules_settings .= ";noload => res_agi.so\n";
+ $add_modules_settings .= "noload => res_calendar.so\n";
+ $add_modules_settings .= "noload => res_crypto.so\n";
+ $add_modules_settings .= ";noload => res_fax.so\n";
+ $add_modules_settings .= "noload => res_jabber.so\n";
+ $add_modules_settings .= "noload => res_monitor.so\n";
+ $add_modules_settings .= ";noload => res_stun_monitor.so\n";
+ $add_modules_settings .= "noload => res_smdi.so\n";
+ $add_modules_settings .= "noload => res_speech.so\n";
+ $add_modules_settings .= "noload => res_odbc.so\n";
+ $add_modules_settings .= "noload => res_musiconhold.so\n";
+ $add_modules_settings .= "noload => app_celgenuserevent.so\n";
+ $add_modules_settings .= ";noload => app_confbridge.so\n";
+ $add_modules_settings .= ";noload => app_minivm.so\n";
+ $add_modules_settings .= ";noload => app_originate.so\n";
+ $add_modules_settings .= ";noload => app_playtones.so\n";
+ $add_modules_settings .= ";noload => app_readexten.so\n";
+ $add_modules_settings .= ";noload => app_waituntil.so\n";
+ $add_modules_settings .= ";noload => bridge_builtin_features.so\n";
+ $add_modules_settings .= ";noload => bridge_multiplexed.so\n";
+ $add_modules_settings .= ";noload => bridge_simple.so\n";
+ $add_modules_settings .= ";noload => bridge_softmix.so\n";
+ $add_modules_settings .= "noload => cdr_adaptive_odbc.so\n";
+ $add_modules_settings .= "noload => chan_jingle.so\n";
+ $add_modules_settings .= ";noload => chan_bridge.so\n";
+ $add_modules_settings .= "noload => chan_unistim.so\n";
+ $add_modules_settings .= ";noload => codec_g722.so\n";
+ $add_modules_settings .= ";noload => format_g719.so\n";
+ $add_modules_settings .= "noload => format_sln16.so\n";
+ $add_modules_settings .= "noload => format_siren14.so\n";
+ $add_modules_settings .= "noload => format_siren7.so\n";
+ $add_modules_settings .= ";noload => func_aes.so\n";
+ $add_modules_settings .= ";noload => func_audiohookinherit.so\n";
+ $add_modules_settings .= ";noload => func_blacklist.so\n";
+ $add_modules_settings .= ";noload => func_config.so\n";
+ $add_modules_settings .= ";noload => func_devstate.so\n";
+ $add_modules_settings .= ";noload => func_dialgroup.so\n";
+ $add_modules_settings .= ";noload => func_dialplan.so\n";
+ $add_modules_settings .= ";noload => func_extstate.so\n";
+ $add_modules_settings .= ";noload => func_iconv.so\n";
+ $add_modules_settings .= ";noload => func_lock.so\n";
+ $add_modules_settings .= ";noload => func_module.so\n";
+ $add_modules_settings .= ";noload => func_shell.so\n";
+ $add_modules_settings .= ";noload => func_speex.so\n";
+ $add_modules_settings .= ";noload => func_sprintf.so\n";
+ $add_modules_settings .= ";noload => func_sysinfo.so\n";
+ $add_modules_settings .= ";noload => func_version.so\n";
+ $add_modules_settings .= ";noload => res_curl.so\n";
+ $add_modules_settings .= "noload => func_vmcount.so\n";
+ $add_modules_settings .= "noload => func_volume.so\n";
+ $add_modules_settings .= "noload => res_clialiases.so\n";
+ $add_modules_settings .= "noload => res_config_curl.so\n";
+ $add_modules_settings .= "noload => res_config_ldap.so\n";
+ $add_modules_settings .= "noload => res_config_sqlite.so\n";
+ $add_modules_settings .= ";noload => res_limit.so\n";
+ $add_modules_settings .= ";noload => res_phoneprov.so\n";
+ $add_modules_settings .= "noload => res_realtime.so\n";
+ $add_modules_settings .= "noload => res_timing_pthread.so\n";
+ $add_modules_settings .= ";noload => app_adsiprog.so\n";
+ $add_modules_settings .= ";noload => app_alarmreceiver.so\n";
+ $add_modules_settings .= ";noload => app_amd.so\n";
+ $add_modules_settings .= ";noload => app_authenticate.so\n";
+ $add_modules_settings .= ";noload => app_cdr.so\n";
+ $add_modules_settings .= ";noload => app_chanisavail.so\n";
+ $add_modules_settings .= ";noload => app_channelredirect.so\n";
+ $add_modules_settings .= ";noload => app_chanspy.so\n";
+ $add_modules_settings .= ";noload => app_controlplayback.so\n";
+ $add_modules_settings .= "noload => app_db.so\n";
+ $add_modules_settings .= ";noload => app_dial.so\n";
+ $add_modules_settings .= ";noload => app_dictate.so\n";
+ $add_modules_settings .= ";noload => app_directed_pickup.so\n";
+ $add_modules_settings .= ";noload => app_directory.so\n";
+ $add_modules_settings .= ";noload => app_disa.so\n";
+ $add_modules_settings .= ";noload => app_dumpchan.so\n";
+ $add_modules_settings .= ";noload => app_echo.so\n";
+ $add_modules_settings .= ";noload => app_exec.so\n";
+ $add_modules_settings .= ";noload => app_externalivr.so\n";
+ $add_modules_settings .= ";noload => app_festival.so\n";
+ $add_modules_settings .= ";noload => app_followme.so\n";
+ $add_modules_settings .= ";noload => app_forkcdr.so\n";
+ $add_modules_settings .= ";noload => app_getcpeid.so\n";
+ $add_modules_settings .= ";noload => app_ices.so\n";
+ $add_modules_settings .= ";noload => app_image.so\n";
+ $add_modules_settings .= ";noload => app_macro.so\n";
+ $add_modules_settings .= ";noload => app_milliwatt.so\n";
+ $add_modules_settings .= ";noload => app_mixmonitor.so\n";
+ $add_modules_settings .= ";noload => app_mp3.so\n";
+ $add_modules_settings .= ";noload => app_morsecode.so\n";
+ $add_modules_settings .= ";noload => app_nbscat.so\n";
+ $add_modules_settings .= ";noload => app_parkandannounce.so\n";
+ $add_modules_settings .= ";noload => app_playback.so\n";
+ $add_modules_settings .= ";noload => app_privacy.so\n";
+ $add_modules_settings .= ";noload => app_queue.so\n";
+ $add_modules_settings .= ";noload => app_read.so\n";
+ $add_modules_settings .= ";noload => app_readfile.so\n";
+ $add_modules_settings .= ";noload => app_record.so\n";
+ $add_modules_settings .= ";noload => app_sayunixtime.so\n";
+ $add_modules_settings .= ";noload => app_senddtmf.so\n";
+ $add_modules_settings .= ";noload => app_sendtext.so\n";
+ $add_modules_settings .= ";noload => app_setcallerid.so\n";
+ $add_modules_settings .= ";noload => app_sms.so\n";
+ $add_modules_settings .= ";noload => app_softhangup.so\n";
+ $add_modules_settings .= "noload => app_speech_utils.so\n";
+ $add_modules_settings .= ";noload => app_stack.so\n";
+ $add_modules_settings .= ";noload => app_system.so\n";
+ $add_modules_settings .= ";noload => app_talkdetect.so\n";
+ $add_modules_settings .= ";noload => app_test.so\n";
+ $add_modules_settings .= ";noload => app_transfer.so\n";
+ $add_modules_settings .= ";noload => app_url.so\n";
+ $add_modules_settings .= ";noload => app_userevent.so\n";
+ $add_modules_settings .= ";noload => app_verbose.so\n";
+ $add_modules_settings .= ";noload => app_voicemail.so\n";
+ $add_modules_settings .= ";noload => app_waitforring.so\n";
+ $add_modules_settings .= ";noload => app_waitforsilence.so\n";
+ $add_modules_settings .= ";noload => app_while.so\n";
+ $add_modules_settings .= ";noload => app_zapateller.so\n";
+ $add_modules_settings .= ";noload => cdr_csv.so\n";
+ $add_modules_settings .= "noload => cdr_custom.so\n";
+ $add_modules_settings .= ";noload => cdr_manager.so\n";
+ $add_modules_settings .= "noload => cdr_pgsql.so\n";
+ $add_modules_settings .= "noload => cdr_radius.so\n";
+ $add_modules_settings .= "noload => cdr_sqlite.so\n";
+ $add_modules_settings .= "noload => cdr_sqlite3_custom.so\n";
+ $add_modules_settings .= "noload => cdr_syslog.so\n";
+ $add_modules_settings .= ";noload => cel_custom.so\n";
+ $add_modules_settings .= ";noload => cel_manager.so\n";
+ $add_modules_settings .= "noload => cel_odbc.so\n";
+ $add_modules_settings .= "noload => cel_pgsql.so\n";
+ $add_modules_settings .= "noload => cel_radius.so\n";
+ $add_modules_settings .= "noload => cel_sqlite3_custom.so\n";
+ $add_modules_settings .= "noload => cel_tds.so\n";
+ $add_modules_settings .= ";noload => chan_agent.so\n";
+ $add_modules_settings .= "noload => chan_dahdi.so\n";
+ $add_modules_settings .= "noload => chan_gtalk.so\n";
+ $add_modules_settings .= "noload => chan_iax2.so\n";
+ $add_modules_settings .= ";noload => chan_local.so\n";
+ $add_modules_settings .= "noload => chan_mgcp.so\n";
+ $add_modules_settings .= ";noload => chan_multicast_rtp.so\n";
+ $add_modules_settings .= "noload => chan_oss.so\n";
+ $add_modules_settings .= ";noload => chan_sip.so\n";
+ $add_modules_settings .= "noload => chan_skinny.so\n";
+ $add_modules_settings .= ";noload => codec_a_mu.so\n";
+ $add_modules_settings .= ";noload => codec_adpcm.so\n";
+ $add_modules_settings .= ";noload => codec_alaw.so\n";
+ $add_modules_settings .= "noload => codec_dahdi.so\n";
+ $add_modules_settings .= ";noload => codec_g726.so\n";
+ $add_modules_settings .= ";noload => codec_gsm.so\n";
+ $add_modules_settings .= ";noload => codec_lpc10.so\n";
+ $add_modules_settings .= ";noload => codec_speex.so\n";
+ $add_modules_settings .= ";noload => codec_ulaw.so\n";
+ $add_modules_settings .= ";noload => format_g723.so\n";
+ $add_modules_settings .= ";noload => format_g726.so\n";
+ $add_modules_settings .= ";noload => format_g729.so\n";
+ $add_modules_settings .= ";noload => format_gsm.so\n";
+ $add_modules_settings .= ";noload => format_h263.so\n";
+ $add_modules_settings .= ";noload => format_h264.so\n";
+ $add_modules_settings .= ";noload => format_ilbc.so\n";
+ $add_modules_settings .= "noload => format_jpeg.so\n";
+ $add_modules_settings .= ";noload => format_ogg_vorbis.so\n";
+ $add_modules_settings .= ";noload => format_pcm.so\n";
+ $add_modules_settings .= ";noload => format_sln.so\n";
+ $add_modules_settings .= ";noload => format_vox.so\n";
+ $add_modules_settings .= ";noload => format_wav.so\n";
+ $add_modules_settings .= ";noload => format_wav_gsm.so\n";
+ $add_modules_settings .= ";noload => func_base64.so\n";
+ $add_modules_settings .= ";noload => func_callcompletion.so\n";
+ $add_modules_settings .= ";noload => func_callerid.so\n";
+ $add_modules_settings .= ";noload => func_cdr.so\n";
+ $add_modules_settings .= ";noload => func_channel.so\n";
+ $add_modules_settings .= ";noload => func_curl.so\n";
+ $add_modules_settings .= ";noload => func_cut.so\n";
+ $add_modules_settings .= "noload => func_db.so\n";
+ $add_modules_settings .= ";noload => func_enum.so\n";
+ $add_modules_settings .= ";noload => func_env.so\n";
+ $add_modules_settings .= ";noload => func_frame_trace.so\n";
+ $add_modules_settings .= ";noload => func_global.so\n";
+ $add_modules_settings .= ";noload => func_groupcount.so\n";
+ $add_modules_settings .= ";noload => func_logic.so\n";
+ $add_modules_settings .= ";noload => func_math.so\n";
+ $add_modules_settings .= ";noload => func_md5.so\n";
+ $add_modules_settings .= "noload => func_odbc.so\n";
+ $add_modules_settings .= ";noload => func_pitchshift.so\n";
+ $add_modules_settings .= ";noload => func_rand.so\n";
+ $add_modules_settings .= ";noload => func_realtime.so\n";
+ $add_modules_settings .= ";noload => func_sha1.so\n";
+ $add_modules_settings .= ";noload => func_srv.so\n";
+ $add_modules_settings .= ";noload => func_strings.so\n";
+ $add_modules_settings .= ";noload => func_timeout.so\n";
+ $add_modules_settings .= ";noload => func_uri.so\n";
+ $add_modules_settings .= "noload => pbx_ael.so\n";
+ $add_modules_settings .= ";noload => pbx_config.so\n";
+ $add_modules_settings .= "noload => pbx_dundi.so\n";
+ $add_modules_settings .= ";noload => pbx_loopback.so\n";
+ $add_modules_settings .= ";noload => pbx_realtime.so\n";
+ $add_modules_settings .= ";noload => pbx_spool.so\n";
+ $add_modules_settings .= ";noload => res_clioriginate.so\n";
+ $add_modules_settings .= "noload => res_config_pgsql.so\n";
+ $add_modules_settings .= ";noload => res_convert.so\n";
+ $add_modules_settings .= ";noload => res_mutestream.so\n";
+ $add_modules_settings .= ";noload => res_rtp_asterisk.so\n";
+ $add_modules_settings .= ";noload => res_rtp_multicast.so\n";
+ $add_modules_settings .= ";noload => res_security_log.so\n";
+ $add_modules_settings .= ";noload => res_snmp.so\n";
+ $add_modules_settings .= "noload => cdr_odbc.so\n";
+ $add_modules_settings .= "noload => cdr_tds.so\n";
+ $add_modules_settings .= "noload => chan_h323.so\n";
+ $add_modules_settings .= "noload => res_config_odbc.so\n";
+ $script_file .= $add_modules_settings;
+ file_put_contents($script, $script_file, LOCK_EX);
+ }
+ }
+
+ //replace general SIP settings as a newbie hint to start configuration
+ $script='/conf/asterisk/sip.conf';
+ if (file_exists($script)){
+ $script_file=file_get_contents($script);
+ //strenghten a couple of security settings, and predefine codecs in the default SIP configuration
+ if (strpos($script_file,'pfSense') === false) { //first check if already added...
+ $pattern[0]=';allowguest';
+ $replace[0]='allowguest=no ;by pfSense ;';
+ $pattern[1]=';alwaysauthreject';
+ $replace[1]='alwaysauthreject=yes ;by pfSense ;';
+ $pattern[2]='; jbenable';
+ $replace[2]='jbenable=yes ;by pfSense ;';
+ $pattern[3]='[general]';
+ $replace[3]='[general]\n;The following general settings usually work on pfSense boxes (note: please do not remove this comment line).\ndisallow=all ;by pfSense\nallow=g729\nallow=ulaw\nallow=alaw\n\n';
+ $script_file=preg_replace($pattern,$replace,$script_file);
+ file_put_contents($script, $script_file, LOCK_EX);
+ }
+ if (strpos($script_file,'demo extension for pfSense') === false) { //first check if already added...
+ $add_demo_extension = "\n\n";
+ $add_demo_extension .= "[301]\n";
+ $add_demo_extension .= ";demo extension for pfSense\n";
+ $add_demo_extension .= "type=friend\n";
+ $add_demo_extension .= "defaultuser=301\n";
+ $add_demo_extension .= "insecure=port,invite\n";
+ $add_demo_extension .= "secret=1234\n";
+ $add_demo_extension .= "regexten=301\n";
+ $add_demo_extension .= "host=dynamic\n";
+ $add_demo_extension .= "context=default\n\n";
+ $add_demo_extension .= "[302]\n";
+ $add_demo_extension .= ";demo extension for pfSense\n";
+ $add_demo_extension .= "type=friend\n";
+ $add_demo_extension .= "defaultuser=302\n";
+ $add_demo_extension .= "insecure=port,invite\n";
+ $add_demo_extension .= "secret=1234\n";
+ $add_demo_extension .= "regexten=302\n";
+ $add_demo_extension .= "host=dynamic\n";
+ $add_demo_extension .= "context=default\n\n";
+ $script_file .= $add_demo_extension;
+ 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);
+ $script_file=preg_replace("$command -nqrx 'core stop now'","#$command -nqrx 'core stop now'\n killall $name",$script_file);
+ }
+ //create the /var subdirs for the writable area in RAM
+ if (strpos($script_file,'pfSense') === false) { //first check if already added...
+ $writable_area = "\n\n# Create paths in pfSense's volatile area if they don't exist (note: please do not remove this comment line)\n";
+ $writable_area .= "if [ ! -d /var/db/asterisk ]; then\n";
+ $writable_area .= " mkdir -p /var/db/asterisk\n";
+ $writable_area .= " chown -R asterisk:asterisk /var/db/asterisk\n";
+ $writable_area .= " chmod -R g+w /var/db/asterisk\n";
+ $writable_area .= "fi\n\n";
+ $writable_area .= "if [ ! -d /var/spool/asterisk ]; then\n";
+ $writable_area .= " mkdir -p /var/spool/asterisk\n";
+ $writable_area .= " chown -R asterisk:asterisk /var/spool/asterisk\n";
+ $writable_area .= " chmod -R g+w /var/spool/asterisk\n";
+ $writable_area .= "fi\n\n";
+ $writable_area .= "if [ ! -d /var/run/asterisk ]; then\n";
+ $writable_area .= " mkdir -p /var/run/asterisk\n";
+ $writable_area .= " chown -R asterisk:asterisk /var/run/asterisk\n";
+ $writable_area .= " chmod -R g+w /var/run/asterisk\n";
+ $writable_area .= "fi\n\n";
+ $writable_area .= "if [ ! -d /var/log/asterisk ]; then\n";
+ $writable_area .= " mkdir -p /var/log/asterisk\n";
+ $writable_area .= " chown -R asterisk:asterisk /var/log/asterisk\n";
+ $writable_area .= " chmod -R g+w /var/log/asterisk\n";
+ $writable_area .= "fi\n\n";
+ $writable_area .= "if [ ! -d /var/log/asterisk/cdr-csv ]; then\n";
+ $writable_area .= " mkdir -p /var/log/asterisk/cdr-csv\n";
+ $writable_area .= " chown -R asterisk:asterisk /var/log/asterisk/cdr-csv\n";
+ $writable_area .= " chmod -R g+w /var/log/asterisk/cdr-csv\n";
+ $writable_area .= "fi\n\n";
+ $script_file .= $writable_area;
}
+ file_put_contents($script, $script_file, LOCK_EX);
+
chmod ($script,0755);
mwexec("$script stop");
mwexec_bg("$script start");
}
- #mount filesystem readonly
- conf_mount_ro();
+ //prepare backup for factory defaults restoring feature
+ if (!file_exists("/conf.default/asterisk_factory_defaults_config.tgz")) {
+ system("cd /conf/asterisk/ && tar czf /conf.default/asterisk_factory_defaults_config.tgz *");
+ }
+
+ //mount filesystem readonly
+ conf_mount_ro();
}
?>
diff --git a/config/asterisk/asterisk.xml b/config/asterisk/asterisk.xml
index a0ce4833..91e25562 100644
--- a/config/asterisk/asterisk.xml
+++ b/config/asterisk/asterisk.xml
@@ -41,7 +41,7 @@
<requirements>Asterisk 1.8.x</requirements>
<faq>Currently there are no FAQ items provided.</faq>
<name>asterisk</name>
- <version>0.1</version>
+ <version>0.3</version>
<title>asterisk</title>
<include_file>/usr/local/pkg/asterisk.inc</include_file>
<additional_files_needed>
@@ -100,4 +100,4 @@
<custom_php_resync_config_command>
sync_package_asterisk();
</custom_php_resync_config_command>
-</packagegui> \ No newline at end of file
+</packagegui>
diff --git a/config/asterisk/asterisk_calls.php b/config/asterisk/asterisk_calls.php
index 77131d8d..6a4f973e 100644
--- a/config/asterisk/asterisk_calls.php
+++ b/config/asterisk/asterisk_calls.php
@@ -4,12 +4,11 @@
status_asterisk_calls.php
part of pfSense
Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
- Copyright (C) 2012 robreg@zsurob.hu
+ Copyright (C) 2013 robi <robreg@zsurob.hu>
All rights reserved.
originally part of m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
- Copyright (C) 2012 robreg@zsurob.hu
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -41,7 +40,7 @@
##|*IDENT=page-status-asterisk
##|*NAME=Status: Asterisk Calls page
##|*DESCR=Allow access to the 'Status: Asterisk Calls' page.
-##|*MATCH=status_asterisk_calls.php*
+##|*MATCH=asterisk_calls.php*
##|-PRIV
require_once("guiconfig.inc");
@@ -54,7 +53,6 @@ $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);
@@ -63,17 +61,19 @@ $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":
// 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));
@@ -93,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>
@@ -110,23 +116,21 @@ if (file_exists($callog))
<td>
<div id="mainarea">
<?php
- //$trimres=shell_exec("tail -50 '$callog' > /tmp/trimmed.csv; rm '$callog'; mv /tmp/trimmed.csv '$callog'");
- //print $trimres . "Last 50 calls: <br>";
if (file_exists($callog))
$file_handle = fopen($callog, "r");
?>
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td colspan="6" class="listtopic">Last 50 Asterisk calls</td>
- </tr>
- <tr>
- <td nowrap class="listhdrr"><?=gettext("From");?></td>
- <td nowrap class="listhdrr"><?=gettext("To");?></a></td>
- <td nowrap class="listhdrr"><?=gettext("Start");?></td>
- <td nowrap class="listhdrr"><?=gettext("End");?></a></td>
- <td nowrap class="listhdrr"><?=gettext("Duration");?></a></td>
- <td nowrap class="listhdrr"><?=gettext("Status");?></td>
- </tr>
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td colspan="6" class="listtopic">Last 50 Asterisk calls</td>
+ </tr>
+ <tr>
+ <td nowrap class="listhdrr"><?=gettext("From");?></td>
+ <td nowrap class="listhdrr"><?=gettext("To");?></a></td>
+ <td nowrap class="listhdrr"><?=gettext("Start");?></td>
+ <td nowrap class="listhdrr"><?=gettext("End");?></a></td>
+ <td nowrap class="listhdrr"><?=gettext("Duration");?></a></td>
+ <td nowrap class="listhdrr"><?=gettext("Status");?></td>
+ </tr>
<?php
$out = '';
if (file_exists($callog)){
@@ -134,7 +138,7 @@ if (file_exists($callog))
$lin = fgetcsv($file_handle, 102400);
if ($lin[12] != "") {
$out = "<tr>" . $out;
- $out = "<td class='listlr'>" . str_replace('"', '', $lin[4]) . "</td><td class='listlr'>" . $lin[2] . "</td><td class='listlr'>" . $lin[9] . "</td><td class='listlr'>" . $lin[11] . "</td><td class='listlr'>" . gmdate("G:i:s", $lin[12]) . "</td><td class='listlr'>" . $lin[14] . "</td>" . $out;
+ $out = "<td class='listlr'>" . utf8_decode(str_replace('"', '', $lin[4])) . "</td><td class='listlr'>" . $lin[2] . "</td><td class='listlr'>" . $lin[9] . "</td><td class='listlr'>" . $lin[11] . "</td><td class='listlr'>" . gmdate("G:i:s", $lin[12]) . "</td><td class='listlr'>" . $lin[14] . "</td>" . $out;
$out = "</tr>" . $out;
}
}
@@ -160,6 +164,13 @@ if (file_exists($callog))
<?=gettext("Listed in reverse order (latest on top).");?> <br>
<?=gettext("Duration includes ringing time.");?> <br>
<?=gettext("Trim keeps the last 50 entries.");?>
+
+<?
+if ($g['platform'] == "nanobsd")
+ echo "<br>This log may be lost when rebooting the system.";
+?>
+
+
</span>
diff --git a/config/asterisk/asterisk_cmd.php b/config/asterisk/asterisk_cmd.php
index 504c3cd1..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 robreg@zsurob.hu
+ Copyright (C) 2013 robi <robreg@zsurob.hu>
All rights reserved.
originally part of m0n0wall (http://m0n0.ch/wall)
@@ -40,7 +40,7 @@
##|*IDENT=page-status-asterisk
##|*NAME=Status: Asterisk page
##|*DESCR=Allow access to the 'Status: Asterisk' page.
-##|*MATCH=status_asterisk.php*
+##|*MATCH=sasterisk_cmd.php*
##|-PRIV
require_once("guiconfig.inc");
@@ -86,19 +86,26 @@ $pfile = $break[count($break) - 1];
<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td class="listtopic">
+ <table><tr>
<?php
/* Print command buttons */
- echo "<a href='$pfile?cmd=sip+show+registry'><input type='button' name='command' value='SIP Registry' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=sip+show+peers'><input type='button' name='command' value='SIP Peers' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=sip+show+channels'><input type='button' name='command' value='SIP Channels' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=core+show+channels'><input type='button' name='command' value='Channels' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=core+show+codecs+audio'><input type='button' name='command' value='Codecs' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=core+show+translation+recalc+10'><input type='button' name='command' value='Translation' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=sip+show+settings'><input type='button' name='command' value='SIP Settings' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=sip+reload'><input type='button' name='command' value='!Reload SIP' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=core+reload'><input type='button' name='command' value='!Reload Core' class='formbtns'></a>";
- echo "<a href='$pfile?cmd=core+show+uptime'><input type='button' name='command' value='Uptime' class='formbtns'></a>";
+ echo "<td align='center'><a href='$pfile?cmd=sip+show+registry'><input type='button' name='command' value='SIP Registry' class='formbtns' style='width: 100px'></a></td>";
+ echo "<td align='center'><a href='$pfile?cmd=sip+show+peers'><input type='button' name='command' value='SIP Peers' class='formbtns' style='width: 100px'></a></td>";
+ echo "<td align='center'><a href='$pfile?cmd=sip+show+channels'><input type='button' name='command' value='SIP Channels' class='formbtns' style='width: 100px'></a></td>";
+ echo "<td align='center'><a href='$pfile?cmd=core+show+channels'><input type='button' name='command' value='Channels' class='formbtns' style='width: 100px'></a></td>";
+ 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 "<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 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>
</tr>
<tr valign="top">
@@ -117,4 +124,4 @@ $pfile = $break[count($break) - 1];
</td>
</tr>
</table>
-<?php include("fend.inc"); ?> \ No newline at end of file
+<?php include("fend.inc"); ?>
diff --git a/config/asterisk/asterisk_edit_file.php b/config/asterisk/asterisk_edit_file.php
index 50d00279..648078f1 100644
--- a/config/asterisk/asterisk_edit_file.php
+++ b/config/asterisk/asterisk_edit_file.php
@@ -2,7 +2,7 @@
/*
edit.php
Copyright (C) 2004, 2005 Scott Ullrich
- Copyright (C) 2012 robreg@zsurob.hu
+ Copyright (C) 2013 robi <robreg@zsurob.hu>
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,12 +34,99 @@
##|*IDENT=page-status-asterisk
##|*NAME=Status: Asterisk config editor page
##|*DESCR=Allow access to the 'Status: Asterisk configuration files' page.
-##|*MATCH=status_asterisk_edit.php*
+##|*MATCH=asterisk_edit_file.php*
##|-PRIV
$pgtitle = array(gettext("Status"),gettext("Asterisk configuration files"));
require("guiconfig.inc");
+
+$backup_dir = "/conf";
+$backup_filename = "asterisk_config.bak.tgz";
+$backup_path = "{$backup_dir}/{$backup_filename}";
+$files_dir = "/conf/asterisk";
+$host = "{$config['system']['hostname']}.{$config['system']['domain']}";
+$downname = "asterisk-config-{$host}-".date("YmdHis").".bak.tgz"; //put the date in the filename
+
+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} --exclude 'dist/*' --exclude dist *");
+ conf_mount_ro();
+}
+
+if (($_GET['a'] == "download") && file_exists("{$backup_path}")) {
+ session_cache_limiter('public');
+ $fd = fopen("{$backup_path}", "rb");
+ header("Content-Type: application/force-download");
+ header("Content-Type: application/octet-stream");
+ header("Content-Type: application/download");
+ header("Content-Description: File Transfer");
+ header("Content-Disposition: attachment; filename=\"{$downname}\"");
+ header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
+ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
+ header("Content-Length: " . filesize("{$backup_path}"));
+ fpassthru($fd);
+ exit;
+}
+
+if ($_GET['a'] == "other") {
+ if ($_GET['t'] == "restore") {
+ //extract files to $files_dir (/conf/asterisk)
+ if (file_exists($backup_path)) {
+ //echo "The file $filename exists";
+ conf_mount_rw();
+ exec("tar -xzC {$files_dir} -f {$backup_path} 2>&1", $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();
+ } else {
+ header( 'Location: asterisk_edit_file.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ;
+ }
+ 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'])) {
+ $upfilnam = $_FILES['ulfile']['name'];
+ $upfiltim = strtotime(str_replace(".bak.tgz","",end(explode("-",$upfilnam))));
+ conf_mount_rw();
+ move_uploaded_file($_FILES['ulfile']['tmp_name'], "{$backup_path}");
+ $savemsg = "Uploaded ". htmlentities($_FILES['ulfile']['name']) . " file as " . $backup_path . "." ;
+ system('chmod -R 644 {$backup_path}');
+ if ($upfiltim) { //take the date from the filename and update modified time accordingly
+ touch($backup_path, $upfiltim);
+ }
+ unset($_POST['txtCommand']);
+ conf_mount_ro();
+ header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ;
+}
+
if($_REQUEST['action']) {
switch($_REQUEST['action']) {
case 'load':
@@ -93,6 +180,13 @@ outputJavaScriptFileInline("javascript/base64.js");
<body link="#000000" vlink="#000000" alink="#000000">
<?php include("fbegin.inc"); ?>
+<?php
+$savemsg = $_GET["savemsg"];
+if ($savemsg) {
+ print_info_box($savemsg);
+}
+?>
+
<script type="text/javascript">
function loadFile() {
$("fileStatus").innerHTML = "<?=gettext("Loading file"); ?> ...";
@@ -151,6 +245,26 @@ outputJavaScriptFileInline("javascript/base64.js");
}
);
}
+
+
+
+ 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">
@@ -170,13 +284,50 @@ outputJavaScriptFileInline("javascript/base64.js");
<td>
<div id="mainarea">
- <!-- file status box -->
- <div style="display:none; background:#eeeeee;" id="fileStatusBox">
+ <!-- backup options -->
+ <div style="background:#eeeeee;">
<div class="vexpl" style="padding-left:15px;">
- <strong id="fileStatus"></strong>
+ <br />
+ <table width='98%' cellpadding='0' cellspacing='0' border='0'>
+ <tr>
+ <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.
+ <br />
+ </td>
+ <td width='20%' valign='middle' align='right'>
+ <?php
+ echo " <input type='button' value='Backup' onclick=\"document.location.href='asterisk_edit_file.php?a=download&t=backup';\" />\n";
+ if (file_exists($backup_path)) {
+ echo " <input type='button' value='Restore' onclick=\"document.location.href='asterisk_edit_file.php?a=other&t=restore';\" />\n";
+ }
+ ?>
+ </td>
+ </tr></table><br>
+ <table width='98%' cellpadding='0' cellspacing='0' border='0'>
+ <tr>
+ <td width='20%' valign='middle' align='left'>
+ <?php
+ if (file_exists($backup_path)) {
+ echo $backup_filename . " date:<br>" . date ("Y F d H:i:s.", filemtime($backup_path));
+ }
+ ?>
+ </td>
+ <td width='80%' valign='middle' align='right'>
+ <form action="asterisk_edit_file.php" method="POST" enctype="multipart/form-data" name="frmUpload" onSubmit="">
+ Upload backup file:
+ <input name="ulfile" type="file" class="button" id="ulfile">
+ <input name="submit" type="submit" class="button" id="upload" value="Upload">
+ </form>
+ </td>
+ </tr>
+ </table><br />
</div>
</div>
-
+
+
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
@@ -186,8 +337,8 @@ outputJavaScriptFileInline("javascript/base64.js");
<table width="100%" cellpadding="9" cellspacing="9">
<tr>
<td align="center" class="list">
- <?=gettext("Save / Load from path"); ?>:
- <input type="text" class="formfld file" id="fbTarget" value="<?=gettext('/usr/local/etc/asterisk');?>" size="45" />
+ <?=gettext("Configuration files stored in"); ?>:
+ <input type="text" class="formfld file" id="fbTarget" value="<?=gettext($files_dir);?>" size="45" />
<input type="button" class="formbtn" id="fbOpen" value="<?=gettext('Browse');?>" />
<!-- <input type="button" class="formbtn" onclick="loadFile();" value="<?=gettext('Load');?>" /> -->
<input type="button" class="formbtn" onclick="saveFile();" value="<?=gettext('Save');?>" />
@@ -196,6 +347,16 @@ outputJavaScriptFileInline("javascript/base64.js");
</tr>
</table>
+
+
+ <!-- file status box -->
+ <div style="display:none; background:#eeeeee;" id="fileStatusBox">
+ <div class="vexpl" style="padding-left:15px;">
+ <strong id="fileStatus"></strong>
+ </div>
+ </div>
+
+
<!-- filebrowser -->
<div id="fbBrowser" style="display:none; border:1px dashed gray; width:98%;"></div>
@@ -236,11 +397,54 @@ outputJavaScriptFileInline("javascript/base64.js");
<?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>
</table>
+<p/>
+
+<span class="vexpl">
+ <span class="red">
+ <strong><?=gettext("Note:");?><br /></strong>
+ </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"); ?>
</body>
</html>
diff --git a/config/asterisk/asterisk_log.php b/config/asterisk/asterisk_log.php
index 7d1328ed..8ff8475d 100644
--- a/config/asterisk/asterisk_log.php
+++ b/config/asterisk/asterisk_log.php
@@ -4,7 +4,7 @@
status_asterisk_log.php
part of pfSense
Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
- Copyright (C) 2012 robreg@zsurob.hu
+ Copyright (C) 2012 robi <robreg@zsurob.hu>
Copyright (C) 2012 Marcello Coutinho
All rights reserved.
@@ -41,7 +41,7 @@
##|*IDENT=page-status-asterisk
##|*NAME=Status: Asterisk Calls page
##|*DESCR=Allow access to the 'Status: Asterisk Log' page.
-##|*MATCH=status_asterisk_log.php*
+##|*MATCH=asterisk_log.php*
##|-PRIV
require_once("guiconfig.inc");
@@ -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/log_asterisk";
-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>
@@ -98,9 +107,9 @@ if ($cmd == "clear") {
<tr>
<td colspan="2" class="listtopic">Last 50 Asterisk log entries</td>
</tr>
-
+
<tr valign="top"><td class="listlr" nowrap>
-
+
<?php
$showlog_command=shell_exec("tail -50 '$log'");
echo nl2br($showlog_command);
@@ -123,6 +132,12 @@ if ($cmd == "clear") {
<strong><?=gettext("Note:");?><br /></strong>
</span>
<?=gettext("Trim keeps the last 50 lines of the log.");?>
+<?
+if ($g['platform'] == "nanobsd")
+ echo "<br>This log may be lost when rebooting the system.";
+?>
+
+
</span>
<?php include("fend.inc"); ?>