AreskiCC CallingCard Application The idiots guide



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
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.

To have a common starting point I start after the installation of Asterisk at Home version 0.6. This gives you a Linux system and a running Asterisk server.
I assume that you run all commands as the root user (the Linux gurus will tell you that you should avoid using the root user. But this guide is not for them)

If you have questions that you are afraid to ask then remember �There are no stupid questions, just stupid answers�

terchris 31Jul05 There is a version 2 of the Idiots's guide created by gsummey AreskiCC CallingCard Application The idiots guideV2


The information I'm missing is marked (==> ... ) Please update if you know how.

Install Areski

1) Install postgres sql server.
Postgres is not installed so you must install it yourself. Type:
yum install rh-postgresql-server
You will get output like this:
�
I will do the following:
[ install: rh-postgresql-server 7.3.9-2.i386 ]
I will install/upgrade these to satisfy the dependencies:
[deps: rh-postgresql 7.3.9-2.i386]
[deps: rh-postgresql-libs 7.3.9-2.i386]
Is this ok [y/N]: y
�
Installed: rh-postgresql-server 7.3.9-2.i386
Dep Installed: rh-postgresql 7.3.9-2.i386 rh-postgresql-libs 7.3.9-2.i386
Transaction(s) Complete

2) Install php-pgsql
Areski needs php-pgsql and you install it by typing:
yum install php-pgsql
You will get output like this:
...
[install: php-pgsql 4.3.2-19.ent.i386]
Is this ok [y/N]: y
..
Installed: php-pgsql 4.3.2-19.ent.i386
Transaction(s) Complete


3) download Areski source

3.1 Create a temporary install dir
mkdir /usr/src/areski
and move to the newly created dir.
cd /usr/src/areski

3.2 Download the source
Copy and paste line by line to the commend line and press enter
wget http://areski.net/areskicc-doc/Areski_AGI_v1.1.tar.gz
wget http://areski.net/areskicc-doc/AreskiCC_UI_v1.1.tar.gz
wget http://areski.net/areskicc-doc/AreskiCC.psql

3.3 unpack the source
Copy and paste line by line to the commend line and press enter
tar -zxvf Areski_AGI_v1.1.tar.gz
tar -zxvf AreskiCC_UI_v1.1.tar.gz

4) The instructions for installing AreskiCC is not written for people like us.
I comment each step so that it is possible to do for us idiots.
The install file is in /usr/src/areski/Areski_AGI/INSTALL.txt
You open the file by using the vi editor. Type
vi /usr/src/areski/Areski_AGI/INSTALL.txt
(to get out of vi hit Esc and type q! at the : prompt)

I repeat the steps installation guide here with full path related to where the software is downloaded.

4.1 Place the entire content directory into your agi-bin directory.
cp /usr/src/areski/Areski_AGI/areskicc.php /var/lib/asterisk/agi-bin/.
cp -r /usr/src/areski/Areski_AGI/libs_areskcc/phpagi /var/lib/asterisk/agi-bin/.
cp -r /usr/src/areski/Areski_AGI/libs_areskcc/db_php_lib /var/lib/asterisk/agi-bin/.

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

4.3 (step is missing in INSATLL.txt I left it to have the same numbering)


