AreskiCC CallingCard Application The idiots guideV2

IMPORTANT : The new version of AreskiCC have changed his name -> "A2Billing"

Please for a followup of the project go to the appropriate pages :

The idiots guide to installing AreskiCC CallingCard Application V2
(Updated August 1st 2005)

Frist of all thanks to terchris for starting the first guide and to everyone who contributed to it.
A quote from the original idiot's guide:
"This guide is for those who have no knowledge of Areski, postgres and hardly any knowledge of Linux.
I wrote it because I had to figure out the hard way. If you want to test AreskiCC, but have no idea on how
to do so then this guide is for you."

I'm writing this for the same reasons, but I have it a lot easier as all I have to do is update some info.
I am assuming a little higher linux knowledge than the first guide, but I feel that if you use both the original
and this you sould be able to figure out any neccessary linux commands.

This guide is assuming a vanilla install of Asterisk@Home V1.3 and will install AreskiCC V2.2

A.Install components that will support AreskiCC
1.)Install postgres sql server.
yum install rh-postgresql-server

2.)Install php-pgsql.
yum install php-pgsql

3.) Make sure that php dynamically loads the pgsql.so module on execution.
The following directions have to be set in your php.ini:
extension_dir = 'directory where pgsql.so is located'
You should really check this, because if areskicc2 fails to connect to Postgre due to missing php-pgsql
functionality you won't get a php error for some strange reason. So you better be sure that you have a working
php-pgsql setup.
Make sure it has a line
  1. tcpip_socket=false make it like following tcpip_socket=true

