Debian - Ubuntu

Start with a clean install (i'm a centos fan so there might be errors in these instructions. Can an experienced Ubuntu/debian admin please check and update these instructions).

= Asterisk =

A simple install will limit the billing and routing options of the server, hiding much of the complexities of this very powerfull billing systems.

This is the best setup for a first server. The advanced install should only be used for larger systems by a competent system administrator.

Before switching to an advanced setup i strongly advice to setup a test server first and play arround for a while to fully understand the complexity and power of the full a2billing system.

Simple install:
cd /var/tmp; wget http://dev.villagetelco.org/debs/villagetelco-server_0.6-2.deb cd /var/tmp; wget http://dev.villagetelco.org/debs/villagetelco-server_0-6-2.deb.md5

md5sum /var/tmp/villagetelco-server_0.6-2_all.deb cat /var/tmp/villagetelco-server_0.6-2_all.deb.md5 Compare the 2 line output, both lines should be exactly the same.

cd /var/tmp/; dpkg -i villagetelco-server_0.6-2_all.deb IMPORTANT Until we create alternative asterisk-config packages, we are making backup copies of the files we overwrite in /etc/asterisk and /usr/share/asterisk/agi-bin We expect a apache2 fresh installation. We are disabling the default website and enabling a new website villagetelco under /etc/apache2/sites-enabled

If it is the first time you install the package you can answer "N" to the question of dropping the databases. If you have installed a previous version answer "y" to the question Do you really want to drop the 'mya2billing a2b_wizard a3glue' database?

This ends the simple install.

Advanced Install
To connect to classic landlines also install the DAHDI drivers and tools.

For digital lines also install libpri and libss7.

To connect to classic landlines your server need special hardware. Visit our friends from ATCOM who helped develop the Mesh Potatos.

http://www.atcom.cn/products_cards.html

At this moment the simple server install option does not support classic landline connections.

Install dependency's

sudo apt-get update sudo apt-get upgrade sudo apt-get install libapache2-mod-php5 php5 php5-common php5-cli \ php5-mysql mysql-server apache2 php5-gd php5-curl php5-mcrypt php-soap php-pear espeak sudo apt-get install build-essential libxml2-dev ncurses-dev

sudo su cd /usr/src wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.8.3.3.tar.gz  tar zxvf asterisk-1.8.3.3.tar.gz   cd asterisk-1.8.3.3/ ./configure make make install make config make samples

= FreePBX =

cd /usr/src wget http://mirror.freepbx.org/freepbx-2.9.0.tar.gz tar zxvf freepbx-2.9.0.tar.gz  cd /freepbx-2.9.0 /.start_asterisk start /.install_amp

= A2Billing =

A2billing requires the packages of a LAMP (PHP5) installation. To install the necessary packages, run the following commands: apt-get install libapache2-mod-php5 php5 php5-common apt-get install php5-cli php5-mysql mysql-server apache2 php5-gd apt-get install openssh-server subversion

A2Billing also requires MCrypt module for PHP5 apt-get install php5-mcrypt

Extra software to support text-to-speech IVR monitoring

Cepstral is commercial software and requires a payed license

Version 1.7.1 includes a new AGI mode that allows the monitoring of the a2billing system via an IVR.

The new monitoring feature requires text-to-speech TTS support, the default TTS engine is Cepstral http://www.cepstral.com/ although a2billing can support Festival too.

Install Cepstral (default path: /opt/swift) and make a symbolic link: ln -s /opt/swift/bin/swift /usr/bin/swift

Make sure that the dynamic libraries are linked, create a file called cepstral.conf under /etc/ld.so.conf.d/ including the path: /opt/swift/lib

Do not forget to register your voice!

Installation

Download and unpack source code

Create a a2billing folder under /usr/local/src mkdir /usr/local/src/a2billing

Unpack the code

Download the code from the SVN repository run: svn co --username guest --password guest http://svn.a2billing.net/svn/asterisk2billing/tags/1-current /usr/local/src/a2billing/

Prepare the Database

We will now create a MySQL database (mya2billing) for the billing software. The file a2billing-createdb-user.sql includes a script that creates the database with the correct access control users and permissions. cd /usr/local/src/a2billing mysql -u root -p < DataBase/mysql-5.x/a2billing-createdb-user.sql

The script with create a database, username and password with the following default values Database name is: mya2billing Database user is: a2billinguser User password is: a2billing

After creating the database structure, we will create a set of tables and insert some initial basic configuration data mysql -u root -p mya2billing < DataBase/mysql-5.x/a2billing-schema-v1.7.0.sql mysql -u root -p mya2billing < UPDATE-a2billing-v1.7.0-to-v1.7.1.sql Checkpoint 1: Check that the database (my2billing) and that (97) tables have been created. mysql -u root -p mya2billing mysql>show tables mysql>exit

Edit the a2billing.conf configuration file

The A2Billing configuration file (a2billing.conf) contains the basic information to connect to the a2billing database. Copy or make a symbolic link from

/usr/local/src/a2billing/a2billing.conf to /etc/a2billing.conf

a2billing.conf -> /usr/local/src/asterisk2billing/a2billing.conf

Option 1 cp /usr/local/src/a2billing/a2billing.conf /etc/

Option 2 ln -s /usr/local/src/asterisk2billing/a2billing.conf /etc/a2billing.conf

Open the file with your favorite text editor (vi is used in this example). If you are new to Linux, we recommend you to use the text editor Gedit. vi /etc/a2billing.conf

The only parameters that you need to change here is the database connection information, an example follows: [database] hostname = localhost port = 3306 user = a2billinguser password = a2billing dbname = mya2billing dbtype = mysql

Fix permissions, files and folders

In this step, we will tweak the file permissions of Asterisk to fit the A2Billing software. We will also create a number of additional files and folders that A2Billing needs, which does not come with the default installation.

SIP and IAX

First we will set a few file permissions (chmod, chown) and create (touch) the SIP and IAX configuration files for Asterisk. 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 www-data /etc/asterisk/additional_a2billing_iax.conf chown -Rf www-data /etc/asterisk/additional_a2billing_sip.conf

Sound files

Run the sounds installation script available in the addons folder (IMPORTANT: the script assumes that asterisk sounds are under /usr/share/asterisk/sounds/) /usr/local/src/a2billing/addons/install_a2b_sounds_deb.sh chown -R asterisk:asterisk /usr/share/asterisk/sounds/

Configure Asterisk Manager

Configure the Asterisk Manager by editing the manager.conf file. vi /etc/asterisk/manager.conf

Notice that we are using the default values (myasterisk, mycode) in this section. The configuration should look like this [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

Install The AGI components

Copy or create a symbolic link of the entire content of the AGI directory into asterisk agi-bin directory. mkdir /usr/share/asterisk/agi-bin chown asterisk:asterisk /usr/share/asterisk/agi-bin

Option 1 cd /usr/local/src/a2billing/AGI cp a2billing.php /usr/share/asterisk/agi-bin/ cp a2billing-monitoring.php /usr/share/asterisk/agi-bin/ cp -Rf lib /usr/share/asterisk/agi-bin/

Option 2 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

Make sure the scripts are executable chmod +x /usr/share/asterisk/agi-bin/a2billing.php chmod +x /usr/share/asterisk/agi-bin/a2billing_monitoring.php

Install web-based Graphical interfaces

In this step, we will install the three graphical interfaces of A2Billing: the Administration (admin), Agent (agent) and Customer (customer) interface. As in previous steps you can copy the folders of make symbolic links.

Place the directories "admin" and "customer" into your webserver document root.

Create a2billing folder in your web root folder mkdir /var/www/a2billing chown www-data:www-data /var/www/a2billing Create folder directory for monitoring Scripts mkdir -p /var/lib/a2billing/script

Create folder directory for Cronts PID mkdir -p /var/run/a2billing

Option 1 cp -rf /usr/local/src/a2billing/admin /var/www/a2billing cp -rf /usr/local/src/a2billing/agent /var/www/a2billing cp -rf /usr/local/src/a2billing/customer /var/www/a2billing cp -rf /usr/local/src/a2billing/common /var/www/a2billing

Option 2 ln -s /usr/local/src/a2billing/admin /var/www/a2billing/admin ln -s /usr/local/src/a2billing/agent /var/www/a2billing/agent ln -s /usr/local/src/a2billing/customer /var/www/a2billing/customer ln -s /usr/local/src/a2billing/common /var/www/a2billing/common

Fix the permissions of the templates_c folder in each of the UI 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 www-data:www-data /usr/local/src/a2billing/admin/templates_c chown -Rf www-data:www-data /usr/local/src/a2billing/customer/templates_c chown -Rf www-data:www-data /usr/local/src/a2billing/agent/templates_c

Checkpoint 2: Direct a browser to the administrative web interface (http:///a2billing/admin) and login as administrator. Default passwords are: user: root pass: changepassword

Create a dialplan for A2Billing

The extensions.conf is the Asterisk dialplan. Calls that interact with the billing software need to be handled inside of one or many A2Billing related contexts.

The calls that reach the context are processed using the a2billing.php AGI script. The a2billing.php script can be invoked in many different modes (standard, did, voucher, callback, etc). In the example, we create two different contexts, the first context [a2billing] handles all the calls from our VoIP clients. When a call arrives, any extension number _X. (2 digits or more) reaches the script a2billing.php

The second context [did], will be used to route inward calls back to the users. Calls to the clients (DID) are handled inside of the [did] context. The script a2billing.php in did mode is responsible of routing the call back to one of our users.

Edit extension.conf vi /etc/asterisk/extensions.conf

and the following contexts

[a2billing] include => a2billing_callingcard include => a2billing_monitoring include => a2billing_voucher

[a2billing_callingcard] ; CallingCard application exten => _XXXX.,1,Answer exten => _XXXX.,2,Wait,2 exten => _XXXX.,3,DeadAGI,a2billing.php exten => _XXXX.,4,Wait,2 exten => _XXXX.,5,Hangup

[a2billing_monitoring] ; Monitoring IVR application exten => 100,1,Answer exten => 100,2,Wait,2 exten => 100,3,DeadAGI,a2billing_monitoring.php exten => 100,4,Wait,2 exten => 100,5,Hangup

[a2billing_voucher] exten => 101,1,Answer exten => 101,2,Wait,2 exten => 101,3,DeadAGI(a2billing.php|1|voucher) exten => 101,4,Wait,2 exten => 101,5,Hangup

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

Configure recurring services

Recurring services are handled via the /etc/crontab

You can add the following cron jobs to your /etc/crontab or create a file with the jobs in /var/spool/cron/a2billing # 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 inorder 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 #Generate Invoices at 6am everyday 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

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

Enable Monitoring

General system monitoring via IVR is available from version 1.7, the new AGI a2billing_monitoring.php provides access to an IVR where monitoring tasks can be configured via the new Monitoring Menu under Maintenance.

SQL queries can be performed and shell scripts can be invoked. Place your scripts under /var/lib/a2billing/script/

Security features via IVR (Monitor account and locking calling card)

Two new IVR menus are now available via the main a2billing.php AGI. The menus needs to be enabled setting the variables in the agi-conf menu (GUI system settings)

Locking Options IVR menu ivr_enable_locking_option = true (default: false)

Monitoring your Calling Card IVR menu ivr_enable_account_information = true (default: false)

= Afrimesh =

sudo apt-add-repository ppa:afrimesh/ppa sudo apt-get install afrimesh-dashboard

= SPUD = 1. Install dependencies apt-get install apache2 php5 mysql-server php5-mysql subversion 2. Get the code cd /var/www svn co http://dev.villagetelco.org/svn/villagetelco/spud/trunk spud 3. Database

a) Create a new database mysqladmin -u root -p create spud b) Edit SPUD database settings

vi /var/www/spud/app/config/database.php

var $default = array(		'driver' => 'mysql',		'persistent' => false,		'host' => 'localhost',		'login' => 'root',		'password' => ,		'database' => 'spud',		'prefix' => ,	);

c) Create database schema> cd /var/www/spud/app/install  mysql -u root spud -p < spud_db_schema.sql 4. Change file permission  cd /var/www/spud/app/  chown -Rf www-data.www-data tmp/ 5. Enable Apache rewrite module  cd /etc/apache2  a2enmod rewrite 6. Edit Apache2 000-default file vi /etc/apache2/sites-enabled/000-default

