|
In order to use AsteriskC2D you need to install a simple Perl script onto a webserver. Normally people pick the server Asterisk is also running on but it's not required.
So to get started you'll need to download the tar ball which contains two scripts, one you might already have "cgi-lib.pl" and the other you won't "AsteriskC2D.pl".
 AsteriskC2D.tgz Version released 10th August 2009
This new version now does not require you to install perl modules you do not intend to use. Ie if you're installing on trixbox, then you don't need to install the LDAP module. The script will also provide human error messages when necessary modules are missing
Support for setting CallerID from the iPhone has now been included. You'll need to install the PBXCode ##1212# to get the extra parameter on your iPhone. If you do not then original function will remain.
You need to copy them to your "cgi-bin" directory of your webserver, "/var/www/cgi-bin/" maybe. change the permissions on "AsteriskC2D.pl" so it's world executable.
$ chmod 755 AsteriskC2D.pl
The Perl script also requires at least one perl module which might not be installed on your system, "NET::Telnet".
$ sudo perl -MCPAN -e "install('Net::Telnet');"
If you want to authenticate with LDAP then you'll likely need this modules too.
sudo perl -MCPAN -e "install('Net::LDAP');"
Use your favorite editor, vi, pico, emacs, to edit AsteriskC2D.pl to match your Environment. By default this script will use mySQL server to authenticate the users and is generally set for TrixBox.
###########################################################################
# 1 for LDAP, 2 for MySQL, 0 to use a file
my $authMethod = 2;
# Asterisk server IP or hostname
my $server_ip = '127.0.0.1';
# Username in the manager.conf file which is allowed to connect.. you have enabled it right! :)
my $clickUser = 'AsteriskC2D';
# the password associated with the above username
my $ClickPassword = 'nottelling!';
# LDAP server configuration bits
###########################################################################
# LDAP server used to authenticate the users expecting to click and dial
my $LDAPServer = 'ldap.example.com';
# prefix for the usernames eg uid=rho,cn=users,dc=00
my $UID ='uid';
# where in the LDAP to look for the users to authenticate
my $LDAPSearch = 'ou=people,dc=example,dc=com';
###########################################################################
# MySQL authentication support
# Trixbox support
###########################################################################
# Use MySQL for authentication, mainly for TrixBox Support
# mysql Server usually localhost
my $MySQLserver = 'localhost';
# username
my $dbusername = 'asteriskuser';
# Password
my $dbpasswd = 'amp109';
# database name
my $database = 'asterisk';
# tablename
my $table = 'sip';
# query for
my $dbquery = 'select data from sip where keyword=\'secret\' and id=';
###########################################################################
# file based authentication configuration
###########################################################################
my $authFile = '/etc/AsteriskC2D.users';
###########################################################################
# contexts in extensions.conf to start matching to dialing strings etc.
my $context = 'from-internal';
#The callerID to put on the phone you are Dialing FROM!!!..
#This puts the name ClickDial and the number your dialing!
my $CIDName = 'ClickDial';
# Enable logging?
my $LOGGING = 1;
# where to log?
my $LOGFILE = '/var/log/asterisk/click.log';
If you would like AsteriskC2D to adjust some phone numbers in flight, ie to change + to your international dialing code etc the look around line 152, uncomment and edit the if statements to your required tastes.
# Uncomment or edit these lines to have AsteriskC2D adjust numbers on the fly.
# if (substr($exten,0,4) eq '+440') { $exten = '90'.substr($exten,4,length($exten)); }
# if (substr($exten,0,3) eq '+44') { $exten = '90'.substr($exten,3,length($exten)); }
# if (substr($exten,0,2) eq '44') { $exten = '90'.substr($exten,2,length($exten)); }
# if (substr($exten,0,1) eq '+') { $exten = '900'.substr($exten,1,length($exten)); }
# if ((substr($exten,0,1) ne '9') && (length($exten) > 4) ) { $exten = '9'.$exten; }
now edit "/etc/asterisk/manager.conf" and make sure it's enabled and you've specified a username and password which matches the "clickUser" and "clickPassword" in the AsteriskC2D.pl script
[general] displaysystemname = yes enabled = yes webenabled = yes port = 5038 httptimeout = 60 bindaddr = 0.0.0.0 [asteriskC2D] secret=nottelling read=call,user write=call,user
If you're using Asterisk 1.6 you might need to change "call,user" to be "call,user,originate" in the above lines.
That should be it. Restart Asterisk and you're ready to try test dialing. If you're on a unix system then you can use "curl" to test the script and it's ability to talk with asterisk.
curl 'http://localhost/cgi-bin/AsteriskC2D.pl' -d 'username=fred&password=1234&deskphone=SIP/1234&toCall=600'
If that works then try with the AsteriskC2D Mac Client. Don't forget to look in your webserver access and error logs.
You might also want to review this document http://www.rho.cc/index.php/faq/asteriskc2d/50-asteriskc2d-iphone/47-iphone-and-ssl-certificates to help with securing your Asterisk server with SSL.
|