Installing Asterisk 14 in Armbian with pjsip, dahdi, libpri, mp3, xmpp

Done using the following armbian image

Armbian_5.25_Bananapi_Debian_jessie_next_4.9.7

Start

dd bs=4M if=./Armbian_5.25_Bananapi_Debian_jessie_next_4.9.7.img of=/dev/sdd & sync

After boot, login > root: 1234

Redefine password and create sudo user.

My quiqk personalization

Set alias and color lists

vi /root/.bashrc

Install munin

apt-get update
apt-get install munin-node
vi /etc/munin/munin-node.conf

add

allow ^192\.168\.\d{1,3}\.\d{1,3}$

The restart and check

systemctl restart munin-node
systemctl status munin-node

Assign an ip alias

vi /etc/network/interfaces

Add

# static alias
 auto eth0:0
 allow-hotplug eth0:0
 iface eth0:0 inet static
 address 192.168.0.10
 netmask 255.255.255.0

reboot

Configure timezone

dpkg-reconfigure tzdata

Upgrade the apt list, but dont do an apt-get upgrade for now

apt-get update

Need to install some dependencies

apt-get install build-essential openssl libxml2-dev libncurses5-dev install libcurl4-gnutls-dev libcurl4-openssl-dev uuid-dev sqlite3 libsqlite3-dev pkg-config libjansson-dev libssl-dev libnewt-dev binutils-dev doxygen freetds-dev libasound2-dev libbluetooth-dev libc-client2007e-dev libcorosync-dev libjack-dev libedit-dev libgsm1-dev libgtk2.0-dev libical-dev libiksemel-dev libldap2-dev liblua5.1-0-dev libmysqlclient-dev libneon27-dev libogg-dev libpopt-dev libpq-dev libresample1-dev libsnmp-dev libspandsp-dev libspeex-dev libspeexdsp-dev libsqlite0-dev libsrtp0-dev libvorbis-dev libvpb-dev libxslt1-dev lua5.1 portaudio19-dev python-dev unixodbc-dev libgmime-2.6-0 libgmime-2.6-dev libgmime2.6-cil libgmime2.6-cil-dev uuid

Some extra dependencies.

mp3

apt-get install subversion

iksmel

apt-get install libtool-bin
apt-get install texinfo

The user local source directory

cd /usr/local/src/

Install dahdi-linux and dahdi-tools

# get back to our source root
cd /usr/local/src/

#start
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
tar -xzf dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-2.11.1+2.11.1/

# handle each folder separately (linux first)
cd linux
make
make install

# handle each folder separately (tools last)
# this Makefile have a problem runing pod2man
# we need to generate the man files one by one
# let start
cd ../tools
./configure
# next we need to generate the files
cd xpp
/usr/bin/pod2man --section 8 dahdi_registration > dahdi_registration.8
/usr/bin/pod2man --section 8 lsdahdi >lsdahdi.8
/usr/bin/pod2man --section 8 xpp_blink > xpp_blink.8
/usr/bin/pod2man --section 8 dahdi_genconf > dahdi_genconf.8
/usr/bin/pod2man --section 8 dahdi_hardware > dahdi_hardware.8
/usr/bin/pod2man --section 8 twinstar > twinstar.8
/usr/bin/pod2man --section 8 xpp_sync > xpp_sync.8
cd ..
make
make install
cd ..
make config

I believe that it can be done this way, need to test it.

# get back to our source root
cd /usr/local/src/

#start
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
tar -xzf dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-2.11.1+2.11.1/

# handle the tools folder separately 
# Is Makefile appears to have a problem runing pod2man
# we need to generate the man files one by one
# let start

cd ../tools
./configure

# next we need to generate the files

cd xpp
/usr/bin/pod2man --section 8 dahdi_registration > dahdi_registration.8
/usr/bin/pod2man --section 8 lsdahdi >lsdahdi.8
/usr/bin/pod2man --section 8 xpp_blink > xpp_blink.8
/usr/bin/pod2man --section 8 dahdi_genconf > dahdi_genconf.8
/usr/bin/pod2man --section 8 dahdi_hardware > dahdi_hardware.8
/usr/bin/pod2man --section 8 twinstar > twinstar.8
/usr/bin/pod2man --section 8 xpp_sync > xpp_sync.8

# go to base directory
cd .../..
make
make install
make config

Install libpri

# get back to our source root
cd /usr/local/src/

#start
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
tar -xzf libpri-current.tar.gz
cd libpri-1.6.0/
make
make install

Install iksemel

# get back to our source root
cd /usr/local/src/

#start
wget https://github.com/meduketto/iksemel/archive/master.zip
mv master.zip iksemel.zip
unzip iksemel.zip
cd iksemel-master/
./autogen.sh
./configure
make
make install

Install jansson

cd /usr/local/src/

#start
wget http://www.digip.org/jansson/releases/jansson-2.10.tar.gz
tar -xzf jansson-2.10.tar.gz
cd jansson-2.10/
./configure
make
make install

Install Asterisk

cd /usr/local/src/

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14.4.0.tar.gz
tar -xzf asterisk-14.4.0.tar.gz
cd asterisk-14.4.0/

# to use mp3 format
contrib/scripts/get_mp3_source.sh

