Manual for installing version 1.2.X

Table of contents:

0. Installation security

1. System Requirements

2. Installing Ioncube

3. Installing the basic Pbxunit system and the "Call Records" report

4. Installing the "Autocall" module

5. Installing the "Automatic Polls" module

6. Installing the "Text to speech" module

 

0. Installation security

After installation, change the admin user password in the pbxunit web interface, and also check the API key in the web-interface configuration file, the value of the variable $_AST_CONFIG['APIKey'] = 'your key'; must be unique or starting from version 1.2.10 - may be empty.

 

1. System Requirements

OS: Linux (Python 2.X, MySQL or MariaDB database, Apache web server and PHP5)

Asterisk: version from 1.8 to the latest version

FreePBX: version from 2.10, to the latest version

Before setting up Pbxunit, you must have installed and configured Asterisk and FreePBX.

FreePBX modules must be installed: Recordings, IVR, Queues

Tested on: FreePBX v12, FreePBX v13, FreePBX v14

Tested on distributions: FreePBX Distro SNG7-FPBX-64bit, FreePBX Distro 10.13.66-64bit, Debian 8

 

2. The project is protected by Ioncube, you need to install the loader for the Apache web server

Download the Ioncube loader for your operating system by following the link: https://www.ioncube.com/loaders.php

For example:

wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

 

Extract the archive, for example:

mkdir /usr/local/lib/php5

tar xvf ioncube_loaders_lin_x86-64.tar.gz -C /usr/local/lib/php5

 

In order to learn the version of PHP, run the following command in the operating system:

php -v

 

Open the php.ini configuration file

Example for FreePBX Distro:

nano /etc/php.ini

Example for Debian Linux:

nano /etc/php5/apache2/php.ini

Add a line to the [PHP] section, specify the module for your version of php, an example for PHP version 5.6:

zend_extension = /usr/local/lib/php5/ioncube/ioncube_loader_lin_5.6.so

 

Restart the web server

Example for FreePBX Distro:

service httpd restart

Example for Debian Linux:

service apache2 restart

 

Make sure that the module is loaded and appeared in the list:

php -v

 

3. Installing the basic Pbxunit system and the "Call Records" report

Log in as root to the shell of your OS.

 

Go to your home directory and create a directory for the installation files:

cd ~

mkdir src

cd src

 

Download the archive with the latest version of Pbxunit:

wget https://pbxunit.com/downloads/pbxunit-last.tar.gz

 

Unzip the archive:

tar xvf pbxunit-last.tar.gz

 

Find out the user name and password of the MySQL database, which has rights to the asterisk and asteriskcdrdb databases. This is the root user or user established for FreePBX.

You can find out the user name and password in the freepbx configuration file:

cat /etc/freepbx.conf

The user name of the database is contained in the variable $amp_conf['AMPDBUSER']

The password is in the variable $amp_conf['AMPDBPASS']

 

Go to the database directory from the unpacked archive. Enter the command to import the tables into the asterisk database:

cd ~/src/pbxunit/database

mysql -u <user_name> -p -D asterisk < asterisk.sql

Enter password.

 

To speed up the work of reports, it is desirable to add the missing indexes to the cdr table, for the asteriskcdrdb database. Warning - if your system already contains a large amount of statistics, in the cdr table, the addition of indexes can permanently block the table, run the command with the stopped Asterisk service.

Enter the command to create indexes in the database asteriskcdrdb:

mysql -u <user_name> -p -D asteriskcdrdb < asteriskcdrdb_indexes.sql

Enter password.

 

Go to the web directory, from the unpacked archive. Copy the pbxunit directory to the web server directory:

cd ~/src/pbxunit/web

cp -r pbxunit/ /var/www/html/

 

Edit the Pbxunit configuration file:

nano /var/www/html/pbxunit/config.php

 

Enter the requisites from the MySQL database:

For the asterisk database, an example:

$_AST_CONFIG['DBAddr'] = 'localhost';

$_AST_CONFIG['DBPort'] = 3306;

$_AST_CONFIG['DBName'] = 'asterisk';

$_AST_CONFIG['DBUser'] = 'freepbxuser';

$_AST_CONFIG['DBPass'] = 'password';

For asteriskcdrdb, for example:

$_AST_CONFIG['DBAddrCDR'] = 'localhost';

$_AST_CONFIG['DBPortCDR'] = 3306;

$_AST_CONFIG['DBNameCDR'] = 'asteriskcdrdb';

$_AST_CONFIG['DBUserCDR'] = 'freepbxuser';

$_AST_CONFIG['DBPassCDR'] = 'password';

 

Login and password of the database you can see in the configuration file FreePBX:

cat /etc/freepbx.conf

 

Full description of the configuration file: Web-interface configuration file

 

If you want to listen records via flash-player, you need to create a symbolic link in the pbxuint web-directory with the name monitor:

cd /var/www/html/pbxunit/

ln -s /var/spool/asterisk/monitor monitor

Attention, by default, you will be allowed to view all files of call records in the web directory to prohibit browsing the directory, create a .htaccess file in the monitor directory:

cd /var/spool/asterisk/monitor

nano .htaccess

Insert content: Options All -Indexes

 

Now you can log in as an Administrator in the web interface at:

http://<IP-address server>/pbxunit/

Default login: admin password: pbxunit

 

In the section "Administration -> Modules and licenses -> Edit company name" enter your company name and save.

 

4. Installing the "Autocall" module

Check the version of Python in your OS.

