Вы находитесь на странице: 1из 9

__________________________________________________________

__________________________________________________________
_______________________________________________

1. Installation Prerequisites
1. Install Dependencies
1. get A2Billing
2. Install Database
3. Install the AGI and Sound Files
1. set ownership and permissions on AGI
2. Set up sounds
3. set ownership on sounds
4. Asterisk Manager
5. Install Web Pages
1. Common
2. Admin pages
3. Agent
4. Customer
6. Cronjobs
7. Create Log Files
1. Log files and Permissions
8. Callback
1. Callback Daemon installation Script
9. Dialplan
10. Reboot
11. Login
12. General Setup
13. Guidelines

Installation Prerequisites

It is assumed that you have already installed Asterisk on a suitable


machine. This tutorial does not cover that part of the installation. If you
are unfamiliar with the
install of Asterisk, it may be better to start with a pre-built distribution,
e.g.

PBX in a Flash - www.pbxinaflash.com, or FonicaPABX -


www.fonicaprojects.com may provide a secure base on which to build
A2Billing.

Asterisk Now, Elastix and Trixbox are other possibilities to provide a


base as part of the family of Asterisk / FreePBX / CentOS distributions.
However, the author has
no knowledge of the security measures in place with these
distributions, and indeed, Trixbox do recommend that their system is
secured behind a firewall, so may not be
suitable for connection directly to the Internet without some remedial
work.

Alternatively, Support and Managed Installation and Training services


are available through http://www.star2billing.com

The distributions mentioned are based on Centos, so these instructions


are Centos biased.

These distributions can be installed on a VMWare image for testing if


no hardware is available.

If you have hand-rolled your own distribution, and are familiar with
1.3.4, then the we assume that you have the necessary dependencies
already installed.

Install Dependencies

yum -y install perl-DBD-Pg subversion

get A2Billing
mkdir /usr/local/src/a2billing
cd /usr/local/src/a2billing
svn co --username guest --password guest
http://svn.a2billing.net/svn/asterisk2billing/trunk/ /usr/local/src/a2billing

copy a2billing.conf in /usr/local/src/a2billing/a2billing.conf to


/etc/a2billing.conf

Edit a2billing.conf to suit your installation. e.g. change dbtype to


mysql.

Install Database

Note that for Piaf and FonicaPABX, the database password is


passw0rd and the location is localhost
cd /usr/local/src/a2billing/DataBase/mysql-5.x
./install-db.sh

Answer the questions appropriately with reference to


/etc/a2billing.conf

You should now have a database called mya2billing with over 70


tables in it.

Install the AGI and Sound Files

So that we can easily update the system when changes are made during
this period of change, we are going to use links back to the location
where we installed the SVN
download, so that an update from the SVN will immediately reflect in
your A2Billing install.

Note that Database changes will not be included using this


methodology, so these will have to be done by hand.
This is not the usual way of doing it, but for testing, it works well. You
can also simply move or copy the files into the appropriate location.
ln -s /usr/local/src/a2billing/AGI/a2billing.php /var/lib/asterisk/agi-
bin/a2billing.php

set ownership and permissions on AGI

chown asterisk:asterisk /var/lib/asterisk/agi-bin/a2billing.php


chmod +x /var/lib/asterisk/agi-bin/a2billing.php

Set up sounds

cd /usr/local/src/a2billing/addons/sounds
./install_a2b_sounds.sh

set ownership on sounds

chown -R asterisk:asterisk /var/lib/asterisk/

Asterisk Manager

Now edit /etc/asterisk/manager_custom.conf (or manager.conf for


those not using a pre-rolled distribution including FreePBX). Add the
following lines
[myasterisk]
secret = mycode
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user

Install Web Pages

Assumption is that apache2 root folder is /var/www/html


Common

ln -s /usr/local/src/a2billing/common /var/www/html/a2billing/common

Admin pages

ln -s /usr/local/src/a2billing/admin /var/www/html/a2billing/admin

Agent

ln -s /usr/local/src/a2billing/agent /var/www/html/a2billing/agent

Customer

ln -s /usr/local/src/a2billing/customer /var/www/html/a2billing/customer

Now we need to set permissions for Apache.

