image_alt_text

19

Aug/10

FreePBX – Common Voicemail Box

Thursday, August 19th, 2010

Overview

I have several extensions on my Asterisk / FreePBX box but currently only one landline. Ring groups solved the problem of one incoming call ringing multiple handsets but there was only one official solution to sharing voicemail.

Voicemail Blasting (VMB)

VMB is a way of disseminating incoming voicemail to multiple voicemail boxes. For example someone lease a message on voicemail for one extension. When the person has finished leaving a message, VMB copies that message and puts it into designated extension voicemail boxes for other extensions to receive. The problem with this setup is that the voicemail may be heard from one extension and deleted but it still remains on others.

Symbolic Links To The Rescue

I found a neat trick to fool FreePBX / Asterisk to get multiple voicemail boxes pointing to one. The great point about this is that each extensions keeps most of their settings separate so things like password can be different for each extension but the messages are shared. This means one person can delete the message from one phone and another user will not see the message (maybe except in the trash).

How To

I have FreePBX running on a Ubuntu 10.04 install. First thing is to create all the extensions and enable voicemail on all of them.

Identify the one extension which will be shared amongst all others e.g 200.

Go to /var/spool/asterisk/voicemail/default Check if there’s a folder with the extension number of your designated voicemail. If not leave a message on extension 200 and it should create one.

Remove all other extensions which should share the same inbox as extension 200, e.g 201 and 202 sudo rm -rf 201 and replace 201 with 202 etc.

Switch user to the Asterisk user. This is needed because the original directories were “owned” by the Asterisk user. Once created also ensure the symbolic links have at least the same or more permissions as extension 200 (or the shared voicemail box) sudo su asterisk

Create a symbolic link to 200 with the previously removed folder names ln -s 200 201ln -s 200 202

Summary

This is a cool trick which should be transparent to FreePBX / Asterisk unless they change the way voicemail works. Updates and modules should not see any difference because the symbolic links point to a real directory.

Also it is easy to revert any extension back to having their own voicemail box or even create multiple shared voicemail boxes by removing the sym link and creating a new one to point to another extension directory.

How to make multiple extensions use a common voicemail box

17

Jul/10

Show Nautilus As Text In Ubuntu 10.04

Saturday, July 17th, 2010

In the new Ubuntu the windows manager Nautilus does not change from an icon to a text when you click on the current directory in the bread crumb. To solve this use the shortcut Ctrl + L

27

Jun/10

VNC/RDP Not Refreshing On Ubuntu

Sunday, June 27th, 2010

When I use VNC Client to remote desktop onto my Ubuntu 10.04 I got the background and maybe even the Gnome panel but the windows and programs were not appearing on the screen. However my mouse and clipboard was still working so I had ended up VNC’ing to the box and switching the display to another source.

To fix this problem just disable the visual desktop effects under System > Preferences > Appearance Under the Visual Effects tab set it to None.

VNC – remote desktop does not refresh

11

Jun/10

Linksys SPA3102 And FreePBX On Ubuntu 10.04

Friday, June 11th, 2010

Overview

I wanted to setup a Private Branch eXchange(PBX) system using Asterisk server at home. As I already had a traditional land line (PSTN or POTS line) I needed something to bridge the computer to the land line. My idea of having a PBX at was to route as many calls over VOIP which tends to be cheaper like Skype and still use a traditional landline for emergencies as well as just having a landline number.

History

Originally I started writing a post on how to get a PBX with a web interface going on Ubuntu 8.04. However once I had it all installed it wasn’t working 100%. I had issues with permissions and FreePBX had problems with the operation panel. Fast forward 2-3 years and I’m back doing it again but this time on the next LTS release and 7 minor release later from FreePBX.

Ubuntu 10.04 LTS

Asterisk

Asterisk is a free and open source software for PBX. It’s what you see in companies to manage and route all their phones calls. Asterisk is a PBX engine which has several front end engines and even a distribution specially for PBX box called Trixbox. If you just want a headless PBX then installing Asterix will suffice however I was not technically skilled enough to create all configuration files from scratch and also a nice front end will go a long way for the Wife Acceptance Factor (WAF). This is where FreePBX comes in.

FreePBX