./configure --with-pjproject-bundled
make menuselect
make
make install
make configq
make samples

Start asterisk

/etc/init.d/asterisk start

Connect to asterisk

asterisk -rvvvv

show modules

module show

Install chan_dongle

cd /usr/local/src/

wget https://github.com/wdoekes/asterisk-chan-dongle/archive/master.zip
mv master.zip chan_dongle.zip
unzip chan_dongle.zip
cd asterisk-chan-dongle-master

./bootstrap
./configure --with-astversion=14
make
cp chan_dongle.so /usr/lib/asterisk/modules
cp etc/dongle.conf /etc/asterisk/

Insert pen

Must be voice unlocked, and not in storage mode

Change device permissions

chmod 666 /dev/ttyUSB1
chmod 666 /dev/ttyUSB2

configure dongle.conf

vi /etc/asterisk/dongle.conf

Connect to asterisk

asterisk -rvvvv

Load chan dongle

module load chan_dongle
dongle show devices

Run as asterisk

Add user

adduser --system --group --home /var/lib/asterisk --no-create-home --gecos "Asterisk PBX" asterisk

Change owner and permission

chown -R asterisk:asterisk /var/lib/asterisk
 chown -R asterisk:asterisk /var/log/asterisk
 chown -R asterisk:asterisk /var/run/asterisk
 chown -R asterisk:asterisk /var/spool/asterisk
 chown -R asterisk:asterisk /usr/lib/asterisk
 chown -R asterisk:asterisk /etc/asterisk

chmod -R u=rwX,g=rX,o= /var/lib/asterisk
 chmod -R u=rwX,g=rX,o= /var/log/asterisk
 chmod -R u=rwX,g=rX,o= /var/run/asterisk
 chmod -R u=rwX,g=rX,o= /var/spool/asterisk
 chmod -R u=rwX,g=rX,o= /usr/lib/asterisk
 chmod -R u=rwX,g=rX,o= /etc/asterisk

vi /etc/asterisk/asterisk.conf

Remove (!) in front of [directories](!)

Installing mysql

apt-get install mariadb-server mariadb-client

(pass: 1234)

Installing Apache2

apt-get install apache2

Installing php

Basic

apt-get install php5 libapache2-mod-php5

php5 modules

apt-get install php5-mysqlnd php5-curl php5-gd php5-json php5-geoip php5-intl php5-mcrypt php5-mysqlnd php5-odbc php5-xmlrpc php5-apcu php5-memcache php5-pspell php5-xsl php5-sqlite

Restart apache

service apache2 restart

Run apache2 as asterisk

vi /etc/apache2/envvars

#export APACHE_RUN_USER=www-data
#export APACHE_RUN_GROUP=www-data
export APACHE_RUN_USER=asterisk
export APACHE_RUN_GROUP=asterisk

Restart apache

Install apache2 mod rewrite

a2enmod rewrite
service apache2 restart

Install freepbx

cd ~
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz
tar vxfz freepbx-13.0-latest.tgz
rm -f freepbx-13.0-latest.tgz
cd freepbx
./start_asterisk start

Asterisk cli

asterisk -rvvv
CLI> quit

Run freePBX installer

./install -n

Configure CDR

Change so for arm

vi /etc/odbcinst.ini
 [MySQL]
 Description = ODBC for MySQL
 Driver = /usr/lib/arm-linux-gnueabihf/odbc/libmyodbc.so
 Setup = /usr/lib/arm-linux-gnueabihf/odbc/libodbcmyS.so
 FileUsage = 1

Change Socket=/var/run/mysql/mysqld.sock to Socket=/var/run/mysqld/mysqld.sock

vi /etc/odbc.ini
 [MySQL-asteriskcdrdb]
 Description=MySQL connection to 'asteriskcdrdb' database
 driver=MySQL
 server=localhost
 database=asteriskcdrdb
 Port=3306
 Socket=/var/run/mysqld/mysqld.sock
 option=3
 Charset=utf8

Define asterisk odbc connector.

I found references to /var/lib/asterisk/.profile but i didn’t found the file but find an .odbc.ini, and use that instead.

vi /var/lib/asterisk/.odbc.ini
 export ODBCINI=/etc/odbc.ini
 export ODBCSYSINI=/etc

Alternatively if the one above not works, add the following lines to file

vi /etc/asterisk/res_odbc_custom.conf
[ENV]
 ODBCSYSINI => /etc
 ODBCINI => /etc/odbc.ini

 

Apache 2 SSL configuration

Create the certificates

mkdir /etc/apache2/ssl
openssl req -x509 -nodes -days 1895 -newkey rsa:2048 -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key

Add the new created certificates to the apache2 config

vi /etc/apache2/sites-available/default-ssl.conf

Add the following lines to configuration file

SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key

Create a symbolic link to sites-enable

ln -s /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/000-default-ssl.conf

Load the ssl module

a2enmod ssl

Activate ssl on site

a2ensite default-ssl

Restart apache

/etc/init.d/apache2 restart

 

Links

https://wiki.freepbx.org/display/FOP/Installing+FreePBX+13+on+Debian+8.1

http://downloads.asterisk.org/pub/telephony/

https://github.com/meduketto/iksemel

http://stackoverflow.com/questions/31760032/asterisk-unable-to-connect-to-database-using-odbc-connector