If you are using a pre-rolled Distro, then web group and ownership are
asterisk and asterisk, if you are not using a distro, then you probably
know what to set anyway.
chown -R asterisk:asterisk /var/www/html/a2billing/
chown -R asterisk:asterisk /usr/local/src/a2billing/common
chown -R asterisk:asterisk /usr/local/src/a2billing/admin
chown -R asterisk:asterisk /usr/local/src/a2billing/customer
chown -R asterisk:asterisk /usr/local/src/a2billing/agent

Cronjobs

Create folder directory for Cronts PID


#mkdir -p /var/run/a2billing

echo "
# Automatically added for A2Billing
0 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_alarm.php
0 12 * * * php
/usr/local/src/a2billing/Cronjobs/a2billing_archive_data_cront.php
0 10 21 * * php /usr/local/src/a2billing/Cronjobs/a2billing_autorefill.php
#Batch process at 00:20 each day
20 0 * * * php
/usr/local/src/a2billing/Cronjobs/a2billing_batch_process.php
#Bill DID usage at 00:00 each day
0 0 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_bill_diduse.php
#Generate Invoices at 6am everyday
0 6 * * * php
/usr/local/src/a2billing/Cronjobs/a2billing_batch_billing.php
#Check if balance below preset value, and email user if so.
1 * * * * php
/usr/local/src/a2billing/Cronjobs/a2billing_notify_account.php
#Charge subscriptions at 06:05 on the 1st of each month
0 6 1 * * php
/usr/local/src/a2billing/Cronjobs/a2billing_subscription_fee.php
#Update currencies at 01:00 each day
0 1 * * * php
/usr/local/src/a2billing/Cronjobs/currencies_update_yahoo.php
" >> /var/spool/cron/asterisk

Add directory for monitoring Script

mkdir -p /var/lib/a2billing/script

Create Log Files

Log files and Permissions

touch /var/log/asterisk/a2billing-daemon-callback.log
touch /var/log/a2billing-daemon-callback.log
touch /var/log/cront_a2b_alarm.log
touch /var/log/cront_a2b_autorefill.log
touch /var/log/cront_a2b_batch_process.log
touch /var/log/cront_a2b_bill_diduse.log
touch /var/log/cront_a2b_subscription_fee.log
touch /var/log/cront_a2b_currency_update.log
touch /var/log/cront_a2b_invoice.log
touch /var/log/a2billing_paypal.log
touch /var/log/a2billing_epayment.log
touch /var/log/api_ecommerce_request.log
touch /var/log/api_callback_request.log
touch /var/log/a2billing_agi.log

Callback

Here is a little script to install the call-back Daemon. Change the


LOAD_LOC variable to reflect where you have downloaded A2Billing.

Callback Daemon installation Script

LOAD_LOC=/usr/local/src/a2billing

yum -y install python-setuptools.noarch


yum -y install MySQL-python
easy_install sqlalchemy

cd $LOAD_LOC/Callback/callback-daemon-py
cp $LOAD_LOC/CallBack/callback-daemon-
py/build/lib/callback_daemon/a2b-callback-daemon.rc /etc/init.d/a2b-
callback-daemon
chmod +x /etc/init.d/a2b-callback-daemon

cd $LOAD_LOC/CallBack/callback-daemon-py/
python setup.py build
python setup.py bdist_egg
easy_install dist/callback_daemon-1.0.prod_r1528-py2.4.egg
chkconfig --add a2b-callback-daemon
service a2b-callback-daemon start
chkconfig a2b-callback-daemon on

Dialplan

The dialplan you put into Asterisk is the same as it was for A2Billing
1.3.4. I've not got round to writing the dialplan as yet.

Reboot

Login

http://Your-Switch/a2billing

Log into the admin pages with root and changepassword

General Setup

The general setup is similar to 1.3.4, and the order of events is


approximately similar

* Set up trunk * Set up callplan * Setup rate plan * add rate table to
callplan * add rates * add customer * test.

Guidelines

Keep an eye on the development of A2Billing here.

http://www.asterisk2billing.org/cgi-bin/trac.cgi/browser/trunk

Make sure that you are running the latest version before reporting a
bug by periodically running.
Bugs can be dicussed in the bugs section here -
http://forum.asterisk2billing.org/viewforum.php?f=22 before reporting
them on the bug tracker.

Bugs tracking and reporting can be done here:-


http://www.asterisk2billing.org/cgi-bin/trac.cgi/report

Вам также может понравиться