FreePBX is GUI interface wrapper for Asterisk. Ubuntu has a FreePBX package in it’s repository. FreePBX uses a web front end so it can be accessed anywhere and makes administration a lot easier. It uses modules to extend the functionally like add-ons in Firefox. These include group pickup to Parking Lots.

With FreePBX this sorts out the software side of my PBX.

Linksys SPA3102

This an Analogue Telephone Adaptor(ATA) which is used to convert a land line to a digital network and a traditional land line phone to the network too. The hardware has been around for a long time and it does work with Asterisk. The SPA(Sipura)3102 can be used as a standalone PBX box too but in my case it will be used to forward incoming and outgoing calls.

The SPA3102 also has a web interface but it can also be used to act as a router at the same time. The web interface is very basic and not very user friendly but has a lot of options making it very customizable and configurable.

Asterisk And FreePBX Install

Switch to root user before installing sudo su.

Install MySQL sudo apt-get install mysql-server
When prompted for password enter one.

Install MySQL modules, PHP, kernel headers for compiling code, apt-get install build-essential linux-headers-`uname -r` openssh-server bison flex apache2 php5 php5-curl php5-cli php5-mysql php-pear php-db php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient15-dev mpg123 libxml2-dev

Go to /usr/src cd /usr/src/
and download the Asterisk source files

xargs wget << SOURCES

http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/releases/dahdi-linux-complete-2.2.1+2.2.1.tar.gz

http://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-1.4.10.2.tar.gz

http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.2.6.tar.gz

http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.6.2.0.tar.gz

SOURCES

Un-tar(zip) all the source files in /usr/src/ tar xvf dahdi-linux-complete-2.2.1+2.2.1.tar.gz
tar xvf libpri-1.4.10.2.tar.gz
tar xvf asterisk-1.6.2.6.tar.gz
tar xvf asterisk-addons-1.6.2.0.tar.gz

Compile Asterisk in the following order:
cd dahdi-linux-complete-2.2.1+2.2.1
make all && make install && make config
cd ../libpri-1.4.10.2
make && make install
cd ../asterisk-1.6.2.6
./configure
make && make install
make samples
cd ../asterisk-addons-1.6.2.0
./configure
make && make install
make samples
Download and extract extra sounds cd /var/lib/astersik/sounds
wget -O - http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-gsm-current.tar.gz | tar xvfz -

Create an Asterisk user account on the Linux box adduser asterisk --disabled-password --no-create-home --gecos "asterisk PBX user"
adduser www-data asterisk

Make a backup of the Asterisk configuration file cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig

Change the Asterisk config to run as a correct user sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf

Create the Asterisk service script which will start and stop the Asterisk demon:

cat > /etc/init.d/asterisk <<-END_STARTUP
#!/bin/bash
### BEGIN INIT INFO
# Provides: asterisk
# Required-Start: \$network \$syslog
# Required-Stop: \$network \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Asterisk daemon.
# Description: This script handles start/stop states of asterisk.
### END INIT INFO

set -e
set -a
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Asterisk"
NAME=amportal
DAEMON=/usr/sbin/\$NAME

test -x \$DAEMON || exit 0

d_start() {
amportal start
}

d_stop() {
amportal stop
}

d_reload() {
amportal restart
}

case "\$1" in

start)
echo -n "Starting \$DESC: \$NAME"
d_start
echo "."
;;

stop)
echo -n "Stopping \$DESC: \$NAME"
d_stop
echo "."
;;

restart|force-reload)
echo -n "Restarting \$DESC: \$NAME"
d_stop
sleep 10
d_start
echo "."
;;

*)

echo "Usage: \$SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;

esac

exit 0
END_STARTUP

Ensure the permissions of the demon script is correct chmod 755 /etc/init.d/asterisk

Make Asterisk start up when the computer starts update-rc.d asterisk defaults 90 10

Download and extract FreePBX
cd /usr/src/
wget -O - http://mirror.freepbx.org/freepbx-2.7.0.tar.gz | tar xvfz -
cd freepbx-2.7.0/

Copy the Amportal configuration cp amportal.conf /etc/

Set environment variables for the current session. These variables will store the password for MySQL access so that the script can be 100% automated. One is the admin password and the other is the Asterisk database user password. These variables should clear once the terminal session ends but it is advised to remove them from the bash history in ~/.bash_history
export MYSQL_ROOT_PW=abcd
export ASTERISK_DB_PW=wxyz