4.4. Copy the sounds files
cp -r /usr/src/areski/Areski_AGI/sounds/* /var/lib/asterisk/sounds/.
You will get a overwrite message. Answer y and hit enter
cp: overwrite `/var/lib/asterisk/sounds/./vm-and.gsm'? y
cp: overwrite `/var/lib/asterisk/sounds/./vm-goodbye.gsm'? y

4.5. Create a Database use DB_areskicc.psql for postgres
a) The database is not started automatically. Start it by typing
/etc/init.d/rhdb start
You should see this output:
Initializing database: [ OK ]
Starting PostgreSQL - Red Hat Edition service: [ OK ]

(==>how to start it at boot time? If someone knows then please insert this important part)
With Redhat usually one would use: chkconfig
Example: chkconfig rhdb on

With Gentoo:
rc-update add servicenamegoeshere default

b) verify that the database is running
Log in as postgres user by typing
su - postgres
you will get this prompt:
-bash-2.05b$
create a database by typing
createdb mydb
you should get this output:
CREATE DATABASE
delete the database by typing
dropdb mydb
You shoud get this output:
DROP DATABASE
type exit to return to root user



c) Install the database from the DB_areskicc.psql file

Try this (and sorry for my english(Gool)):
4.5.1) Add NEW user with username ... (user1 sample)
postgres@asterisk:/etc/asterisk$ createuser -W
4.5.2) Login to any existing database and check is it user added
4.5.2.a) login
postgres@asterisk:/etc/asterisk$ psql -d mydb (where mydb is database from 4.5.b)
4.5.2.b) Check
mydb=# \du
4.5.2.b.1) Sample output:
List of database users
User name | User ID | Attributes

user1 | 100 |
postgres | 1 | superuser, create database
(2 rows)
4.5.3) Ok, user added, now we must set user attributes:
4.5.3.a)mydb=# ALTER USER user1 CREATEDB;
(note, thet symbol ; MUST BE at the end of command)
4.5.3.b) Check user atributes:
mydb=# \du
4.5.3.b.1) Sample output:
List of database users
User name | User ID | Attributes

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

4.5.4) Exit from database
(type "\q")
and create NEW database "areskicc2" for user user1
postgres@asterisk:/etc/asterisk$ psql -d areskicc2 -U user1
4.5.4.1) check is it ok
login to database:
postgres@asterisk:/etc/asterisk$ psql -d areskicc2
type
areskicc2=# \l+
Sample output
List of databases
Name | Owner | Encoding | Description

areskicc2 | user1 | SQL_ASCII |
template1 | postgres | SQL_ASCII | Default template database
(2 rows)
Now exit from DB (type "\q")
4.5.5) Import data from AreskiCC.psql to database areskicc2
psql -d areskicc2 -f /usr/src/areski/AreskiCC.psql
4.5.5.1) check is it ok
psql -d areskicc2
areskicc2=# \dt
Sample output:
List of relations
Schema | Name | Type | Owner

public | call | table | postgres
public | callerid | table | postgres
public | card | table | postgres
public | country | table | postgres
public | countryprefix | table | postgres
public | internationalprefix | table | postgres
public | logpayment | table | postgres
public | logrefill | table | postgres
public | provider | table | postgres
public | providerdestination | table | postgres
public | providerrate | table | postgres
public | reseller | table | postgres
public | resellercard | table | postgres
public | sale | table | postgres
public | tariff | table | postgres
public | tariffrate | table | postgres
public | trunk | table | postgres
public | ui_authen | table | postgres
(18 rows)

4.5.5.2 Now ALL is ok. Try login to You database areskicc2 with your username
(first you must exit from db, type "\q") :)

postgres@asterisk:/etc/asterisk$ psql -d areskicc2 -U user1

If you have errors "cant connect / bad autorisation ...." try edit postgres config file:
root@asterisk:# vi /etc/postgresql/pg_hba.conf
(in my system i'm add string
local areskicc2 user1 trust)
Beware to add this rule as the first one! Otherwise an other rule could be applied and will reject your authentication.
Don't forgot restart postgres daemon after change postgres config:
root@asterisk:/etc/init.d# ./postgresql restart

Now drink some beer (or tea) and GO TO p. 4.6 (:biggrin:)
Regards, Gool.


d) Test that the database is imported
Do a select * from <tablename> �
(==> I�ll write this when I have got info on how to import the database.)

"#> su postgres
%> psql -U chosen_username -W chosen_database -f database_file.sql
"

4.6. Setup your Database into the application
Edit db_php_lib/defines.php files
vi /var/lib/asterisk/agi-bin/db_php_lib/defines.php
The file looks like this:

define ("HOST", "localhost");
define ("PORT", "5432");
define ("USER", "areski");
define ("PASS", "areski");
define ("DBNAME", "areskicc2");
define ("DB_TYPE", "postgres"); // mysql or postgres

define ("FSROOT", "/var/lib/asterisk/agi-bin/");

define ("LIBDIR", FSROOT."db_php_lib/");

define ("LEN_CARDNUMBER", "10"); //lenght of the cardnumber (amount of digits)

Since we are just going to get the thing up and running we leave the file as is.

4.7 Setup the callingcard application into Asterisk
Edit extension.conf (/etc/asterisk/extension.conf)
Add the following link to the appropriate context

; CallingCard application
exten => _X.,1,Answer
exten => _X.,2,Wait,2
exten => _X.,3,DeadAGI,areskicc.php
exten => _X.,4,Wait,2
exten => _X.,5,Hangup
(==>I have not yet figured out where this should go so that AMP is not messed up)

4.8 RELOAD ASTERISK
You do this by typing
asterisk �rvv
On the CLI prompt you type reload
To exit type exit


5 Test it
Dial .. and ...
(==> missing)

6 Installation of the web interface
The web interface is downloaded into /usr/src/areski/AreskiCC_UI
Go there by typing
cd /usr/src/areski/AreskiCC_UI

6.1 Copy the files so that the web server can get to them
Create directory for Aresikicc by typing:
mkdir /var/www/html/areskicc
Copy by typing
cp -r * /var/www/html/areskicc

6.2 Ensure that you have create the Database AreskiCC.psql (for postgres)
We did this is step 5. so we don�t need to do it again.

6.3 Setup your Database into the application
We did not change the file in 4.6 so we can skip this as well.

6.4 Modify php.ini !!
Important step : modify the file php.ini (usually in /etc/... ) and find the line
"register_globals = Off"
and set it at
"register_globals = On"

If you skip this step, you won't see anything except "logout" after the login page, whatever login/password you type in.

6.5 Have fun :D
This part we will not skip.

7. Testing the system
(==> missing)



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
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.

To have a common starting point I start after the installation of Asterisk at Home version 0.6. This gives you a Linux system and a running Asterisk server.
I assume that you run all commands as the root user (the Linux gurus will tell you that you should avoid using the root user. But this guide is not for them)

If you have questions that you are afraid to ask then remember �There are no stupid questions, just stupid answers�

terchris 31Jul05 There is a version 2 of the Idiots's guide created by gsummey AreskiCC CallingCard Application The idiots guideV2


The information I'm missing is marked (==> ... ) Please update if you know how.

Install Areski

1) Install postgres sql server.
Postgres is not installed so you must install it yourself. Type:
yum install rh-postgresql-server
You will get output like this:
�
I will do the following:
[ install: rh-postgresql-server 7.3.9-2.i386 ]
I will install/upgrade these to satisfy the dependencies:
[deps: rh-postgresql 7.3.9-2.i386]
[deps: rh-postgresql-libs 7.3.9-2.i386]
Is this ok [y/N]: y
�
Installed: rh-postgresql-server 7.3.9-2.i386
Dep Installed: rh-postgresql 7.3.9-2.i386 rh-postgresql-libs 7.3.9-2.i386
Transaction(s) Complete

2) Install php-pgsql
Areski needs php-pgsql and you install it by typing:
yum install php-pgsql
You will get output like this:
...
[install: php-pgsql 4.3.2-19.ent.i386]
Is this ok [y/N]: y
..
Installed: php-pgsql 4.3.2-19.ent.i386
Transaction(s) Complete


3) download Areski source

3.1 Create a temporary install dir
mkdir /usr/src/areski
and move to the newly created dir.
cd /usr/src/areski

3.2 Download the source
Copy and paste line by line to the commend line and press enter
wget http://areski.net/areskicc-doc/Areski_AGI_v1.1.tar.gz
wget http://areski.net/areskicc-doc/AreskiCC_UI_v1.1.tar.gz
wget http://areski.net/areskicc-doc/AreskiCC.psql

3.3 unpack the source
Copy and paste line by line to the commend line and press enter
tar -zxvf Areski_AGI_v1.1.tar.gz
tar -zxvf AreskiCC_UI_v1.1.tar.gz

4) The instructions for installing AreskiCC is not written for people like us.
I comment each step so that it is possible to do for us idiots.
The install file is in /usr/src/areski/Areski_AGI/INSTALL.txt
You open the file by using the vi editor. Type
vi /usr/src/areski/Areski_AGI/INSTALL.txt
(to get out of vi hit Esc and type q! at the : prompt)

I repeat the steps installation guide here with full path related to where the software is downloaded.

4.1 Place the entire content directory into your agi-bin directory.
cp /usr/src/areski/Areski_AGI/areskicc.php /var/lib/asterisk/agi-bin/.
cp -r /usr/src/areski/Areski_AGI/libs_areskcc/phpagi /var/lib/asterisk/agi-bin/.
cp -r /usr/src/areski/Areski_AGI/libs_areskcc/db_php_lib /var/lib/asterisk/agi-bin/.

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

4.3 (step is missing in INSATLL.txt I left it to have the same numbering)


4.4. Copy the sounds files
cp -r /usr/src/areski/Areski_AGI/sounds/* /var/lib/asterisk/sounds/.
You will get a overwrite message. Answer y and hit enter
cp: overwrite `/var/lib/asterisk/sounds/./vm-and.gsm'? y
cp: overwrite `/var/lib/asterisk/sounds/./vm-goodbye.gsm'? y

4.5. Create a Database use DB_areskicc.psql for postgres
a) The database is not started automatically. Start it by typing
/etc/init.d/rhdb start
You should see this output:
Initializing database: [ OK ]
Starting PostgreSQL - Red Hat Edition service: [ OK ]

(==>how to start it at boot time? If someone knows then please insert this important part)
With Redhat usually one would use: chkconfig
Example: chkconfig rhdb on

With Gentoo:
rc-update add servicenamegoeshere default

b) verify that the database is running
Log in as postgres user by typing
su - postgres
you will get this prompt:
-bash-2.05b$
create a database by typing
createdb mydb
you should get this output:
CREATE DATABASE
delete the database by typing
dropdb mydb
You shoud get this output:
DROP DATABASE
type exit to return to root user



c) Install the database from the DB_areskicc.psql file

Try this (and sorry for my english(Gool)):
4.5.1) Add NEW user with username ... (user1 sample)
postgres@asterisk:/etc/asterisk$ createuser -W
4.5.2) Login to any existing database and check is it user added
4.5.2.a) login
postgres@asterisk:/etc/asterisk$ psql -d mydb (where mydb is database from 4.5.b)
4.5.2.b) Check
mydb=# \du
4.5.2.b.1) Sample output:
List of database users
User name | User ID | Attributes

user1 | 100 |
postgres | 1 | superuser, create database
(2 rows)
4.5.3) Ok, user added, now we must set user attributes:
4.5.3.a)mydb=# ALTER USER user1 CREATEDB;
(note, thet symbol ; MUST BE at the end of command)
4.5.3.b) Check user atributes:
mydb=# \du
4.5.3.b.1) Sample output:
List of database users
User name | User ID | Attributes

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

4.5.4) Exit from database
(type "\q")
and create NEW database "areskicc2" for user user1
postgres@asterisk:/etc/asterisk$ psql -d areskicc2 -U user1
4.5.4.1) check is it ok
login to database:
postgres@asterisk:/etc/asterisk$ psql -d areskicc2
type
areskicc2=# \l+
Sample output
List of databases
Name | Owner | Encoding | Description

areskicc2 | user1 | SQL_ASCII |
template1 | postgres | SQL_ASCII | Default template database
(2 rows)
Now exit from DB (type "\q")
4.5.5) Import data from AreskiCC.psql to database areskicc2
psql -d areskicc2 -f /usr/src/areski/AreskiCC.psql
4.5.5.1) check is it ok
psql -d areskicc2
areskicc2=# \dt
Sample output:
List of relations
Schema | Name | Type | Owner

public | call | table | postgres
public | callerid | table | postgres
public | card | table | postgres
public | country | table | postgres
public | countryprefix | table | postgres
public | internationalprefix | table | postgres
public | logpayment | table | postgres
public | logrefill | table | postgres
public | provider | table | postgres
public | providerdestination | table | postgres
public | providerrate | table | postgres
public | reseller | table | postgres
public | resellercard | table | postgres
public | sale | table | postgres
public | tariff | table | postgres
public | tariffrate | table | postgres
public | trunk | table | postgres
public | ui_authen | table | postgres
(18 rows)

4.5.5.2 Now ALL is ok. Try login to You database areskicc2 with your username
(first you must exit from db, type "\q") :)

postgres@asterisk:/etc/asterisk$ psql -d areskicc2 -U user1

If you have errors "cant connect / bad autorisation ...." try edit postgres config file:
root@asterisk:# vi /etc/postgresql/pg_hba.conf
(in my system i'm add string
local areskicc2 user1 trust)
Beware to add this rule as the first one! Otherwise an other rule could be applied and will reject your authentication.
Don't forgot restart postgres daemon after change postgres config:
root@asterisk:/etc/init.d# ./postgresql restart

Now drink some beer (or tea) and GO TO p. 4.6 (:biggrin:)
Regards, Gool.


d) Test that the database is imported
Do a select * from <tablename> �
(==> I�ll write this when I have got info on how to import the database.)

"#> su postgres
%> psql -U chosen_username -W chosen_database -f database_file.sql
"

4.6. Setup your Database into the application
Edit db_php_lib/defines.php files
vi /var/lib/asterisk/agi-bin/db_php_lib/defines.php
The file looks like this:

define ("HOST", "localhost");
define ("PORT", "5432");
define ("USER", "areski");
define ("PASS", "areski");
define ("DBNAME", "areskicc2");
define ("DB_TYPE", "postgres"); // mysql or postgres

define ("FSROOT", "/var/lib/asterisk/agi-bin/");

define ("LIBDIR", FSROOT."db_php_lib/");

define ("LEN_CARDNUMBER", "10"); //lenght of the cardnumber (amount of digits)

Since we are just going to get the thing up and running we leave the file as is.

4.7 Setup the callingcard application into Asterisk
Edit extension.conf (/etc/asterisk/extension.conf)
Add the following link to the appropriate context

; CallingCard application
exten => _X.,1,Answer
exten => _X.,2,Wait,2
exten => _X.,3,DeadAGI,areskicc.php
exten => _X.,4,Wait,2
exten => _X.,5,Hangup
(==>I have not yet figured out where this should go so that AMP is not messed up)

4.8 RELOAD ASTERISK
You do this by typing
asterisk �rvv
On the CLI prompt you type reload
To exit type exit


5 Test it
Dial .. and ...
(==> missing)

6 Installation of the web interface
The web interface is downloaded into /usr/src/areski/AreskiCC_UI
Go there by typing
cd /usr/src/areski/AreskiCC_UI

6.1 Copy the files so that the web server can get to them
Create directory for Aresikicc by typing:
mkdir /var/www/html/areskicc
Copy by typing
cp -r * /var/www/html/areskicc

6.2 Ensure that you have create the Database AreskiCC.psql (for postgres)
We did this is step 5. so we don�t need to do it again.

6.3 Setup your Database into the application
We did not change the file in 4.6 so we can skip this as well.

6.4 Modify php.ini !!
Important step : modify the file php.ini (usually in /etc/... ) and find the line
"register_globals = Off"
and set it at
"register_globals = On"

If you skip this step, you won't see anything except "logout" after the login page, whatever login/password you type in.

6.5 Have fun :D
This part we will not skip.

7. Testing the system
(==> missing)

Created by: terchris, Last modification: Thu 27 of Oct, 2005 (15:00 UTC) by areski
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+