Friday, September 21, 2012

Installing Asterisk 10.8.0 on CentOS 6.3 (64-bit)

The book “Asterisk: The Definitive Guide 3rd Edition” describes installing Asterisk 1.8.x.  This is my attempt to go through the installation instructions and adapt them for an Asterisk 10.8.0 install.  I assume you have CentOS 6.3 installed already and updated (yum update).

This guide follows the book’s installation type.  We will not be installing a pre-built package, but will be installing from the source code.  You can find package installation instructions at http://www.asterisk.org/downloads/yum.  Note that the packages are not always up to date and the book recommends installing the latest version from source.

Note 1: I am relatively new to Linux and completely new to Asterisk.  Perhaps this guide will help someone else perform the same operation I am doing, but this is mainly to chronicle my installation so that I can easily repeat it if necessary.

Note 2: For the purposes of this install, I have removed the “sudo” commands and will run all the commands as root (su –).

Remove any 32-bit libraries, perform a system update and reboot:

yum remove *.i386

image

yum update –y

image

# Reboot system if any updates were installed
reboot

Synchronize time and install the NTP (Network Time Protocol) daemon:

# Verify ntp daemon is installed
yum install –y ntp

image

# Set the current date/time from pool.ntp.org
ntpdate pool.ntp.org

# Verify ntp daemon runs at system startup
chkconfig ntpd on

# Start the NTP daemon
service ntpd start

image

Add a new system user “asteriskpbx”:

adduser asteriskpbx

passwd asteriskpbx

image

# Install sudo if not already present
yum install sudo

# Edit the /etc/sudoers file and add ‘asteriskpbx’
visudo

# NOTE: I added the entry manually using the following
echo 'asteriskpbx ALL=(ALL) ALL' >> /etc/sudoers

image

# Also add an entry for the group “wheel”
echo '%wheel ALL=(ALL) ALL' >> /etc/sudoers

# Edit /etc/group file and modify the line that starts
# with wheel so it reads: wheel:x:10:root,asteriskpbx

Install software dependencies:

yum install gcc.x86_64 gcc-c++.x86_64 make.x86_64 wget.x86_64 subversion.x86_64 libxml2-devel.x86_64 ncurses-devel.x86_64 openssl-devel.x86_64 vim-enhanced.x86_64

image

Create directory structure:

mkdir -p ~/src/asterisk-complete/asterisk

cd ~/src/asterisk-complete/asterisk

Check out the source code with Subversion (we will check out using a specific tag, 10.8.0)

svn co http://svn.asterisk.org/svn/asterisk/tags/10.8.0

image

(NEW) Install the SQLite3 development package:

yum install sqlite-devel.x86_64

To support Google Talk, install ikseml by downloading it from http://code.google.com/p/iksemel/

wget http://iksemel.googlecode.com/files/iksemel-1.4.tar.gz

tar -xvzf iksemel-1.4.tar.gz

cd ~/src/iksemel-1.4

./configure

make

make install

Build and install the software:

cd ~/src/asterisk-complete/asterisk/10.8.0

./configure

make

make install

make config

To install the asterisk program documentation (optional, requires doxygen):

# Verify doxygen is installed (for me, it was already)
yum install doxygen

make progdocs

Install additional sound prompts from menuselect:

cd ~/src/asterisk-complete/asterisk/10.8.0/

make menuselect

make install

Modify file permissions of the folders Asterisk was installed to:

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

On CentOS, disable SELinux:

# Change the value of SELINUX from enforcing to disabled, then REBOOT
nano /etc/selinux/config

Create the /etc/asterisk/ directory and copy the indications.conf sample file into it:

mkdir -p /etc/asterisk

chown asteriskpbx:asteriskpbx /etc/asterisk

cd /etc/asterisk/

cp ~/src/asterisk-complete/asterisk/10.8.0/configs/indications.conf.sample ./indications.conf

Copy the sample asterisk.conf file into /etc/asterisk and uncomment and change runuser= and rungroup= to asteriskpbx:

cp ~/src/asterisk-complete/asterisk/10.8.0/configs/asterisk.conf.sample /etc/asterisk/asterisk.conf

nano /etc/asterisk/asterisk.conf

Create the modules.conf file. Enable loading of modules automatically, and disable extra modules:

$ cat >> /etc/asterisk/modules.conf
; The modules.conf file, used to define which modules
; Asterisk should load (or not load).
;
[modules]
autoload=yes
; Resource modules currently not needed
noload => res_speech.so
noload => res_phoneprov.so
noload => res_ael_share.so
noload => res_clialiases.so
noload => res_adsi.so
; PBX modules currently not needed
noload => pbx_ael.so
noload => pbx_dundi.so
; Channel modules currently not needed
noload => chan_oss.so
noload => chan_mgcp.so
noload => chan_skinny.so
noload => chan_phone.so
noload => chan_agent.so
noload => chan_unistim.so
noload => chan_alsa.so
; Application modules currently not needed
noload => app_nbscat.so
noload => app_amd.so
noload => app_minivm.so
noload => app_zapateller.so
noload => app_ices.so
noload => app_sendtext.so
noload => app_speech_utils.so
noload => app_mp3.so
noload => app_flash.so
noload => app_getcpeid.so
noload => app_setcallerid.so
noload => app_adsiprog.so
noload => app_forkcdr.so
noload => app_sms.so
noload => app_morsecode.so
noload => app_followme.so
noload => app_url.so
noload => app_alarmreceiver.so
noload => app_disa.so
noload => app_dahdiras.so
noload => app_senddtmf.so
noload => app_sayunixtime.so
noload => app_test.so
noload => app_externalivr.so
noload => app_image.so
noload => app_dictate.so
noload => app_festival.so