Run the database scripts:
mysqladmin -u root -p${MYSQL_ROOT_PW} create asterisk
mysqladmin -u root -p${MYSQL_ROOT_PW} create asteriskcdrdb
mysql -u root -p${MYSQL_ROOT_PW} asterisk < SQL/newinstall.sql
mysql -u root -p${MYSQL_ROOT_PW} asteriskcdrdb < SQL/cdr_mysql_table.sql

mysql -u root -p${MYSQL_ROOT_PW} <<-END_PRIVS
GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY "${ASTERISK_DB_PW}";
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY "${ASTERISK_DB_PW}";
flush privileges;
END_PRIVS

Edit the amportal configuration file with the database username and password
sed -i "s/# \(AMPDBUSER=.*\)/\1/" /etc/amportal.conf
sed -i "s/# \(AMPDBPASS=\).*/\1${ASTERISK_DB_PW}/" /etc/amportal.conf
sed -i "s@\(AMPWEBROOT=\).*@\1/var/www/@" /etc/amportal.conf
sed -i "s@\(FOPWEBROOT=\).*@\1/var/www/panel@" /etc/amportal.conf
sed -i "s@\(FOPWEBADDRESS=\).*@PUTIPADDRESS@" /etc/amportal.conf

Change the max PHP file upload size to 120mb in Apache
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini

Change the files and directories so that Asterisk has access to them
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /var/www/

Remove line ending from the Asterisk configuration file.
sed -i '1 s/\(\[directories\]\).*/\1/' /etc/asterisk/asterisk.conf

Start Asterisk
./start_asterisk start

Install FreePBX
./install_amp

Restart Apache server
/etc/init.d/apache2 restart

Create a symlink to the "Music On Hold"(MOH) files
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3

Start FreePBX
amportal start

Asterisk / PBX Terminology

Before I go into configuring the PBX itself it is worth knowing the terminology behind the technology.

  • Extension - Can be considered as an internal phone number. Each extension can be associated with a user and the user and the user can "roam" from phone to phone keeping their phone number.
  • Feature Codes - Special phone numbers which can put an extension to do not disturb (DND) so that no phone calls will get through to accessing voicemail.
  • Trunk - Provides services to the PBX such as land line or to allow calls to another PBX.
  • Routes - The path a call may go. Routes consists of inbound, calls coming in and outbound, calls leaving the system routes.
  • Dial Rules - Rules defined in ASCII characters which govern routes e.g Only free phone numbers are allowed to take the land line route. All other numbers should go out to a VOIP provider.
  • Channels - Number of simultaneous calls a trunk can handle

Configure FreePBX

First thing to do is set up extensions. Extensions are independent to any available routes as by default Asterisk treats any number dialled as an internal number. Below are steps to create 2 extensions. One number will eventually be assigned to the phone attached to the Linksys SPA3102 and the other for another hard/softphone.

  1. Go to Setup > Basic > Extensions menu item.
  2. Ensure "Generic SIP Device" is selected in the Devices drop down box.
  3. Enter the following details:
    1. User Extension - Phone number of extension E.G 1000
    2. Display Name - Friendly name
    3. Voicemail & Directory Status - Enable this if you want the user to have voicemail facilities
    4. Secret - Leave blank for now but this is the password for the extension.
  4. Submit the changes.
  5. Click on the new extension listed on the right hand side of the Extensions page. This will edit the extension
  6. Under Device Options section change the Mailbox by removing the @device suffix and just leave the extension number in the field.
  7. Submit the changes again.
  8. Repeat the steps above again to create a second extension, changing the extension number, display name and the mailbox setting E.G 1001
  9. Apply the changes to make it take effect.

At this point I would download a SIP softphone such as X-Lite on two computers and test out the 2 extensions created. Using the X-Lite or other softphones is beyond this article.