Options Indexes FollowSymLinks MultiViews AllowOverride All Restart Apache /etc/init.d/apache2 restart 7. Configure VIS server

a) Set the IP address/domain name of your webserver. Default value is 127.0.0.1

b) Set the IP addres of your VIS server. The default settings will point to the Bo Kaap VIS server.

c) Configure the vis mode. SPUD supports two VIS modes ('mode' => 'batman') and ('mode' => 'batman-adv') depending if you run your mesh protocol in L3 or L2

d) Configure the vis_version. If you run a L3 mesh network you need also to define the vis_version variable. The legacy value supports the broken JSON output of some old implementations. Recent L3 VIS servers should be set up as vis_version: trunk vi /var/www/spud/app/config/config.php

$config['SPUD']= array(              'host'     => '127.0.0.1'               ); $config['VIS']= array(                                                                 'host'     => '41.223.35.110',               'port'     => '2015',               'timeout'  => '30'   	       'vis_version' => 'legacy',	       'mode' => 'batman',               );

8. Add VIS update to cronjob

a) Open cronjob editor

crontab -e

b) Add the follwing line

*/5 * * * * root /usr/bin/wget -O - -q -t 1 http://localhost/spud/nodes/update >/dev/null 2>&1

9. Get started with SPUD

Navigate to SPUD: http://localhostname_or_ip/spud