Added new AST_CRON_audio... scripts to handle mixing/compressing/ftping of audio recordings
git-svn-id: svn://192.168.202.10@787 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -37,10 +37,19 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom
|
||||
still be recorded as a DROP in it's original in-group or campaign, but
|
||||
the lead information will move on to the drop in-group.
|
||||
|
||||
7. The 8 outbound agi-VDADtransfer scripts are in process of being consolidated
|
||||
7. Audio recording mixing/compression/ftping scripts have been completely
|
||||
rewritten and separated into different scripts for better fault
|
||||
tolerance. Also, you have the option of compression in to the following
|
||||
formats: WAV, GSM, MP3 and OGG
|
||||
- AST_CRON_audio_1_move_mix.pl
|
||||
- AST_CRON_audio_1_move_VDonly.pl
|
||||
- AST_CRON_audio_2_compress.pl
|
||||
- AST_CRON_audio_3_ftp.pl
|
||||
|
||||
8. The 8 outbound agi-VDADtransfer scripts are in process of being consolidated
|
||||
into a single AGI script: agi-VDAD_ALL_outbound.agi
|
||||
|
||||
8. The start of a new QC (Quality Control) feature [non functional right now]
|
||||
9. The start of a new QC (Quality Control) feature [non functional right now]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_CRON_audio_1_move_VDonly.pl
|
||||
#
|
||||
# This is a STEP-1 program in the audio archival process
|
||||
#
|
||||
# IMPORTANT!!! ONLY TO BE USED WHEN ONLY VICIDIAL RECORDINGS ARE ON THE SYSTEM!
|
||||
#
|
||||
# runs every 3 minutes and copies the -in recordings in the monitor to the DONE
|
||||
# directory for further processing. Very important for RAM-drive usage
|
||||
#
|
||||
# put an entry into the cron of of your asterisk machine to run this script
|
||||
# every 3 minutes or however often you desire
|
||||
#
|
||||
# ### recording mixing/compressing/ftping scripts
|
||||
##0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
|
||||
# 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
|
||||
# 1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
|
||||
# 2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
|
||||
#
|
||||
# make sure that the following directories exist:
|
||||
# /var/spool/asterisk/monitor # default Asterisk recording directory
|
||||
# /var/spool/asterisk/monitorDONE # where the moved -in files are put
|
||||
#
|
||||
# This program assumes that recordings are saved by Asterisk as .wav
|
||||
# should be easy to change this code if you use .gsm instead
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 80302-1958 - First Build
|
||||
#
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n----- DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING -----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#print "no command line options set\n";
|
||||
}
|
||||
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||
@conf = <conf>;
|
||||
close(conf);
|
||||
$i=0;
|
||||
foreach(@conf)
|
||||
{
|
||||
$line = $conf[$i];
|
||||
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
||||
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
||||
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
||||
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
||||
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
||||
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
||||
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
|
||||
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) )
|
||||
{$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
||||
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
||||
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
||||
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
||||
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
||||
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
||||
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) )
|
||||
{$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) )
|
||||
{$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) )
|
||||
{$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) )
|
||||
{$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) )
|
||||
{$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) )
|
||||
{$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;}
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = $VARserver_ip; # Asterisk server IP
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
|
||||
use DBI;
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
|
||||
### directory where in/out recordings are saved to by Asterisk
|
||||
$dir1 = "$PATHmonitor";
|
||||
$dir2 = "$PATHDONEmonitor";
|
||||
|
||||
opendir(FILE, "$dir1/");
|
||||
@FILES = readdir(FILE);
|
||||
|
||||
$i=0;
|
||||
foreach(@FILES)
|
||||
{
|
||||
$size1 = 0;
|
||||
$size2 = 0;
|
||||
|
||||
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
|
||||
{
|
||||
|
||||
$size1 = (-s "$dir1/$FILES[$i]");
|
||||
if ($DBX) {print "$FILES[$i] $size1\n";}
|
||||
sleep(1);
|
||||
$size2 = (-s "$dir1/$FILES[$i]");
|
||||
if ($DBX) {print "$FILES[$i] $size2\n\n";}
|
||||
|
||||
if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
|
||||
{
|
||||
$INfile = $FILES[$i];
|
||||
$OUTfile = $FILES[$i];
|
||||
$OUTfile =~ s/-in\.wav/-out.wav/gi;
|
||||
$OUTfile =~ s/-in\.gsm/-out.gsm/gi;
|
||||
$ALLfile = $FILES[$i];
|
||||
$ALLfile =~ s/-in\.wav/-all.wav/gi;
|
||||
$ALLfile =~ s/-in\.gsm/-all.gsm/gi;
|
||||
$SQLFILE = $FILES[$i];
|
||||
$SQLFILE =~ s/-in\.wav|-in\.gsm//gi;
|
||||
|
||||
$stmtA = "select recording_id from recording_log where filename='$SQLFILE' order by recording_id desc LIMIT 1;";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
if ($sthArows > 0)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$recording_id = "$aryA[0]";
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
if ($DB) {print "|$recording_id|$INfile| |$ALLfile|\n";}
|
||||
|
||||
if (!$T)
|
||||
{
|
||||
`mv -f "$dir1/$INfile" "$dir2/$ALLfile"`;
|
||||
`rm -f "$dir1/$OUTfile"`;
|
||||
}
|
||||
else
|
||||
{
|
||||
`cp -f "$dir1/$INfile" "$dir2/$ALLfile"`;
|
||||
}
|
||||
|
||||
$stmtA = "UPDATE recording_log set location='http://$server_ip/RECORDINGS/$ALLfile' where recording_id='$recording_id';";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
|
||||
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($DB) {print "DONE... EXITING\n\n";}
|
||||
|
||||
$dbhA->disconnect();
|
||||
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,226 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_CRON_audio_1_move_mix.pl
|
||||
#
|
||||
# This is a STEP-1 program in the audio archival process
|
||||
#
|
||||
# runs every 3 minutes and copies and mixes the -in and -out recordings in the
|
||||
# monitor to the DONE directory for further processing. Very important for
|
||||
# RAM-drive usage
|
||||
#
|
||||
# put an entry into the cron of of your asterisk machine to run this script
|
||||
# every 3 minutes or however often you desire
|
||||
#
|
||||
# ### recording mixing/compressing/ftping scripts
|
||||
# 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
|
||||
##0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
|
||||
# 1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
|
||||
# 2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
|
||||
#
|
||||
# make sure that the following directories exist:
|
||||
# /var/spool/asterisk/monitor # default Asterisk recording directory
|
||||
# /var/spool/asterisk/monitorDONE # where the mixed -all files are put
|
||||
#
|
||||
# This program assumes that recordings are saved by Asterisk as .wav
|
||||
# should be easy to change this code if you use .gsm instead
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 80302-1958 - First Build
|
||||
#
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n----- DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING -----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#print "no command line options set\n";
|
||||
}
|
||||
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||
@conf = <conf>;
|
||||
close(conf);
|
||||
$i=0;
|
||||
foreach(@conf)
|
||||
{
|
||||
$line = $conf[$i];
|
||||
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
||||
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
||||
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
||||
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
||||
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
||||
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
||||
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
|
||||
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) )
|
||||
{$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
||||
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
||||
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
||||
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
||||
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
||||
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
||||
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) )
|
||||
{$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) )
|
||||
{$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) )
|
||||
{$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) )
|
||||
{$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) )
|
||||
{$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) )
|
||||
{$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;}
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = $VARserver_ip; # Asterisk server IP
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
|
||||
use DBI;
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
|
||||
### find soxmix or sox to do the mixing
|
||||
$soxmixbin = '';
|
||||
if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
if ($DB) {print "Can't find soxmix binary! Trying sox...\n";}
|
||||
if ( -e ('/usr/bin/sox')) {$soxmixbin = '/usr/bin/sox -m';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/sox')) {$soxmixbin = '/usr/local/bin/sox -m';}
|
||||
else
|
||||
{
|
||||
print "Can't find sox binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### directory where in/out recordings are saved to by Asterisk
|
||||
$dir1 = "$PATHmonitor";
|
||||
$dir2 = "$PATHDONEmonitor";
|
||||
|
||||
opendir(FILE, "$dir1/");
|
||||
@FILES = readdir(FILE);
|
||||
|
||||
$i=0;
|
||||
foreach(@FILES)
|
||||
{
|
||||
$size1 = 0;
|
||||
$size2 = 0;
|
||||
|
||||
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
|
||||
{
|
||||
|
||||
$size1 = (-s "$dir1/$FILES[$i]");
|
||||
if ($DBX) {print "$FILES[$i] $size1\n";}
|
||||
sleep(1);
|
||||
$size2 = (-s "$dir1/$FILES[$i]");
|
||||
if ($DBX) {print "$FILES[$i] $size2\n\n";}
|
||||
|
||||
if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
|
||||
{
|
||||
$INfile = $FILES[$i];
|
||||
$OUTfile = $FILES[$i];
|
||||
$OUTfile =~ s/-in\.wav/-out.wav/gi;
|
||||
$OUTfile =~ s/-in\.gsm/-out.gsm/gi;
|
||||
$ALLfile = $FILES[$i];
|
||||
$ALLfile =~ s/-in\.wav/-all.wav/gi;
|
||||
$ALLfile =~ s/-in\.gsm/-all.gsm/gi;
|
||||
$SQLFILE = $FILES[$i];
|
||||
$SQLFILE =~ s/-in\.wav|-in\.gsm//gi;
|
||||
|
||||
$stmtA = "select recording_id from recording_log where filename='$SQLFILE' order by recording_id desc LIMIT 1;";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
if ($sthArows > 0)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$recording_id = "$aryA[0]";
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
if ($DB) {print "|$recording_id|$INfile|$OUTfile| |$ALLfile|\n";}
|
||||
|
||||
`$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir2/$ALLfile"`;
|
||||
|
||||
$stmtA = "UPDATE recording_log set location='http://$server_ip/RECORDINGS/$ALLfile' where recording_id='$recording_id';";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
|
||||
|
||||
if (!$T)
|
||||
{
|
||||
`mv -f "$dir1/$INfile" "$dir2/ORIG/$INfile"`;
|
||||
`mv -f "$dir1/$OUTfile" "$dir2/ORIG/$OUTfile"`;
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($DB) {print "DONE... EXITING\n\n";}
|
||||
|
||||
$dbhA->disconnect();
|
||||
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,292 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_CRON_audio_2_compress.pl
|
||||
#
|
||||
# This is a STEP-2 program in the audio archival process
|
||||
#
|
||||
# runs every 3 minutes and compresses the -all recording files to GSM format
|
||||
#
|
||||
# put an entry into the cron of of your asterisk machine to run this script
|
||||
# every 3 minutes or however often you desire
|
||||
#
|
||||
# ### recording mixing/compressing/ftping scripts
|
||||
##0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
|
||||
# 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
|
||||
# 1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
|
||||
# 2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
|
||||
#
|
||||
# FLAGS FOR COMPRESSION CODECS
|
||||
# --GSM = GSM 6.10 codec
|
||||
# --MP3 = MPEG Layer3 codec
|
||||
# --OGG = OGG Vorbis codec
|
||||
#
|
||||
# make sure that the following directories exist:
|
||||
# /var/spool/asterisk/monitorDONE # where the mixed -all files are put
|
||||
#
|
||||
# This program assumes that recordings are saved by Asterisk as .wav
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 80302-1958 - First Build
|
||||
#
|
||||
|
||||
$GSM=0; $MP3=0; $OGG=0;
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n [--GSM] = compress into GSM codec\n [--MP3] = compress into MPEG-Layer-3 codec\n [--OGG] = compress into OGG Vorbis codec\n\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n----- DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING -----\n\n";
|
||||
}
|
||||
if ($args =~ /--GSM/i)
|
||||
{
|
||||
$GSM=1;
|
||||
if ($DB) {print "GSM compression\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--MP3/i)
|
||||
{
|
||||
$MP3=1;
|
||||
if ($DB) {print "MP3 compression\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--OGG/i)
|
||||
{
|
||||
$OGG=1;
|
||||
if ($DB) {print "OGG compression\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#print "no command line options set\n";
|
||||
$GSM=1;
|
||||
}
|
||||
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||
@conf = <conf>;
|
||||
close(conf);
|
||||
$i=0;
|
||||
foreach(@conf)
|
||||
{
|
||||
$line = $conf[$i];
|
||||
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
||||
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
||||
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
||||
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
||||
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
||||
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
||||
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
|
||||
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) )
|
||||
{$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
||||
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
||||
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
||||
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
||||
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
||||
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
||||
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) )
|
||||
{$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) )
|
||||
{$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) )
|
||||
{$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) )
|
||||
{$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) )
|
||||
{$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) )
|
||||
{$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;}
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = $VARserver_ip; # Asterisk server IP
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
|
||||
use DBI;
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
|
||||
if ( ($GSM > 0) || ($OGG > 0) )
|
||||
{
|
||||
### find sox binary to do the compression
|
||||
$soxbin = '';
|
||||
if ( -e ('/usr/bin/sox')) {$soxbin = '/usr/bin/sox';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/sox')) {$soxbin = '/usr/local/bin/sox';}
|
||||
else
|
||||
{
|
||||
print "Can't find sox binary! Exiting...\n";
|
||||
exit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($MP3 > 0)
|
||||
{
|
||||
### find lame mp3 encoder binary to do the compression
|
||||
$lamebin = '';
|
||||
if ( -e ('/usr/bin/lame')) {$lamebin = '/usr/bin/lame';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/lame')) {$lamebin = '/usr/local/bin/lame';}
|
||||
else
|
||||
{
|
||||
print "Can't find lame binary! Exiting...\n";
|
||||
exit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
### directory where -all recordings are
|
||||
$dir2 = "$PATHDONEmonitor";
|
||||
|
||||
opendir(FILE, "$dir2/");
|
||||
@FILES = readdir(FILE);
|
||||
|
||||
$i=0;
|
||||
foreach(@FILES)
|
||||
{
|
||||
$size1 = 0;
|
||||
$size2 = 0;
|
||||
|
||||
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
|
||||
{
|
||||
|
||||
$size1 = (-s "$dir2/$FILES[$i]");
|
||||
if ($DBX) {print "$FILES[$i] $size1\n";}
|
||||
sleep(1);
|
||||
$size2 = (-s "$dir2/$FILES[$i]");
|
||||
if ($DBX) {print "$FILES[$i] $size2\n\n";}
|
||||
|
||||
if ( ($FILES[$i] !~ /out\.|in\./i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
|
||||
{
|
||||
$recording_id='';
|
||||
$ALLfile = $FILES[$i];
|
||||
$SQLFILE = $FILES[$i];
|
||||
$SQLFILE =~ s/-all\.wav|-all\.gsm//gi;
|
||||
|
||||
$stmtA = "select recording_id from recording_log where filename='$SQLFILE' order by recording_id desc LIMIT 1;";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
if ($sthArows > 0)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$recording_id = "$aryA[0]";
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
if ($GSM > 0)
|
||||
{
|
||||
$GSMfile = $FILES[$i];
|
||||
$GSMfile =~ s/-all\.wav/-all.gsm/gi;
|
||||
|
||||
if ($DB) {print "|$recording_id|$ALLfile|$GSMfile| |$SQLfile|\n";}
|
||||
|
||||
`$soxbin "$dir2/$ALLfile" "$dir2/GSM/$GSMfile"`;
|
||||
|
||||
$stmtA = "UPDATE recording_log set location='http://$server_ip/RECORDINGS/GSM/$GSMfile' where recording_id='$recording_id';";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
|
||||
}
|
||||
|
||||
if ($OGG > 0)
|
||||
{
|
||||
$OGGfile = $FILES[$i];
|
||||
$OGGfile =~ s/-all\.wav/-all.ogg/gi;
|
||||
|
||||
if ($DB) {print "|$recording_id|$ALLfile|$OGGfile| |$SQLfile|\n";}
|
||||
|
||||
`$soxbin "$dir2/$ALLfile" "$dir2/OGG/$OGGfile"`;
|
||||
|
||||
$stmtA = "UPDATE recording_log set location='http://$server_ip/RECORDINGS/OGG/$OGGfile' where recording_id='$recording_id';";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
|
||||
}
|
||||
|
||||
if ($MP3 > 0)
|
||||
{
|
||||
$MP3file = $FILES[$i];
|
||||
$MP3file =~ s/-all\.wav/-all.mp3/gi;
|
||||
|
||||
if ($DB) {print "|$recording_id|$ALLfile|$MP3file| |$SQLfile|\n";}
|
||||
|
||||
`$lamebin -b 16 -m m --silent "$dir2/$ALLfile" "$dir2/MP3/$MP3file"`;
|
||||
|
||||
$stmtA = "UPDATE recording_log set location='http://$server_ip/RECORDINGS/MP3/$MP3file' where recording_id='$recording_id';";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
|
||||
}
|
||||
|
||||
|
||||
if (!$T)
|
||||
{
|
||||
`mv -f "$dir2/$ALLfile" "$dir2/ORIG/$ALLfile"`;
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($DB) {print "DONE... EXITING\n\n";}
|
||||
|
||||
$dbhA->disconnect();
|
||||
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,263 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_CRON_audio_3_ftp.pl
|
||||
#
|
||||
# This is a STEP-3 program in the audio archival process
|
||||
#
|
||||
# runs every 3 minutes and copies the recording files to an FTP server
|
||||
#
|
||||
# put an entry into the cron of of your asterisk machine to run this script
|
||||
# every 3 minutes or however often you desire
|
||||
#
|
||||
# ### recording mixing/compressing/ftping scripts
|
||||
##0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
|
||||
# 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
|
||||
# 1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
|
||||
# 2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
|
||||
#
|
||||
# FLAGS FOR COMPRESSION FILES TO TRANSFER
|
||||
# --GSM = GSM 6.10 files
|
||||
# --MP3 = MPEG Layer3 files
|
||||
# --OGG = OGG Vorbis files
|
||||
# --WAV = WAV files
|
||||
#
|
||||
# make sure that the following directories exist:
|
||||
# /var/spool/asterisk/monitorDONE # where the mixed -all files are put
|
||||
#
|
||||
# This program assumes that recordings are saved by Asterisk as .wav
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 80302-1958 - First Build
|
||||
#
|
||||
|
||||
$GSM=0; $MP3=0; $OGG=0; $WAV=0;
|
||||
|
||||
# Default variables for FTP
|
||||
$VARFTP_host = '10.0.0.4';
|
||||
$VARFTP_user = 'cron';
|
||||
$VARFTP_pass = 'test';
|
||||
$VARFTP_port = '21';
|
||||
$VARFTP_dir = 'RECORDINGS';
|
||||
$VARHTTP_path = 'http://10.0.0.4';
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n [--GSM] = copy GSM files\n [--MP3] = copy MPEG-Layer-3 files\n [--OGG] = copy OGG Vorbis files\n [--WAV] = copy WAV files\n\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n----- DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER DEBUG -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING -----\n\n";
|
||||
}
|
||||
if ($args =~ /--GSM/i)
|
||||
{
|
||||
$GSM=1;
|
||||
if ($DB) {print "GSM audio files\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--MP3/i)
|
||||
{
|
||||
$MP3=1;
|
||||
if ($DB) {print "MP3 audio files\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--OGG/i)
|
||||
{
|
||||
$OGG=1;
|
||||
if ($DB) {print "OGG audio files\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--WAV/i)
|
||||
{
|
||||
$WAV=1;
|
||||
if ($DB) {print "WAV audio files\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#print "no command line options set\n";
|
||||
$WAV=1;
|
||||
}
|
||||
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||
@conf = <conf>;
|
||||
close(conf);
|
||||
$i=0;
|
||||
foreach(@conf)
|
||||
{
|
||||
$line = $conf[$i];
|
||||
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
||||
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
||||
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
||||
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
||||
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
||||
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
||||
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
|
||||
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) )
|
||||
{$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
||||
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
||||
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
||||
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
||||
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
||||
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
||||
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) )
|
||||
{$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) )
|
||||
{$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) )
|
||||
{$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) )
|
||||
{$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) )
|
||||
{$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) )
|
||||
{$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;}
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = $VARserver_ip; # Asterisk server IP
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
|
||||
use DBI;
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
use Net::Ping;
|
||||
use Net::FTP;
|
||||
|
||||
### directory where -all recordings are
|
||||
if ($WAV > 0) {$dir2 = "$PATHDONEmonitor";}
|
||||
if ($MP3 > 0) {$dir2 = "$PATHDONEmonitor/MP3";}
|
||||
if ($GSM > 0) {$dir2 = "$PATHDONEmonitor/GSM";}
|
||||
if ($OGG > 0) {$dir2 = "$PATHDONEmonitor/OGG";}
|
||||
|
||||
opendir(FILE, "$dir2/");
|
||||
@FILES = readdir(FILE);
|
||||
|
||||
$i=0;
|
||||
foreach(@FILES)
|
||||
{
|
||||
$size1 = 0;
|
||||
$size2 = 0;
|
||||
|
||||
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
|
||||
{
|
||||
|
||||
$size1 = (-s "$dir2/$FILES[$i]");
|
||||
if ($DBX) {print "$FILES[$i] $size1\n";}
|
||||
sleep(1);
|
||||
$size2 = (-s "$dir2/$FILES[$i]");
|
||||
if ($DBX) {print "$FILES[$i] $size2\n\n";}
|
||||
|
||||
if ( ($FILES[$i] !~ /out\.|in\./i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
|
||||
{
|
||||
$recording_id='';
|
||||
$ALLfile = $FILES[$i];
|
||||
$SQLFILE = $FILES[$i];
|
||||
$SQLFILE =~ s/-all\.wav|-all\.gsm|-all\.ogg|-all\.mp3//gi;
|
||||
|
||||
$stmtA = "select recording_id,start_time from recording_log where filename='$SQLFILE' order by recording_id desc LIMIT 1;";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
if ($sthArows > 0)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$recording_id = "$aryA[0]";
|
||||
$start_date = "$aryA[1]";
|
||||
$start_date =~ s/ .*//gi;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
if ($DB) {print "|$recording_id|$start_date|$ALLfile| |$SQLfile|\n";}
|
||||
|
||||
### BEGIN Remote file transfer
|
||||
$p = Net::Ping->new();
|
||||
$ping_good = $p->ping("$VARFTP_host");
|
||||
|
||||
if ($ping_good)
|
||||
{
|
||||
$ftp = Net::FTP->new("$VARFTP_host", Port => $VARFTP_port);
|
||||
$ftp->login("$VARFTP_user","$VARFTP_pass");
|
||||
$ftp->cwd("$VARFTP_dir");
|
||||
$ftp->mkdir("$start_date");
|
||||
$ftp->cwd("$start_date");
|
||||
$ftp->binary();
|
||||
$ftp->put("$dir2/$ALLfile", "$ALLfile");
|
||||
$ftp->quit;
|
||||
|
||||
$stmtA = "UPDATE recording_log set location='$VARHTTP_path/$start_date/$ALLfile' where recording_id='$recording_id';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
|
||||
|
||||
if (!$T)
|
||||
{
|
||||
`mv -f "$dir2/$ALLfile" "$PATHDONEmonitor/FTP/$ALLfile"`;
|
||||
}
|
||||
}
|
||||
### END Remote file transfer
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($DB) {print "DONE... EXITING\n\n";}
|
||||
|
||||
$dbhA->disconnect();
|
||||
|
||||
|
||||
exit;
|
||||
@@ -85,8 +85,17 @@ else
|
||||
if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
print "Can't find soxmix binary! Exiting...\n";
|
||||
exit;
|
||||
print "Can't find soxmix binary! Trying sox...\n";
|
||||
if ( -e ('/usr/bin/sox')) {$soxmixbin = '/usr/bin/sox -m';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/sox')) {$soxmixbin = '/usr/local/bin/sox -m';}
|
||||
else
|
||||
{
|
||||
print "Can't find sox binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -603,12 +603,12 @@ PHASE 6: ADDING CRONTAB ENTRIES FOR ASTGUICLIENT/VICIDIAL SCRIPTS
|
||||
- cd /usr/share/astguiclient
|
||||
- crontab -e
|
||||
- add the following entries(here's what we used):
|
||||
(Note if you have not edited the AST_CRON_mix_recordings.pl script
|
||||
to FTP to a different server, then you should use the
|
||||
AST_CRON_mix_recordings_BASIC.pl file in it's place)
|
||||
|
||||
### recording mixing for Asterisk run every 5 minutes
|
||||
1,6,11,16,21,26,31,36,41,46,51,56 * * * 1,2,3,4,5,6 /usr/share/astguiclient/AST_CRON_mix_recordings_BASIC.pl
|
||||
### recording mixing/compressing/ftping scripts
|
||||
0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
|
||||
#0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
|
||||
1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
|
||||
#2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
|
||||
|
||||
### keepalive script for astguiclient processes
|
||||
* * * * * /usr/share/astguiclient/ADMIN_keepalive_ALL.pl
|
||||
|
||||
@@ -72,15 +72,25 @@ make install
|
||||
|
||||
|
||||
cd /usr/local
|
||||
wget http://easynews.dl.sourceforge.net/sourceforge/sox/sox-12.17.9.tar.gz
|
||||
gunzip sox-12.17.9.tar.gz
|
||||
tar xvf sox-12.17.9.tar
|
||||
cd sox-12.17.9
|
||||
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.96.1.tar.gz
|
||||
gunzip lame-3.96.1.tar.gz
|
||||
tar xvf lame-3.96.1.tar
|
||||
cd lame-3.96.1
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
|
||||
cd /usr/local
|
||||
wget http://easynews.dl.sourceforge.net/sourceforge/sox/sox-14.0.1.tar.gz
|
||||
gunzip sox-14.0.1.tar.gz
|
||||
tar xvf sox-14.0.1.tar
|
||||
cd sox-14.0.1
|
||||
./configure --disable-shared
|
||||
make
|
||||
make install
|
||||
|
||||
|
||||
cd /usr/local
|
||||
wget http://ftp.gnu.org/gnu/screen/screen-4.0.2.tar.gz
|
||||
gunzip screen-4.0.2.tar.gz
|
||||
|
||||
+11
-10
@@ -479,11 +479,12 @@ in and out as separate files
|
||||
1. Go to http://sourceforge.net/projects/sox/ and download the sox package
|
||||
- to install this directly on the command line type:
|
||||
- cd /usr/local
|
||||
- wget http://easynews.dl.sourceforge.net/sourceforge/sox/sox-12.17.9.tar.gz
|
||||
- gunzip sox-12.17.9.tar.gz
|
||||
- tar xvf sox-12.17.9.tar
|
||||
- cd sox-12.17.9
|
||||
- ./configure
|
||||
- cd /usr/local
|
||||
- wget http://easynews.dl.sourceforge.net/sourceforge/sox/sox-14.0.1.tar.gz
|
||||
- gunzip sox-14.0.1.tar.gz
|
||||
- tar xvf sox-14.0.1.tar
|
||||
- cd sox-14.0.1
|
||||
- ./configure --disable-shared
|
||||
- make (if alsa.o errors add --disable-alsa-dsp to configure and redo)
|
||||
- make install
|
||||
- you are done
|
||||
@@ -2849,12 +2850,12 @@ SUBPHASE 6.5: setting up astguiclient scripts for continuous running
|
||||
- cd /usr/share/astguiclient
|
||||
- crontab -e
|
||||
- add the following entries(here's what we used):
|
||||
(Note if you have not edited the AST_CRON_mix_recordings.pl script
|
||||
to FTP to a different server, then you should use the
|
||||
AST_CRON_mix_recordings_BASIC.pl file in it's place)
|
||||
|
||||
### recording mixing for Asterisk run every 5 minutes
|
||||
1,6,11,16,21,26,31,36,41,46,51,56 * * * 1,2,3,4,5,6 /usr/share/astguiclient/AST_CRON_mix_recordings_BASIC.pl
|
||||
### recording mixing/compressing/ftping scripts
|
||||
0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
|
||||
#0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
|
||||
1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
|
||||
#2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
|
||||
|
||||
### keepalive script for astguiclient processes
|
||||
* * * * * /usr/share/astguiclient/ADMIN_keepalive_ALL.pl
|
||||
|
||||
@@ -2109,6 +2109,10 @@ if ($WEBONLY < 1)
|
||||
`mkdir -p $PATHmonitor`;
|
||||
`mkdir -p $PATHDONEmonitor`;
|
||||
`mkdir -p $PATHDONEmonitor/ORIG`;
|
||||
`mkdir -p $PATHDONEmonitor/GSM`;
|
||||
`mkdir -p $PATHDONEmonitor/MP3`;
|
||||
`mkdir -p $PATHDONEmonitor/OGG`;
|
||||
`mkdir -p $PATHDONEmonitor/FTP`;
|
||||
`chmod -R 0766 $PATHmonitor`;
|
||||
`chmod -R 0766 $PATHDONEmonitor`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user