[CTRL+D]

Configure musiconhold.conf:

$ cat >> musiconhold.conf
; musiconhold.conf
[default]
mode=files
directory=moh

[CTRL+D]

At this point the system should be ready to configure the dialplan and channels.  First, log out and then log in as asteriskpbx.  Enter the following command to ensure you have sudo access:

sudo ls /root/

Finally, to make life easier, include /usr/sbin and /sbin in the PATH variable for asteriskpbx.  Edit the file with nano or something similar.

# change PATH=$PATH:$HOME/bin to PATH=$PATH:$HOME/bin:/usr/sbin:/sbin
nano .bash_profile

At this point Asterisk looks to be installed successfully.  I will blog again with any updates.  I will be working on getting this working with our PBX at work (and my VOIP phone) and with Google Talk and with Skype.

Installing FireFox 15 (or latest version) on CentOS 6.3 (or 6.x) via yum

Distilled from http://www.if-not-true-then-false.com/2011/install-firefox-on-fedora-centos-red-hat-rhel/

(Optional) Backup current FireFox profiles

tar -cvzf $HOME/mozilla-firefox-profiles-backup.tar.gz $HOME/.mozilla/firefox/

Change to root user

su -

Install Remi repository

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

(Optional) Check for available versions

yum --enablerepo=remi list firefox

If you already have an older version of FireFox installed, then UPDATE

yum --enablerepo=remi update firefox

Otherwise INSTALL

yum --enablerepo=remi install firefox

Done!

Thursday, September 20, 2012

Installing VirtualBox Linux Guest Additions for CentOS 6.3

To install the VM Guest Additions for VirtualBox 4.1.22 on CentOS 6.3, I worked through the instructions found at http://wiki.centos.org/HowTos/Virtualization/VirtualBox/CentOSguest

As detailed at http://wiki.centos.org/AdditionalResources/Repositories/RPMForge we must install RPMforge first, so we can install the DKMS (Dynamic Kernel Module Support) required by the Virtual Box Linux Additions.

The following must be done with root privileges. I logged in as root for this operation.

Install RPMforge

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

rpm -K rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

rpm -i rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Install DKMS (Dynamic Kernel Module Support)

yum --enablerepo rpmforge install dkms

Ensure the development environment and kernel source are installed

yum groupinstall "Development Tools"

yum install kernel-devel

Install Guest Additions

In VirtualBox, under the Devices menu, select the VBoxGuestAdditions.iso image for the CD/DVD drive.  The autorun should execute and you should be able to install it from there.  If the autorun does not kick in, go to a terminal prompt and CD to the mountpoint and issue the command:

./VBoxLinuxAdditions.run

image

Once I performed those actions, I logged out of root and logged in under my own account.  The mouse no longer needed to be captured by the virtual machine.  You can resize the Virtual Box window and the CentOS desktop will resize.  Much better.

Wednesday, September 19, 2012

Console Progress/Status Output and Clear To End Of Line (EOL) (VB.NET)

When writing a .NET Console application, I sometimes have long-running processes for which I like to see status information displayed.  I could simply issue WriteLine statements and have the console window continuously scroll text, but I much prefer information to be displayed and updated in a single location.  Traditionally, what you would do is write some text (of length N) and then write N Ctrl-H characters (Backspace) which moves the cursor back to where it started.  Then when you write again, it overwrites the previous text.  Though, if the new text is shorter than the previous text, you end up with those extra characters – so what you want to do is write your text and then “clear to end of line” (EOL).  I finally got around to implementing that.

There are various ways to tackle this, but I use a couple functions: CONSOLE__WRITE to display text and backspace the cursor to where it started, and CONSOLE__CLEAR_EOL which clears text to the end of the line.  Actually, I incorporated the CONSOLE__CLEAR_EOL as an optional (default True) parameter to CONSOLE__WRITE.

Here are the routines..

    Public Sub CONSOLE__WRITE(ByRef szText As String, Optional ByVal bClearEOL As Boolean = True)
        'Output the text
        Console.Write(szText)
        'Optionally clear to end of line (EOL)
        If bClearEOL Then CONSOLE__CLEAR_EOL()
        'Move cursor back to where we started, using Backspaces
        Console.Write(Microsoft.VisualBasic.StrDup(szText.Length(), Chr(8)))
    End Sub
 
    Public Sub CONSOLE__CLEAR_EOL()
        'Clear to End of line (EOL)
        'Save window and cursor positions
        Dim x As Integer = Console.CursorLeft
        Dim y As Integer = Console.CursorTop
        Dim wx As Integer = Console.WindowLeft
        Dim wy As Integer = Console.WindowTop
        'Write spaces until end of buffer width
        Console.Write(Space(Console.BufferWidth - x))
        'Restore window and cursor position
        Console.SetWindowPosition(wx, wy)
        Console.SetCursorPosition(x, y)
    End Sub

Here is a little test program…

image

Here is a sample of it running..

image

And when it has completed..

image