Thursday, November 3, 2011

Install A2Billing on Trixbox

(Anhgolden's Blog)- A2billing hỗ trợ phần quản lý cước cho Asterisk System.
Sưu tầm bài viết hướng dẫn cài đặt như sau:
# mkdir /usr/local/src/a2billing

# cd /usr/local/src/a2billing/

# wget http://www.asterisk2billing.org/downloads/A2Billing_1.6.0.tar.gz

# tar -xzf A2Billing_1.6.0.tar.gz

# mysql -u root -p < DataBase/mysql-5.x/a2billing-createdb-user.sql

# cd /usr/local/src/a2billing/DataBase/mysql-5.x

# bash install-db.sh

===============================================================

Install A2Billing DataBase
-----------------------------

Enter Database Name :
mya2billing
Enter Hostname :
localhost
Enter UserName :
root
Enter Password :
passw0rd
mysql --user=root --password=passw0rd --host=localhost mya2billing

===============================================================

# ln -s /usr/local/src/a2billing/a2billing.conf  /etc/

# vi /etc/a2billing.conf

=====================================================

[database]
hostname = localhost
; port for postgres is 5432 by default
port = 3306
user = a2billinguser
password = a2billing
dbname = mya2billing
; dbtype setting can either be mysql or postgres
dbtype = mysql

=====================================================

# chmod 777 /etc/asterisk

# touch /etc/asterisk/additional_a2billing_iax.conf

# touch /etc/asterisk/additional_a2billing_sip.conf

# echo #include additional_a2billing_sip.conf >> /etc/asterisk/sip.conf

# echo #include additional_a2billing_iax.conf >> /etc/asterisk/iax.conf

# chown -Rf asterisk /etc/asterisk/additional_a2billing_iax.conf

# chown -Rf asterisk /etc/asterisk/additional_a2billing_sip.conf

# cd /usr/local/src/a2billing/addons/sounds/

# bash /usr/local/src/a2billing/addons/sounds/install_a2b_sounds.sh



# vi /etc/asterisk/manager.conf

=====================================================
;
; Asterisk Call Management support
;
[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0

[myasterisk]
secret=mycode
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user

[admin]
secret = amp111
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

#include manager_additional.conf
#include manager_custom.conf

=====================================================

# mkdir -p /usr/share/asterisk/agi-bin

# ln -s /usr/local/src/a2billing/AGI/a2billing.php /usr/share/asterisk/agi-bin/a2billing.php

# ln -s /usr/local/src/a2billing/AGI/lib /usr/share/asterisk/agi-bin/lib

New update
# ln -s /usr/local/src/a2billing/AGI/a2billing.php /var/lib/asterisk/agi-bin/

New update
# ln -s /usr/local/src/a2billing/AGI/a2billing_monitoring.php /var/lib/asterisk/agi-bin/

New update
# ln -s /usr/local/src/a2billing/AGI /var/lib/asterisk/agi-bin/

New update
# chown -R asterisk.asterisk /var/lib/asterisk/agi-bin/

New update
# chown -R asterisk.asterisk /usr/local/src/a2billing

# chmod +x /usr/share/asterisk/agi-bin/a2billing.php

# mkdir /var/www/html/a2billing

# chown asterisk.asterisk /var/www/html/a2billing

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

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

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

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

# chmod 755 /usr/local/src/a2billing/admin/templates_c

# chmod 755 /usr/local/src/a2billing/customer/templates_c

# chmod 755 /usr/local/src/a2billing/agent/templates_c

# chown -Rf asterisk.asterisk /usr/local/src/a2billing/admin/templates_c

# chown -Rf asterisk.asterisk /usr/local/src/a2billing/customer/templates_c

# chown -Rf asterisk.asterisk /usr/local/src/a2billing/agent/templates_c



Direct a browser to the administrative web interface (http://YOURDOMAIN/a2billing/admin) and login as administrator. Default passwords are:


user: root
pass: changepassword



New update
# vi /etc/asterisk/extensions_custom.conf

and add the following contexts at the end

=====================================================

#include extensions_a2billing.conf

=====================================================
create a file extensions_a2billing.conf and put following in it
New update
=====================================================
[a2billing]
; CallingCard application
exten => _X.,1,Answer
exten => _X.,2,Wait(2)
exten => _X.,3,DeadAGI(a2billing.php)
exten => _X.,4,Wait(2)
exten => _X.,5,Hangup

[did]
; CallingCard application
exten => _X.,1,DeadAGI(a2billing.php|1|did)

=====================================================


# vi /etc/crontab

and add following

=====================================================

# update the currency table
0 6 * * * php /usr/local/src/a2billing/Cronjobs/currencies_update_yahoo.php

# manage the monthly services subscription
0 6 1 * * php /usr/local/src/a2billing/Cronjobs/a2billing_subscription_fee.php

# To check account of each Users and send an email if the balance is
less than the user have choice.
0 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_notify_account.php

# this script will browse all the DID that are reserve and check if
the customer need to pay for it
# bill them or warn them per email to know if they want to pay in
order to keep their DIDs
0 2 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_bill_diduse.php

# This script will take care of the recurring service.
0 12 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_process.php

# To generate invoices and for each user.
0 6 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_billing.php

# to proceed the autodialer
*/5 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_autodialer.php

# manage alarms
0 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_alarm.php

=====================================================


I have not tried following but keep it for reference
Call back daemon (only for Call backs)

The call back daemon is responsible of reading from the database the pool of calls stored for call back and trigger those calls periodically. The daemon is written in Python. Install the python-setuptools and use easy_install to install the callback_daemon

# apt-get install python-setuptools python-mysqldb python-psycopg2 python-sqlalchemy

# cd /usr/local/src/a2billing/CallBack

# easy_install callback-daemon-py/dist/callback_daemon-1.0.prod_r1527-py2.5.egg

Install the init.d startup script

# cd /usr/local/src/a2billing/CallBack/callback-daemon-py/callback_daemon/

# cp a2b-callback-daemon.debian  /etc/init.d/a2b-callback-daemon

# chmod +x /etc/init.d/a2b-callback-daemon

Make sure the daemon starts

# update-rc.d a2b-callback-daemon defaults 40 60

If you need to remove the daemon in the future run

# update-rc.d -f a2b-callback-daemon remove

=====================================================
Make files and log:

# mkdir -p /var/lib/a2billing/script
# mkdir -p /var/run/a2billing

# 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

4 comments:

Unknown said...

Bạn ơi cho mình hỏi
Mình đã làm theo hướng dẫn của bạn và đã login được vào a2billing nhưng khi truy cập vào bất cứ mục nào cũng bị "don't access this page"
Mình đã làm lại nhiều lần mà vẫn bị thế..mong bạn giúp mình với

anhgolden said...

Bạn kiểm tra lại chmod và chown các folder và files của A2Billing xem ntn.

Viên Nguyễn said...

Loi nhe:

[root@asterisk11 CallBack]# easy_install callback-daemon-py/dist/callback_daemon-1.0.prod_r1527-py2.5.egg
Processing callback_daemon-1.0.prod_r1527-py2.5.egg
creating /usr/lib/python2.6/site-packages/callback_daemon-1.0.prod_r1527-py2.5.egg
Extracting callback_daemon-1.0.prod_r1527-py2.5.egg to /usr/lib/python2.6/site-packages
Adding callback-daemon 1.0.prod-r1527 to easy-install.pth file
Installing a2b_callback_daemon script to /usr/bin

Installed /usr/lib/python2.6/site-packages/callback_daemon-1.0.prod_r1527-py2.5.egg
Processing dependencies for callback-daemon==1.0.prod-r1527
Searching for callback-daemon==1.0.prod-r1527
Reading http://pypi.python.org/simple/callback-daemon/
Couldn't find index page for 'callback-daemon' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/



No local packages or download links found for callback-daemon==1.0.prod-r1527
error: Could not find suitable distribution for Requirement.parse('callback-daemon==1.0.prod-r1527')

anhgolden said...

Phần bạn đề cập bên trên liên quan đến "No local packages or download links found for callback-daemon". Có thể đường dẫn file đã bị thay đổi cần phải update lại. Tks.

Tuy nhiên, bạn có thể bỏ qua phần Call-back trên A2Billing này.

Post a Comment