B.Download AreskiCC source and data base schema.
(Note: Check http://www.areski.net to see if V2.2 is the most current!!!)
cd /usr/src
mkdir areski
cd areski
wget http://www.areski.net/areskicc-doc-v2/Areski_AGI_v2.2.tar.gz
wget http://www.areski.net/areskicc-doc-v2/AreskiCC_UI_v2.2.tar.gz
wget http://www.areski.net/areskicc-doc-v2/areskicc-pgsql-schema-v2.2.sql

C.Unpack the source
tar -xzvf ./Areski_AGI_v2.2.tar.gz
tar -xzvf ./AreskiCC_UI_v2.2.tar.gz

D.*From this point I will change the numbering scheme to reflect the install notes from
I will add more info where needed, but use that document as the numbering guideline

1.Place the entire content directory into your agi-bin directory.
cd Areski_AGI
cp areskicc2.php /var/lib/asterisk/agi-bin/
cp -r libs_areskcc /var/lib/asterisk/agi-bin/

2.Make sure the script is runnable
chmod +x /var/lib/asterisk/agi-bin/areskicc2.php

3.This step is missing from the install document

4.Copy the sounds files
cp -r sounds/* /var/lib/asterisk/sounds/
  • Note you will be asked if you want to overwrite, answer yes

5.Create a Database, add a user and import the areskicc-pgsql-schema.psql

5.1.Start postgres
/etc/init.d/rhdb start

5.2.Set postgres to start automatically
chkconfig rhdb on

5.3.Login as postgres and add database user
a)su - postgres
b)createuser -W
You will be asked if the user can create databases, answer yes
You will be asked if the user can create other users, answer no
I used a username of asterisk, use whatever you want
Use whatever password you want

5.4.Create areskicc2 database
a) createdb -O asterisk areskicc2 (that is an O for Owner)

5.5.Login to new database to check ownership
a) psql -d areskicc2
b) \du

List of database users
User name | User ID | Attributes

asterisk | 100 | create database
postgres | 1 | superuser, create database
(2 rows)

c) \q (to exit from database)

5.6.Import data schema into new database
a) psql -U asterisk -d areskicc2 -f /usr/src/areski/areskicc-pgsql-schema-v2.2.sql

5.6.1 Comment from hoanguyen:
"for easy way you should do the step 5.8 and 5.9 here, then use the almost the same command line as the above, just add -U (for user) and -W (or password)"

psql -d areskicc2 -f /usr/src/areski/areskicc-pgsql-schema-v2.2.sql -U username -W

it will ask you for password then input the password you set before this step. This will create all the table with the 'username' as Owner.

5.7.Check if asterisk is owner of all the database tables by login into postgre
psql -d areskicc2 and issue the command '\d'
If it looks ok you can skip this step and go directly to 5.8. otherwise:

a)Login to the database and change the ownership of all tables and sequences
psql -d areskicc2
areskicc2=#\d (to show all tables and indexes)

List of relations
Schema | Name | Type | Owner

public | call | table | asterisk
public | call_id_seq | sequence | asterisk
public | callerid | table | asterisk
public | ui_authen_userid_seq | sequence | asterisk
(26 rows)

b)If the owner is not asterisk (or your user), we will need to change it
areskicc2=#ALTER TABLE call OWNER to asterisk;
Notice the semicolon at the end of the command, this is neccessary
You need to run this command for every table and sequence in the database (there are 26 of them)
Replace the word "call" in the example above with the table or sequence name
(use the command ALTER TABLE to alter sequences also).
  • Note upon re-reading the example, I want to clarify it as it seems confusing. In the example above
you are running the commnad ALTER TABLE on a table named "call" you are changing the OWNER to

You may cut and paste the following commands, if you are not up to typing each one individually:
ALTER TABLE call to asterisk
ALTER TABLE call_id_seq OWNER to asterisk
ALTER TABLE callerid OWNER to asterisk
ALTER TABLE callerid_id_seq OWNER to asterisk
ALTER TABLE cc_card OWNER to asterisk
ALTER TABLE cc_card_id_seq OWNER to asterisk
ALTER TABLE cc_iax_buddies OWNER to asterisk
ALTER TABLE cc_iax_buddies_id_seq OWNER to asterisk
ALTER TABLE cc_ratecard OWNER to asterisk
ALTER TABLE cc_ratecard_id_seq OWNER to asterisk
ALTER TABLE cc_sip_buddies OWNER to asterisk
ALTER TABLE cc_sip_buddies_id_seq OWNER to asterisk
ALTER TABLE cc_tariffgroup OWNER to asterisk
ALTER TABLE cc_tariffgroup_id_seq OWNER to asterisk
ALTER TABLE cc_tariffgroup_plan OWNER to asterisk
ALTER TABLE cc_tariffplan OWNER to asterisk
ALTER TABLE cc_tariffplan_id_seq OWNER to asterisk
ALTER TABLE logpayment OWNER to asterisk
ALTER TABLE logpayment_id_seq OWNER to asterisk
ALTER TABLE logrefill OWNER to asterisk
ALTER TABLE logrefill_id_seq OWNER to asterisk
ALTER TABLE templatemail OWNER to asterisk
ALTER TABLE trunk OWNER to asterisk
ALTER TABLE trunk_id_trunk_seq OWNER to asterisk
ALTER TABLE ui_authen OWNER to asterisk
ALTER TABLE ui_authen_userid_seq OWNER to asterisk

5.8.Now we must edit the pg_hba.conf file to allow connection to the database.
vi /var/lib/pgsql/data/pg_hba.conf
b)add this line above the existing line
host all all trust

So the file should look like this when complete
host all all trust
local all all trust

5.9.Restart postgres for changes to take effect
/etc/init.d/rhdb restart

6.Setup your database into the application

6.1.Edit /var/lib/asterisk/agi-bin/libs_areskcc/db_php_lib/defines.php
a)Be sure to set the user and pass to the entries you used when creating the database in step 5.3.b above.
b)I changed NUMBER_TRY to 1 from the default of 3. It seemed that if the number could not go through,
it would redial three times, repeating the error to me three times.
c)I changed LEN_CARDNUMBER to 4 because I am using AreskiCC as a authorization system, not as a calling
card system. This way the users enter their 4 digit "PIN" number before being allowed to make a call. You
probably do not want to change this if you are using this for calling cards.
d)Experiment with the other options to find the best settings for your application.

7.Setup the callingcard application into Asterisk

7.1.Edit extension_custom.conf (/etc/asterisk/extension_custom.conf)
a)Add the following under the [from-internal-custom] context.
; CallingCard application
exten => _X.,1,Answer
exten => _X.,2,Wait,2
exten => _X.,3,DeadAGI,areskicc2.php
exten => _X.,4,Wait,2
exten => _X.,5,Hangup

8.Edit sip.conf
8.1.Insert #include additional_areskicc_sip.conf at the end of the file
a)*Note: I have not configured the IAX and SIP buddies. I can only assume that the basic info that Areski
included in the help file will work correctly.

9.Edit iax.conf
9.1.#include additional_areskicc_iax.conf at the end of the file
a)*Note: I have not configured the IAX and SIP buddies. I can only assume that the basic info that Areski
included in the help file will work correctly.

10.Configure the asterisk manager

10.1.I didn't need to modify the asterisk manager.

11.Restart asterisk
11.1.Run asterisk -r

12.Install the user interface
12.1.mkdir /var/www/html/areskicc
12.2.cp -r /usr/src/areski/AreskiCC_UI_v2/* /var/www/html/areskicc
12.3.we need to edit /var/www/html/areskicc/lib/defines.php
a)change username and password to what was used in step 5.3.b above
b)change EMAIL_ADMIN to whatever email address you wish to use
c)again, change LEN_CARDNUMBER if you don't want to use the default card length
d)once you know what you are doing you can change SHOW_HELP to no

13.From this point you should be able to login to the webpage
13.3.Comment from hoanguyen: you can change this password by edit areskicc-pgsql-schema-v2.2.sql
- Looking for 2 lines in the file:
INSERT INTO ui_authen VALUES (2, 'admin', 'mypassword', 0, 1023, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2005-02-26 21:14:05.391501-05');
INSERT INTO ui_authen VALUES (1, 'root', 'myroot', 0, 1023, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2005-02-26 20:33:27.691314-05');
then change 'admin' with any user name you want, and 'mypassword' with any password you like.
also do with 'root' and 'myroot'
you have to do this before step 5.6 (before import to the database).

14.Now you can setup AreskiCC
14.1.Create a trunk
14.2.Create a tarrifgroup
14.3.Create a ratecard
14.4.Create a user

15.1.If you used the default addition to the extension_custom.conf as shown above in setp 7.1.a you should
be able to pick up your phone, dial 18005551212 and hear something like "Please enter your complete card number"
15.2.Enter the card number that was created for you when you setup your test user in step 14.4 above.
15.3.The call should route through the trunk you specified in step 14.1 and everything should be golden...

16.Additional Info
16.1.In the previous guide it was noted that you should modify the php.ini to reflect "register_globals=On"
I did not have to do this with my installation, I checked the file and it was already set to On.
16.2.There is a BUG in areskicc2.php which makes that if you set NUMBER_TRY to something other than 1, the script
will attempt to call the dnid extension and doesn't prompt for the number to dial after the first call has been
made. To fix it, replace <$use_dnid=0> at line 209 of areskicc2.php with <$use_dnid='NO'>.
16.3. Be aware that areskicc2.php strips of international dialing prefixes (011,00) when looking up the dialed
number in the rate card. normally this is the wanted way. but some iax providers give you improper cvs
ratecards (e.g. voipjet) where destination numbers are in the format 011+countryprefix.
For example : 01149 for Germany Proper. Best solution to this is to fix your rates csv file before importing it
into areskicc and make sure they use pure country prefixes for destination codes..
16.4. Already wondered whether if Areskicc's LCR function is actually doing LCR ? Well it does - but only if you care
to fix the BUG i found in Class.RateEngine.php:

if ($LCtype==0){
//$result = $this -> array_csort($result,'6',SORT_ASC); GOTTYA!
$result = $this -> array_csort($result,'9',SORT_ASC); //1
//$result = $this -> array_csort($result,'9',SORT_ASC); GOTTYA!
$result = $this -> array_csort($result,'12',SORT_ASC); //1
Created by: gsummey, Last modification: Mon 11 of Jun, 2012 (03:49 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+