The Pbxunit system works with Python version 2.X

python -V

 

Install the Python library to work with MySQL..

Example for FreePBX Distro:

yum install MySQL-python

Example for Debian Linux:

apt-get install python-mysqldb

 

Install the pyst2 library for Python:

Examples for installing via the pip package manager for Python

Install the package manager pip.

Example for FreePBX Distro:

yum install python2-pip

Example for Debian Linux:

apt-get install python-pip

Install the pyst2 library:

pip install 'pyst2'==0.5.0

 

Go to the Pbxunit installation directory:

cd ~/src/pbxunit

 

Copy the directory with the configuration file to / etc:

cp -r configs/pbxunit /etc/

Edit the configuration file:

nano /etc/pbxunit/pbxunit.conf

In the [mysql] section, specify the MySQL user that has the rights to the asterisk and asteriskcdrdb databases, for example:

db_user=freepbxuser

db_pass=password

In the [ami] section, specify the credentials from admin for the Asterisk Manager Interface, you can see it in the config /etc/asterisk/manager.conf, for example:

user=admin

pass=amipassword

For FreePBX version 13 and higher, specify the path for the directory with audio files in the [path] section along with the language code, for example, for the English language:

sounds=/var/lib/asterisk/sounds/en

For versions of FreePBX under 13, leave the default:

sounds=/var/lib/asterisk/sounds

 

Full description of the configuration file: Service configuration file

 

Copy the Python libraries to the python library directory of your version, an example for the version of python 2.7

Example for FreePBX Distro:

cp -r python-lib/pbxunit/ /usr/lib/python2.7/site-packages/

Example for Debian Linux:

cp -r python-lib/pbxunit/ /usr/lib/python2.7/

 

Go to the modules/autocall/ directory from the installation archive:

cd ~/src/pbxunit/modules/autocall

 

Enter the command for additional fields in the cdr table from the asteriskcdrdb DB:

mysql -u <user_name> -p -D asteriskcdrdb < database/asteriskcdrdb.sql

Enter password.

 

Files from the modules/autocall/agi-bin directory can be copied to the Asterisk agi-bin directory:

cp agi-bin/* /var/lib/asterisk/agi-bin/

The service startup files from modules/init.d an be copied to the /etc/init.d directory:

cp init.d/* /etc/init.d/

Make the files executable:

chmod a+x /etc/init.d/pbxu_*

 

Copy the contents of the dialplan/extensions_custom.conf to /etc/asterisk/extensions_custom.conf

In the [pbxu-autocall-dial] section, change the channel language to the required one, for example:

exten => _.,n,Set(CHANNEL(language)=en)

In the [macro-pbxu-autocall] section, you can disable CDR statistics recording when auto-dialing, to this uncomment the line

#exten => s,n,NoCDR()

If you turn off the CDR record, the "Duration" field will not be displayed in the reports.

 

Reload the Asterisk dial plan:

asterisk -x 'dialplan reload'

 

Add services to startup, for example:

nano /etc/rc.local

Add the following lines:

/etc/init.d/pbxu_queue_autocall.py restart

/etc/init.d/pbxu_start_autocall.py restart

For FreePBX Distro, set execute rights to rc.local:

chmod a+x /etc/rc.d/rc.local

 

Run the command to change the access rights to scripts:

fwconsole chown

 

Start the services:

/etc/init.d/pbxu_queue_autocall.py start

/etc/init.d/pbxu_start_autocall.py start

 

To import large files with jobs, you may need to edit the php.ini file on your OS.

Increase download limit up to 50 MB:

post_max_size = 50M

After the changes in php.ini - restart the web server.

 

5. Installing the "Automatic Polls" module

Beforehand, you must have the "Autocall" module installed.

 

Go to the modules/autopolls/ directory from the installation archive:

cd ~/src/pbxunit/modules/autopolls

 

Files from the autopolls/agi-bin directory can be copied to the Asterisk agi-bin directory:

cp agi-bin/* /var/lib/asterisk/agi-bin/

 

Copy the contents of the dialplan/extensions_custom.conf file to  /etc/asterisk/extensions_custom.conf

 

Reload the Asterisk dial plan:

asterisk -x 'dialplan reload'

 

Run the command to change the access rights to scripts:

fwconsole chown

 

6. Installing the "Text to speech" module

Required python libraries:

for Google TTS - gTTs (https://github.com/pndurette/gTTS)

for Amazon Polly - boto3 (https://github.com/boto/boto3)

 

For work, in your OS the application mpg123 must be installed - for converting files. The executable file must be on the path: /usr/bin/mpg123

 

Examples for installing via the pip package manager for Python

Install the package manager pip.

Example for FreePBX Distro:

yum install python2-pip

Update pip:

pip install pip --upgrade

Install the requests library with SSL support:

pip install 'requests[security]'

Install the python library gTTs for Google TTS:

pip install bs4

pip install gtts-token

pip install gTTs

The latest gTTs are incorrectly installed via pip and the built-in installer. Download the archive from https://pypi.org/project/gTTS/#files and copy the library manually:

cp -r gTTS-2.0.3/gtts/ /usr/lib/python2.7/site-packages/

It is also necessary to update the gtts-token package in a timely manner, since system access key google services may change:

pip install gtts-token --upgrade

 

Install the python library boto3 for Amazon Polly:

pip install boto3

 

Install the conversion package from ogg format for Yandex Cloud Speechkit:

The utility should be located along the path: /usr/bin/avconv

Example for Debian Linux:

apt-get install libav-tools