Asterisk for Raspberry Pi on Raspbian

From KlavoWiki
Jump to navigationJump to search

This Document is deprecated. Refer to Asterisk Install on Debian

If you don't want to follow these instructions and would prefer to download an image you can do so by downloading the image from Asterisk for Raspberry Pi Image.

The following instructions are based on Raspbian (2013-12-20-wheezy-raspbian.zip)

Write Image to SD Card

Using Win32DiskImager and the latest version of Raspbian from Raspberry Pi write the image to the SD card.

Once the image is written insert the SD card into the Raspberry Pi and boot. The device will get an IP address from DHCP.

Update and Configure the OS

Log into the operating system with the default username and password.

Username : pi
Password : raspberry

Run raspi-config and configure all requires settings.

sudo raspi-config

If you have not already done so from raspi-config update the operating system by running:

sudo apt-get update
sudo apt-get upgrade

Set required IP Address

Static_IP_Address_for_Raspbian

Create ll alias

Add the following line

alias ll="ls -la --color --group-directories-first --time-style=\"+%Y-%m-%d %H:%M\""

to the file /home/pi/.profile

reboot

sudo reboot

Install Utilities and Prerequisites

The following packages are for Asterisk dependencies and utilities to mange the operating system and packages.

sudo apt-get -y install vim mlocate zip unzip gcc make hgsvn libssl-dev libtiff4-dev \
libsqlite3-dev subversion mysql-server libmysqlclient-dev libmysqlclient18 libnewt-dev \
libuuid1 libxslt1-dev liburiparser1 libncurses5-dev libjansson-dev libogg-dev libspandsp-dev \
libjansson4 uuid-dev libxml2 mime-construct sendmail

cd /usr/src
sudo wget http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
sudo tar xvf speex-1.2rc1.tar.gz
sudo rm -f speex-1.2rc1.tar.gz

cd speex-1.2rc1
sudo ./configure
sudo make
sudo make install

Asterisk

cd /usr/src
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-12-current.tar.gz
sudo tar xvf asterisk-12-current.tar.gz
cd asterisk-12......

sudo ./contrib/scripts/get_mp3_source.sh
sudo ./configure
sudo make menuselect

sudo make
sudo make install
sudo make samples
sudo make config

sudo ldconfig


logrotate

sudo vi /etc/logrotate.d/asterisk

add the following lines to the file

/var/log/asterisk/messages /var/log/asterisk/*log {
   missingok
   notifempty
   rotate 12
   weekly
   create 0640 root root
   postrotate
       /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
   endscript
}

logger

sudo vi /etc/asterisk/logger.conf

change from:

;dateformat=%F %T

to

dateformat=%F %T %Z

Verbosity

sudo vi /etc/asterisk/asterisk.conf

change

;verbose = 3

to

verbose = 3

CDR

Send all CDR records to a MySQL database.

Create Database

sudo mysql
create database asterisk;
use asterisk;

CREATE TABLE cdr (
  sequence int(10) unsigned NOT NULL AUTO_INCREMENT,
  start datetime NOT NULL default '0000-00-00 00:00:00',
  calldate datetime NOT NULL default '0000-00-00 00:00:00',
  clid varchar(80) NOT NULL default '',
  src varchar(80) NOT NULL default '',
  dst varchar(80) NOT NULL default '',
  dcontext varchar(80) NOT NULL default '',
  channel varchar(80) NOT NULL default '',
  dstchannel varchar(80) NOT NULL default '',
  lastapp varchar(80) NOT NULL default '',
  lastdata varchar(80) NOT NULL default '',
  duration int(11) NOT NULL default '0',
  billsec int(11) NOT NULL default '0',
  disposition varchar(45) NOT NULL default '',
  amaflags int(11) NOT NULL default '0',
  accountcode varchar(20) NOT NULL default '',
  uniqueid varchar(32) NOT NULL default '',
  userfield varchar(255) NOT NULL default '',
  PRIMARY KEY (sequence)
);

GRANT ALL ON *.* to cdruser@localhost identified by 'letmein';
flush privileges;

Confg Asterisk

sudo vi /etc/asterisk/cdr_mysql.conf

Edit the global settings

[global]
hostname=localhost
dbname=asterisk
table=cdr
password=letmein
user=cdruser

Fax2Mail

Install Script

sudo wget http://klaverstyn.com.au/david/asterisk/files/fax2mail -O /usr/sbin/fax2mail
sudo chmod +x /usr/sbin/fax2mail
sudo mkdir /var/log/asterisk/faxlog

Default Address

Create a default email address for fax delivery

sudo vi /usr/sbin/fax2mail

On line 99 make the required change

DEFAULTTO="myemail@mydomain.com"

Apache Install

sudo apt-get -y install apache2 php5 libapache2-mod-php5 php5-gd php5-mysql
sudo service apache2 restart

aCDR

cd /var/www
sudo wget www.acdr.com.au/download/aCDR-Lv1.0.zip
sudo unzip aCDR-Lv1.0.zip
sudo rm -f aCDR-Lv1.0.zip

Edit config file

sudo vi /var/www/cdr/config/config.php
<?php
            $db="asterisk";
            $tbl="cdr";
            $ser="localhost";
            $user="cdruser";
            $pwd="letmein";
            $grap="1";
            $rp="22";
            $clm="calldate clid src dst channel dstchannel duration billsec disposition";
            ?>