For Dialling out of the Sipura 3102 a Trunk is needed as well as configuring the outbound route.

  1. Go to Setup > Basic > Trunks in FreePBX
  2. Click on the Add SIP Trunk
  3. Fill in the following fields:
    1. Trunk Description - A friendly name for the trunk. This can be anything
    2. Outbound Caller ID - Full telephone number of the landline including area code.
    3. CID Options - Any
    4. Maximum Channels - 1
    5. Dial Rules - Leave blank
    6. Outbound Dial Prefix - Leave blank
    7. Trunk Name - A memorable name which will be used in the Sipura configuration
    8. Peer Details:

      canreinvite=no
      context=from-pstn
      host=[host]
      nat=no
      port=5061
      type=friend
      qualify=yes
      dtmfmode=rfc2833

      Change [host] to the IP address of computer hosting Asterisk / FreePBX and [username] to username to be used by Sipura

    9. Leave the remaining fields blank.
  4. Submit Changes.
  5. Go to Setup > Basic > Outbound Routes
  6. Click on 0 9_outside (or create a new one)
  7. Change the settings to as follows:
    1. All fields should be blank or left as default up to Dial Patterns.
    2. Dial Patterns - 9|.
    3. Trunk Sequence - Select the Trunk created above.
  8. Submit changes.
  9. Apply the changes.

The above setting outbound route requires a 9 to be dialled followed by the number to be dialled. The dial pattern can be changed later.

Create a new inbound route for the landline to Asterisk via SPA3102:

  1. Go to Setup > Inbound Call Control > Inbound Routes
  2. Change the following settings:
    1. Description - A meaningful name for the inbound route
    2. DID Number - Enter the landline telephone number including the area code.
    3. Set Destination - Set where the landline call should go to. This can be voicemail or an extension
  3. Submit changes.
  4. Apply Settings

It is worth mentioning here that there is a module in FreePBX called Ring Group which would allow a group of extensions to be named as a destination. This means anyone in the group will have their phone ring when someone rings the landline.

As a recommended step check if a password has been set on the admin web page. Clear out the browser's cookies and cache. Go to the Freepbx page and click on the FreePBX Administration link it should prompt for a password. If not edit the default admin account or add a new account under Setup > Basic > Administration

Notice there is a warning under "General Settings". This means the authentication has not been turned on. Submit the changes and apply them once completed. Go to the Freepbx box and edit the file /etc/amportal.conf Look for the line AUTHTYPE=none and change it from none to database.

Setting Up SPA3102

Out of the box the ATA is configured to act as a router and has the web interface disabled on the WAN port. I will be putting SPA3102 into an existing network so I need to enable the WAN port and turn off the DHCP. The WAN port needs to be enabled so that it can connect to the local network instead of the box expecting a modem and turning off DHCP will stop two devices assigning an IP to the computers on the network.

Plug a telephone into phone socket of the SPA3102 and the power in the power socket. Pick up the phone and dial ***** (5 asterisks) and then 7932 and then 1. Hang up or press #.

Now plug the network cable into the Internet port of the SPA3102 NOT THE ETHERNET PORT. Point your browser to the IP address of the SPA3102. To find out what the IP is you should be able to check on your router or dial ***** (5 asterisks) > 110 on your phone.

Just like a router, a webpage with settings and status of the device should appear. Use the screenshots below and set all the settings below:

The settings are for UK and I have change the tones in the Voice > Regional settings. Others such as the daylight savings are aligned to the UK time zone.

The following needs to be configured according to the environment.
Voice > Line 1 > Proxy and Registration

  • Proxy - IP address of the Linux box which will host the Asterisk and FreePBX software.

Voice > Line 1 > Subscriber Information

  • User ID - Extension set in FreePBX
  • Password - Leave blank initially for easier debugging but it should match the secret settings in the extensions

Voice > PSTN Line > Proxy and Registration

  • Proxy - IP address of the Linux box which will host the Asterisk and FreePBX software.

Voice > PSTN Line > Dial Plans

  • Dial Plan 2 - S0(<:xxxxxxxxxx>) where x is the phone number of your land land including the area code e.g 01323123456

Asterisk
Trixbox
FreePBX
Installing Asterisk and FreePBX on a vmware instance of Ubuntu 10.04 (Lucid) alpha3

30

May/10

Full Disk – MediaTomb Hog

Sunday, May 30th, 2010

For some reason MediaTomb was out putting a lot of log statements in /var/log/mediatomb.log. I tailed the file and only got what looked like time stamped entries of normal scanning information as I have timed re-scans.

The file managed to fill my 250GB hard drive when Ubuntu 10.04 started to complain. After removing the file using the command line all was fine again.