forked from njdcamilli/agilebill
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sluther
committed
Aug 27, 2010
1 parent
c6de111
commit 0b7773d
Showing
11 changed files
with
764 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
doinstall() { | ||
perl -pe "s|%%AGILE_DB_HOST%%|${db_host}|g" $1 | \ | ||
perl -pe "s|%%AGILE_DB_DATABASE%%|${db_name}|g" | \ | ||
perl -pe "s|%%AGILE_DB_USERNAME%%|${db_user}|g" | \ | ||
perl -pe "s|%%AGILE_DB_PASSWORD%%|${db_pass}|g" > $2 | ||
echo "Installing to: $2" | ||
} | ||
|
||
echo -n "Enter the database IP address: " | ||
read db_host | ||
echo -n "Enter the database name: " | ||
read db_name | ||
echo -n "Enter the database username: " | ||
read db_user | ||
echo -n "Enter the database password: " | ||
read db_pass | ||
# echo | ||
# echo "Installing templated Asterisk configuration files..." | ||
|
||
# cd conf | ||
# for FILE in *; do | ||
# doinstall ${FILE} /etc/asterisk/${FILE} | ||
# done | ||
# cd .. | ||
cd scripts1.6 | ||
for FILE in *; do | ||
doinstall ${FILE} /usr/sbin/${FILE} | ||
chmod 755 /usr/sbin/${FILE} | ||
done | ||
cd .. | ||
|
||
echo "Installing Cron entries..." | ||
echo "*/15 * * * * asterisk /usr/sbin/agilevoice-export-extensions" >>/etc/crontab | ||
echo "*/15 * * * * asterisk /usr/sbin/agilevoice-export-sip" >>/etc/crontab | ||
echo "*/15 * * * * asterisk /usr/sbin/agilevoice-export-iax" >>/etc/crontab | ||
echo "*/15 * * * * asterisk /usr/sbin/agilevoice-export-vm" >>/etc/crontab | ||
echo "*/30 * * * * asterisk /usr/sbin/cdr_import_agilevoice" >>/etc/crontab | ||
|
||
perl -MCPAN -e "install Text::CSV" | ||
|
||
echo "Installing MySQL tables..." | ||
echo "Installing av-tables.sql" | ||
mysql -u ${db_user} -p${db_pass} ${db_name} < av-tables.sql | ||
|
||
|
||
echo "Complete." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
import posix | ||
import os | ||
|
||
posix.system('/usr/sbin/agilevoice-export-extensions.pl') | ||
a = posix.system('diff -q /etc/asterisk/extensions_agilevoice.conf.tmp /etc/asterisk/extensions_agilevoice.conf >/dev/null 2>&1') | ||
if a: | ||
try: | ||
os.unlink('/etc/asterisk/extensions_agilevoice.conf') | ||
except OSError: | ||
pass | ||
posix.system('mv -f /etc/asterisk/extensions_agilevoice.conf.tmp /etc/asterisk/extensions_agilevoice.conf') | ||
posix.system('asterisk -rx "extensions reload" >/dev/null 2>&1') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/perl -T | ||
# Retrieves the extensions entries from the database | ||
|
||
use DBI; | ||
################### BEGIN OF CONFIGURATION #################### | ||
|
||
# the name of the extensions table | ||
$table_name = "ab_voip_did"; | ||
# the path to the extensions.conf file | ||
# WARNING: this file will be substituted by the output of this program | ||
$ext_conf = "/etc/asterisk/extensions_agilevoice.conf.tmp"; | ||
# the name of the box the MySQL database is running on | ||
$hostname = "%%AGILE_DB_HOST%%"; | ||
# the name of the database our tables are kept | ||
$database = "%%AGILE_DB_DATABASE%%"; | ||
# username to connect to the database | ||
$username = "%%AGILE_DB_USERNAME%%"; | ||
# password to connect to the database | ||
$password = "%%AGILE_DB_PASSWORD%%"; | ||
|
||
################### END OF CONFIGURATION ####################### | ||
|
||
my $dial = ""; | ||
my $dialarg = ""; | ||
|
||
open EXTEN, ">$ext_conf" or die "Cannot create/overwrite file: $ext_conf\n"; | ||
|
||
$dbh = DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username", "$password"); | ||
|
||
|
||
$statement = "SELECT did, channel, channelarg from $table_name WHERE active=1 ORDER BY did"; | ||
my $result = $dbh->selectall_arrayref($statement); | ||
unless ($result) { | ||
# check for errors after every single database call | ||
print "dbh->selectall_arrayref($statement) failed!\n"; | ||
print "DBI::err=[$DBI::err]\n"; | ||
print "DBI::errstr=[$DBI::errstr]\n"; | ||
exit; | ||
} | ||
my @resultSet = @{$result}; | ||
if ( $#resultSet > -1 ) { | ||
foreach $row (@{ $result }) { | ||
my @result = @{ $row }; | ||
$dial = $result[1]; | ||
$dialarg = $result[2]; | ||
if (0 == length($dialarg)) { | ||
$dialarg = $result[0]; | ||
} | ||
if ($dial =~ /IAX/) { | ||
$dial = "IAX2/".$dialarg."/".$result[1]; | ||
} else { | ||
$dial = "SIP/".$dialarg; | ||
} | ||
print EXTEN "exten => ".$result[0].",1,Dial(".$dial.")\n"; | ||
print EXTEN "exten => ".$result[0].",2,Macro(exten-vm,".$result[0].",".$dial.")\n"; | ||
print EXTEN "exten => ".$result[0].",3,Hangup\n"; | ||
} | ||
} | ||
exit 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
import posix | ||
import os | ||
|
||
posix.system('/usr/sbin/retrieve_iax_conf_from_mysql.pl') | ||
a = posix.system('diff -q /etc/asterisk/iax_agilevoice.conf.tmp /etc/asterisk/iax_agilevoice.conf >/dev/null 2>&1') | ||
if a: | ||
try: | ||
os.unlink('/etc/asterisk/iax_agilevoice.conf') | ||
except OSError: | ||
pass | ||
posix.system('mv -f /etc/asterisk/iax_agilevoice.conf.tmp /etc/asterisk/iax_agilevoice.conf') | ||
posix.system('asterisk -rx "reload chan_iax2.so" >/dev/null 2>&1') | ||
posix.system('asterisk -rx "reload app_voicemail.so" >/dev/null 2>&1') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
import posix | ||
import os | ||
|
||
posix.system('/usr/sbin/retrieve_sip_conf_from_mysql.pl') | ||
a = posix.system('diff -q /etc/asterisk/sip_agilevoice.conf.tmp /etc/asterisk/sip_agilevoice.conf >/dev/null 2>&1') | ||
if a: | ||
try: | ||
os.unlink('/etc/asterisk/sip_agilevoice.conf') | ||
except OSError: | ||
pass | ||
posix.system('mv -f /etc/asterisk/sip_agilevoice.conf.tmp /etc/asterisk/sip_agilevoice.conf') | ||
posix.system('asterisk -rx "sip reload" >/dev/null 2>&1') | ||
posix.system('asterisk -rx "reload app_voicemail.so" >/dev/null 2>&1') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/perl -Tw | ||
# Retrieves the voicemail entries from the database | ||
|
||
use DBI; | ||
################### BEGIN OF CONFIGURATION #################### | ||
|
||
# the name of the extensions table | ||
$table_name = "ab_voip_vm"; | ||
# the path to the extensions.conf file | ||
# WARNING: this file will be substituted by the output of this program | ||
$vm_conf = "/etc/asterisk/voicemai.conf"; | ||
# the name of the box the MySQL database is running on | ||
$hostname = "%%AGILE_DB_HOST%%"; | ||
# the name of the database our tables are kept | ||
$database = "%%AGILE_DB_DATABASE%%"; | ||
# username to connect to the database | ||
$username = "%%AGILE_DB_USERNAME%%"; | ||
# password to connect to the database | ||
$password = "%%AGILE_DB_PASSWORD%%"; | ||
|
||
################### END OF CONFIGURATION ####################### | ||
|
||
open EXTEN, ">$vm_conf" or die "Cannot create/overwrite file: $vm_conf\n"; | ||
|
||
$dbh = DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username", "$password"); | ||
|
||
# Get the possible contexts available | ||
$statement = "SELECT DISTINCT context FROM $table_name"; | ||
my $cresult = $dbh->selectall_arrayref($statement); | ||
unless ($cresult) { | ||
# check for errors after every single database call | ||
print "dbh->selectall_arrayref($statement) failed!\n"; | ||
print "DBI::err=[$DBI::err]\n"; | ||
print "DBI::errstr=[$DBI::errstr]\n"; | ||
exit; | ||
} | ||
|
||
# Global Voicemail configuration options | ||
print EXTEN "[general]\n\n"; | ||
print EXTEN "format=wav49|wav\n"; | ||
print EXTEN "operator=yes\n"; | ||
print EXTEN "review=yes\n"; | ||
print EXTEN "serveremail=AgileVoice\n"; | ||
print EXTEN "attach=yes\n"; | ||
print EXTEN "maxmessage=300\n"; | ||
print EXTEN "minmessage=3\n"; | ||
print EXTEN "maxsilence=5\n"; | ||
print EXTEN "pbxskip=yes\n"; | ||
print EXTEN "fromstring=AgileVoice\n"; | ||
print EXTEN 'emailsubject=New voicemail from ${VM_CALLERID}'; print EXTEN "\n"; | ||
print EXTEN 'emailbody=Dear ${VM_NAME}:\n\n\tJust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE} so you might\nwant to check it when you get a chance. Thanks!\n'; print EXTEN "\n"; | ||
print EXTEN "mailcmd=/usr/sbin/sendmail -t\n"; | ||
|
||
print EXTEN "\n[zonemessages]\n"; | ||
print EXTEN "eastern=America/New_York|'vm-received' Q 'digits/at' IMp\n"; | ||
print EXTEN "central=America/Chicago|'vm-received' Q 'digits/at' IMp\n"; | ||
print EXTEN "central24=America/Chicago|'vm-received' q 'digits/at' H 'digits/hundred' M 'hours'\n"; print EXTEN "\n"; | ||
|
||
|
||
|
||
my @cresultSet = @{$cresult}; | ||
if ( $#cresultSet > -1 ) { | ||
foreach $crow (@{ $cresult }) { | ||
my @cresult = @{ $crow }; | ||
|
||
# Print the context out | ||
print EXTEN "[".$cresult[0]."]\n"; | ||
|
||
$statement = "SELECT context, mailbox, password, fullname, email, pager, options from $table_name WHERE context='".$cresult[0]."'"; | ||
my $result = $dbh->selectall_arrayref($statement); | ||
unless ($result) { | ||
# check for errors after every single database call | ||
print "dbh->selectall_arrayref($statement) failed!\n"; | ||
print "DBI::err=[$DBI::err]\n"; | ||
print "DBI::errstr=[$DBI::errstr]\n"; | ||
exit; | ||
} | ||
my @resultSet = @{$result}; | ||
if ( $#resultSet > -1 ) { | ||
foreach $row (@{ $result }) { | ||
my @result = @{ $row }; | ||
print EXTEN $result[1]." => ".$result[2].",".$result[3].",".$result[4]."\n"; | ||
} | ||
} | ||
} | ||
} | ||
|
||
exit 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
import posix | ||
import os | ||
|
||
posix.system('/usr/sbin/agilevoice-pro-export-extensions.pl') | ||
a = posix.system('diff -q /etc/asterisk/extensions_agilevoice.conf.tmp /etc/asterisk/extensions_agilevoice.conf >/dev/null 2>&1') | ||
if a: | ||
try: | ||
os.unlink('/etc/asterisk/extensions_agilevoice.conf') | ||
except OSError: | ||
pass | ||
posix.system('mv -f /etc/asterisk/extensions_agilevoice.conf.tmp /etc/asterisk/extensions_agilevoice.conf') | ||
posix.system('asterisk -rx "extensions reload" >/dev/null 2>&1') | ||
|
Oops, something went wrong.