Saturday, August 9, 2008

Make hidden folders

This is a trick to make folders to keep your personal files safely.
1. Right Click on the free space and click on new folder.
2. While naming the folder just press ALT key and enter 0160
3. Now you can just select the folder and og to its properties.
4. There in the advanced option you can change the icon for the folder you created.
5. You can easily choose a blank image there.

And now you are done. If confused just watch the video:
http://www.metacafe.com/watch/376945/lock_hidden_folders_in_windows_vista_and_xp/




AddThis Feed Button

Solitaire

Now you can do a awesome trick to your Solitaire games comes by default with your windows xp version.
Just press the Key "Alt"+"Shift"+2 all the same like Ctrl+Alt+Del

You can win by this small trick while watching a amazing thing!!

Enjoy!

3D PinBall Trivk

You never know what you can do with your pinball games comes with your windows xp installation. Just see the video here and amaze your friends:

http://www.metacafe.com/watch/297793/windows_3d_pinball_hidden_trick/

How to get your system information in Ubuntu

I stumbled upon the nifty “lshw” tool today. lshw lists your hardware. Try it now:
$sudo lshw

You can get specific details by using the -C flag:
$sudo lshw -C disk
will list all you hard disks.

It create an html page with your hardware details if you do a:
$sudo lshw -html > your-file-name.html





AddThis Feed Button

UUID

You can run command to generate a uuid randomly:

sudo uuidgen

you can also run a perl script to get a randomly generated uuid:

#!/usr/bin/perl
#UUID generator

$uuid = `uuidgen`;
chomp $uuid;
print $uuid;

If you want to get UUID customized according to your need::

You will need UUID.pm file to get the below code running and you can get that by this command

sudo cpan Data::UUID

Synopsis:
use Data::UUID;

$ug = new Data::UUID;
$uuid1 = $ug->create();
$uuid2 = $ug->create_from_name(, );

$res = $ug->compare($uuid1, $uuid2);

$str = $ug->to_string( $uuid );

This modules provides several methods to create a UUID:

# creates binary (16 byte long binary value) UUID.
$ug->create();
$ug->create_bin();

# creates binary (16-byte long binary value) UUID based on particular
# namespace and name string.
$ug->create_from_name(, );
$ug->create_from_name_bin(, );

# creates UUID string, using conventional UUID string format,
# such as: 4162F712-1DD2-11B2-B17E-C09EFE1DC403
$ug->create_str();
$ug->create_from_name_str(, );

# creates UUID string as a hex string,
# such as: 0x4162F7121DD211B2B17EC09EFE1DC403
$ug->create_hex();
$ug->create_from_name_hex(, );

# creates UUID string as a Base64-encoded string
$ug->create_b64();
$ug->create_from_name_b64(, );

Binary UUIDs can be converted to printable strings using following methods:

# convert to conventional string representation
$ug->to_string();

# convert to hex string
$ug->to_hexstring();

# convert to Base64-encoded string
$ug->to_b64string();

Conversly, string UUIDs can be converted back to binary form:

# recreate binary UUID from string
$ug->from_string();
$ug->from_hexstring();

# recreate binary UUID from Base64-encoded string
$ug->from_b64string();

Finally, two binary UUIDs can be compared using the following method:

# returns -1, 0 or 1 depending on whether uuid1 less
# than, equals to, or greater than uuid2

Examples:

use Data::UUID qw(:all);

# this creates a new UUID in string form, based on the standard namespace
# UUID NameSpace_URL and name "www.mycompany.com"

$ug = new Data::UUID;

print $ug->create_from_name_str(NameSpace_URL, "www.mycompany.com");





AddThis Feed Button

SimpleDB in EC2 Ubuntu

I am showing here the How to guide for amazon-simpledb-cli(Command Line Interface)
This tool depends on the following Perl modules from CPAN:
      Getopt::Long
Pod::Usage
Digest::SHA1
Digest::HMAC
XML::Simple

You can install them using the "cpan" command on many Linux distros:
sudo cpan Getopt::Long
sudo cpan Pod::Usage
sudo cpan Digest::SHA1
sudo cpan Digest::HMAC
sudo cpan XML::Simple

This tool also depends on the Amazon::SDB modules provided by Amazon(not the one in CPAN). Amazon's modules can be found here:

http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1136

Here is the How to for the above:
curl -Lo amazon-simpledb-perl-library.zip \
http://amazon-simpledb-perl-library.notlong.com

unzip amazon-simpledb-perl-library.zip

sitelib=$(perl -MConfig -le 'print $Config{sitelib}')
sudo scp -r amazon-simpledb-*-perl-library/src/Amazon $sitelib

Finally, this command line interface can be installed with:

sudo curl -Lo /usr/local/bin/simpledb http://simpledb-cli.notlong.com
sudo chmod +x /usr/local/bin/simpledb

Now to test your installation::
  1. Extract the amazon-simpledb-2007-11-07-perl-library.zip file into a working directory.
  2. Edit desired sample. For example: src/Amazon/SimpleDB/Samples/CreateDomainSample.pl

    • Set AWS Access Key ID and AWS Secret Access Key
    •  my $AWS_ACCESS_KEY_ID        = "";
      my $AWS_SECRET_ACCESS_KEY = "";

    • Set request parameters. For example, find following pre-generated snippet:
    •  use Amazon::SimpleDB::Model::CreateDomain; 
      # @TODO: set action. Action can be passed as Amazon::SimpleDB::Model::CreateDomain
      # object or hash of parameters
      # invokeCreateDomain($service, $action);

    • And set action with DomainName parameter:
    •  use Amazon::SimpleDB::Model::CreateDomain; 
      my $action = Amazon::SimpleDB::Model::CreateDomain->new;
      invokeCreateDomain($service, $action->withDomainName("MyDomain"));

  3. Run CreateDomain sample:
  4.    perl src/Amazon/SimpleDB/Samples/CreateDomainSample.pl
  5. You should see the output similar to the following:


  6.     CreateDomainResponse
    ResponseMetadata
    RequestId
    95cdcb68-f46c-400b-8265-8c2de2a5c475

  7. Experiment with samples. When ready, install library in the perl include path and use it.

SEE ALSO
Amazon SimpleDB (SDB)
http://www.amazon.com/SimpleDB-AWS-Service-Pricing/b/?node=342335011

Amazon SimpleDB Developer Guide
http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGui
de/




AddThis Feed Button

Codecs & asterisk

If you have worked with Asterisk/Trixbox for any length of time, you have dealt with codecs. You’ve seen terms thrown around such as ulaw, alaw, G711, G729, and on and on and one. But what are these? And what are the differences between them? When should use use G726 instead of ulaw? What codecs are even possible in Trixbox? I’ll try to clear some of this up.

For VoIP communication, you need to start with a protocol. The three big protocols are SIP, IAX2, and H323. SIP and IAX2 are natively supported in Trixbox’s version of Asterisk (v1.2), so I’m going to assume that you’re using one of these. Once you have your protocol in place, a codec tells the system what format to send the calls across the protocol.

Codecs are used to convert an analog voice signal to digital. They vary in sound quality and bandwidth consumption. Typically, the better the sound quality, the more bandwidth consumed…the less bandwidth consumed, the worse the sound quality. Here are the codecs currently supported in Asterisk v1.2:

ulaw - AKA G.711 - 64Kbps - ulaw is the standard US codec for uncompressed voice. For internal extension to extension calls, this is the preferred codec. Notice the 64Kbps? This is how much bandwidth is consumed by this codec. When thinking about bandwidth consumption, I like to think in terms of phone lines…a typical phone line (or T1 channel) is 56Kbps (remember the days of modems??). ulaw is just a little higher than that. If your Internet connection is a modem, you would want a more compressed codec. If you have 768Kbps up/down DSL, you should be able to run 12 ulaw calls across the connection (768Kbps / 64Kbps = 12). That is typically not recommended however, and with other Internet stuff going on, that number gets reduced significantly. If a client told me they had a 768Kbps connection, I would tell them not to expect good voice quality on more than 3-4 simultaneous calls with ulaw and that connection.

alaw - AKA G.711 - 64Kbps - alaw is the same as ulaw, but it is the European standard codec.

G.723.1 - 6.3Kbps or 5.3Kbps - This is the standard codec used by H323. Since I’m not talking about H323, I’ll skip this one.

G.726 - 32 Kbps - G726 is a good alternative to ulaw when you need to save some bandwidth. It consumes 1/2 the amount of bandwidth of ulaw, and the voice quality isn’t degraded much.

G.729 - 8Kbps - The G729 codec is excellent, but there is a trade-off. It has very low bandwidth consumption and decent voice quality, however it also has a dark side in that it isn’t free. G.729 licenses are available from Digium at the cost of $10.00 per channel. They also take a significant amount of CPU power to process the compression. Installation requires a purchased license from Digium, and you have to download and run their registration program…it is pretty easy to do, but is still an additional step. Plus, it bases the registration on the MAC address of the computer it was installed on, and is only transferrable once (and you have to contact Digium to do it). This is a good codec, but try G.726 or GSM first.

GSM - 13Kbps - GSM is a codec that comes from cell phone technology. It has pretty low bandwidth consumption, but you will notice lower voice quality than a standard PSTN line.

iLBC - 13.33Kbps - iLBC is another low-bandwidth codec. They claim better quality than G729, but I haven’t had much experience with them…I don’t know if that is a true statement or not.

Speex - configurable 4-48Kbps - Speex is another less-known codec. It’s advantage is that it is flexible (4Kbps to 48Kbps) in terms of bandwidth consumption, but it takes up more CPU than even G.729. Again, I have never used this codec, so I don’t know much more about it.

I hope that helps clear codecs up a bit. My general rule of thumb is to use ulaw if there aren’t any bandwidth constraints. If bandwidth is a consideration, I then try G.726 and GSM in that order. If a customer is jazzed about G.729, I have no problem using that as well (although I don’t think it offers enough advantage over G.726 or GSM to be worth $10 bucks).





AddThis Feed Button

Tuesday, August 5, 2008

how to s3-bash in ubuntu ec2

s3-bash
wget http://s3-bash.googlecode.com/files/s3-bash.0.02.tar.gz
untar the files

  • To get files: use ./s3-get
  • To put files: use ./s3-put
  • To delete files: use ./s3-delete
Examples

./s3-get -k MyAWSAccessKeyId -s AWSSecretAccessKeyIdFile /bucket/pathtoobject
We use a file for the AWS Secret Access Key Id so that it does not appear in the list of running processes with ps


nano AWSSecretAccessKeyIdFile (paste your SecretKey there)

od -a AWSSecretAccessKeyIdFile

cat AWSSecretAccessKeyIdFile | tr -d '\n' >> AWSSecretAccessKeyIdFile2(if you get 41 bytes problem)





AddThis Feed Button

How to Convert wav file to ulaw for asterisk

To convert wav to ulaw:

sox -V vm-intro.wav -r 8000 -c 1 -t ul -w vm-intro.ulaw

To convert ulaw(gsm) to MP3:
sox /var/lib/asterisk/sounds/mymessage.gsm -r 8000 -c 1 -s -w /var/lib/asterisk/sounds/mymessage.wav

lame -V3 /var/lib/asterisk/sounds/mymessage.wav /var/lib/asterisk/sounds/mymessage.mp3

I think this is the only way to convert your recorded ulaw(gsm) file into MP3.




AddThis Feed Button

Text To Speech Engine Festival on Ubuntu EC2

Festival:

apt-get install festival
apt-get install festvox-kallpc16k

You need to add to /usr/share/festival/festival.scm:

(define (tts_textasterisk string mode)
"(tts_textasterisk STRING MODE)
Apply tts to STRING. This function is specifically designed for use in server mode so
a single function call may synthesize the string. This function name may be added to
the server safe functions."
(let ((wholeutt (utt.synth (eval (list 'Utterance 'Text string)))))
(utt.wave.resample wholeutt 8000)
(utt.wave.rescale wholeutt 5)
(utt.send.wave.client wholeutt)))


festival.conf
-----------------------------
[general]
host=localhost
port=1314
festivalcommand=(tts_textasterisk "%s" 'file)(quit)\n

but in extensions.conf when i call the festival app i put the text
'quoted' like this:


exten => 003,1,Festival('Hello asterisk user, how are you today?') ;
<-- note the quotes ... exten => 003,2,Wait(1)

exten => 003,3,Hangup()


From the command-line type 'festival --server'
Then restart Asterisk

This configuration reads a text file (limiting it to 130 characters or less) and then speaks the message to the caller.

exten => 3200,1,ReadFile(test=/tmp/test.txt,130)
exten => 3200,n,Festival(${test})
exten => 3200,n,Hangup

Example of a Auto Attendant menu.


[MainMenu]
exten => s,1,SetVar(NUMINVALID=0)
exten => s,2,Setvar(NUMTIMEOUTS=0)
exten => s,3,Background(sales_press_one)
exten => s,4,Background(support_press_two))
exten => s,5,ResponseTimeout(5)
exten => s,6,DigitTimeout(2)

exten => t,1,SetVar(NUMTIMEOUTS=$[${NUMTIMEOUTS} + 1])
exten => t,2,Gotoif($[${NUMTRIES} < 2]?s,3)
exten => t,3,Background(vm-goodbye)
exten => t,4,Hangup()

exten => i,1,SetVar(NUMINVALID=$[${NUMINVALID} + 1])
exten => i,2,Gotoif($[${NUMINVALID} < 4]?:10)
exten => i,3,Background(invalid)
exten => i,4,Goto(s,2)
exten => i,10,Playback(vm-goodbye)
exten => i,11,Hangup()




AddThis Feed Button

Running Perl and MySql for Asterisk

Setting up MySQL:(
if you forget ur mysql password:
  1. Stop the MySQL Server :sudo /etc/init.d/mysql stop
  2. Start the mysqld configuration : sudo mysqld --skip-grant-tables &
  3. Login to MySQL as root : mysql -u root mysql
  4. Replace YOURNEWPASSWORD with your new password! : UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
Note: This method is not regarded as the securest way of resetting the password. However it works.

create database callrouting;
use callrouting;
grant all privileges on callrouting.* to callrouter@localhost identified by 'callrouter';

create table passwords(id int(11) AUTO_INCREMENT NOT NULL, password varchar(255),primary key(id));
SHOW TABLES;

DESCRIBE passwords;
insert into passwords(password) values("1234");
quit;

PERL: Password check::::
running pl files: ./filename.pl or perl filename.pl



AddThis Feed Button

Perl Support for Asterisk

PERL::AGI

wget http://asterisk.gnuinter.net/files/asterisk-perl-0.10.tar.gz

untar -> go to folder ->
pl Makefile.pl -> make -> make install

to test perl:
go to examples folder-> ./agi-test.pl or perl agi-test.pl





AddThis Feed Button

asterisk on Ec2 ubuntu

Install Pre-Requisites:

For compiling and installing:
apt-get install build-essential autoconf automake libtool flex bison libssl-dev
libnewt-dev libncurses5-dev linux-headers-`uname -r` gcc

SOUNDS:
apt-get install sox curl subversion subversion-tools

MySQL
apt-get install mysql-client mysql-server libmysqlclient15-dev


LIBPRI:
wget ftp.digium.com/pub/libpri/releases/libpri-1.4.4.tar.gz
make
make install


Speex:(
Speex is an Open Source/Free Software patent-free audio compression format designed for speech. The Speex Project aims to lower the barrier of entry for voice applications
by providing a free alternative to expensive proprietary speech codecs. Moreover, Speex is well-adapted to Internet applications and provides
useful features that are not present in most other codecs.)

wget http://downloads.us.xiph.org/releases/speex/speex-1.2beta2.tar.gz
./configure --prefix=/usr
make
make install

Asterisk:
wget ftp.digium.com/pub/asterisk/releases/asterisk-1.4.21.1.tar.gz

cd asterisk-1.4.13
Edit the Makefile(change the ASTVARRUNDIR= to /var/run/asterisk)
./configure
make menuselct(selct gsm sounds frm extras and core sounds in gsm)
make install
make samples

Asterisk Addons:
wget ftp.digium.com/pub/asterisk/releases/asterisk-addons-1.4.7.tar.gz
cd asterisk-addons-1.4.4
./configure
make menuselect
make install

LINKS(to install it apt-get install links)
go to http://asterikast.com -> downloads -> download the g729 codecs from there
UNZIP it... (apt-get install UNZIP)
copy that codecs into /usr/lib/asterisk/module/

DELETE all the codecs and asterisk-addons folder frm /usr/src

groupadd asterisk
useradd -s /bin/false -g asterisk asterisk

wget http://asterikast.com/_downloads/_scripts/ownast
cat ownast
chmod +x ownast
cp ownast /usr/bin/
ownast

safe_asterisk -U asterisk -G asterisk
(if you get "Bad fd number" try ln -sf /bin/bash /bin/sh)
asterisk -r
ps

edit the sip.conf
[general]
context=default
allowguest=yes
disallow=all
allow=ulaw
nat=yes
dtmfmode=rfc2833
canreinvite=no

[100]
type=friend
context=default
disallow=all
allow=ulaw
allow=g729
host=dynamic
username=100
secret=100
canreinvite=no






AddThis Feed Button

How to S3fs on EC2 Ubuntu

Download, build, and install (use libcurl3-openssl-dev for Ubuntu
7.04)

apt-get install -y subversion build-essential libcurl4-openssl-dev
libxml2-dev libfuse-dev
svn checkout http://s3fs.googlecode.com/svn/trunk/s3fs s3fs
make -C s3fs (install g++ if needed and install make)
cp s3fs/s3fs /usr/local/bin

- Set up an S3 access configuration file

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
echo "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" > /etc/passwd-s3fs
chmod 600 /etc/passwd-s3fs

- Start s3fs (probably best to use a new/empty bucket the first time):

bucket=...
mkdir -p /mnt/$bucket
/usr/local/bin/s3fs $bucket /mnt/$bucket

- Shut it down (flushes any cached data)

umount /mnt/$bucket

s3fs has a caching mechanism: You can enable local file caching to minimize downloads, e.g., :

/usr/bin/s3fs mybucket /mnt -ouse_cache=/tmp




AddThis Feed Button

JetS3t on Ubuntu

Download the JetS3t toolkit from here:
https://jets3t.dev.java.net/releases/jets3t-0.5.0.zip

sudo mkdir /opt/jets3t
unzip jets3t-0.5.0.zip -d /opt/jets3t

chmod 755 /opt/jets3t/bin/cockpit.sh
chmod 755 /opt/jets3t/bin/synchronize.sh
chmod 755 /opt/jets3t/bin/uploader.sh

export JETS3T_HOME=/opt/jets3t

nano /etc/bash.bashrc 9add the above line to the end of file)

nano
/opt/jets3t/configs/synchronize.properties(Add your Amazon S3 Credentials)
Run the synchronize script. Example: Uploading the contents of the /media/server1/HomeMovies/ to the HomeMovies Bucket:
/opt/jets3t/bin/synchronize.sh UP HomeMovies /media/server1/HomeMovies/
Use the cockpit utility to confirm the data is residing on the Amazon S3 server.
/opt/jets3t/bin/cockpit.sh

/opt/jets3t/bin/synchronize.sh UP -f




AddThis Feed Button

How to install Java in Ubuntu

sudo apt-get update

And finally, just tell it to install java :)

sudo apt-get install sun-java5-jdk


After this the rest of the process will display a dialog that will require you to accept the license agreement. When you do, the rest of the setup will happen on its own.

When you're on the command prompt type

javac -version

or

java -version

To Install jdk-6u5-linux-i586.bin:

download from http://15fwqxm1kxnjv9qge3r2.linux-packages.s3.amazonaws.com/jdk-6u5-linux-i586.bin
wget http://15fwqxm1kxnjv9qge3r2.linux-packages.s3.amazonaws.com/jdk-6u5-linux-i586.bin
-----------------------------------------------------------
Optional Runtime Dependencies:

ALSA Library-1.0.13: http://www.linuxfromscratch.org/blfs/view/svn/multimedia/alsa-lib.html
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.13.tar.bz2
./configure --enable-static &&
make
make install &&
install -v -m644 -D doc/asoundrc.txt \
/usr/share/doc/alsa-lib-1.0.13/asoundrc.txt
make doc
install -v -d -m755 /usr/share/doc/alsa-1.0.13/html &&
install -v -m644 doc/doxygen/html/* /usr/share/doc/alsa-1.0.13/html

CUPS-1.2.12: http://www.linuxfromscratch.org/blfs/view/svn/pst/cups.html
wget ftp://ftp.easysw.com/pub/cups/1.2.12/cups-1.2.12-source.tar.bz2
useradd -c "Print Service User" -d /dev/null -g lp -s /bin/false -u 9 lp
patch -Np1 -i ../cups-1.2.12-security_fixes-2.patch &&
./configure &&
make
make install
gunzip -v /usr/share/man/man{\
1/{cancel,cups{-config,test{dsc,ppd}},\
lp{,options,passwd,q,rm,r,stat}}.1,\
5/{{classes,client,cups-snmp,cupsd,printers,subscriptions,mailto}.conf,\
mime.{convs,types}}.5,\
7/{backend,filter}.7,\
8/{accept,cups{d,addsmb,enable,-{deviced,driverd,lpd,polld}},\
lp{admin,info,move,c}}.8}.gz &&

rm -v /usr/share/man/man8/{reject,cupsdisable}.8.gz &&

ln -v -s accept.8 /usr/share/man/man8/reject.8 &&

ln -v -s cupsenable.8 /usr/share/man/man8/cupsdisable.8
make install-cups

GTK+-2.10.13: http://www.linuxfromscratch.org/blfs/view/svn/x/gtk2.html
wget ftp://ftp.gtk.org/pub/gtk/v2.10/gtk+-2.10.13.tar.bz2
./configure --prefix=/usr --sysconfdir=/etc &&
make
make install &&
install -v -m755 -d /usr/share/doc/gtk+-2.10.13/{faq,tutorial} &&
cp -v -R docs/faq/html/* /usr/share/doc/gtk+-2.10.13/faq &&
cp -v -R docs/tutorial/html/* /usr/share/doc/gtk+-2.10.13/tutorial &&
install -v -m644 docs/*.txt /usr/share/doc/gtk+-2.10.13

----------------------------------------------------

chmod 755 jdk-6u5-linux-i586.bin

./jdk-6u5-linux-i586.bin


cd jdk1.6.0_05
install -v -m755 -d /opt/jdk-6u5 &&
mv -v * /opt/jdk-6u5
chown -v -R root:root /opt/jdk-6u5 &&
ln -v -sf xawt/libmawt.so /opt/jdk-6u5/jre/lib/i386/
cd ..
sed -i 's@XINERAMA@FAKEEXTN@g' \/opt/jdk-6u5/jre/lib/i386/xawt/libmawt.so

ln -sf xawt/libmawt.so /opt/jdk-6u5/jre/lib/i386/: This fixes linking issues with other applications that expect to find the motif libraries with the other JDK libraries.

Configuring JDK

As the root user, create a symlink to the installation directory:

ln -v -nsf jdk-6u5 /opt/jdk

The information below assumes your system is set up using the instructions found in “The Bash Shell Startup Files”. You may need to extract the relevant information below and incorporate it into your system's startup files if your system is set up differently.

Add the following jdk.sh shell startup file to the /etc/profile.d directory with the following commands as the root user:

cat > /etc/profile.d/jdk.sh << "EOF" # Begin /etc/profile.d/jdk.sh

# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk

# Adjust PATH
pathappend ${JAVA_HOME}/bin PATH

# Auto Java CLASSPATH
# Copy jar files to, or create symlinks in this directory
AUTO_CLASSPATH_DIR=/usr/lib/classpath
pathprepend . CLASSPATH
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
pathappend $dir CLASSPATH
done

export JAVA_HOME CLASSPATH
unset AUTO_CLASSPATH_DIR
unset dir

# End /etc/profile.d/jdk.sh

EOF

The Java plugin is located in $JAVA_HOME/jre/plugin/i?86/ns7/. Make a symbolic link to the file in that directory from your browser(s) plugins directory.



Choosing the default Java to use

apt-get install java-common
  • Open a Terminal window
  • Run sudo update-java-alternatives -l to see the current configuration and possibilities.

  • Run sudo update-java-alternatives -s XXXX to set the XXX java version as default. For Sun Java 6 this would be sudo update-java-alternatives -s java-6-sun

  • Run java -version to ensure that the correct version is being called.

You can also use the following command to interactively make the change;

  • Open a Terminal window
  • Run sudo update-alternatives --config java

  • Follow the onscreen prompt




AddThis Feed Button

Asterisk Installation Step By Step on Ubuntu

Install Pre-Requisites:
apt-get install build-essential autoconf automake libtool flex bison libssl-dev libnewt-dev libncurses5-dev linux-headers-`uname -r`
apt-get install sox curl subversion subversion-tools
apt-get install mysql-client mysql-server libmysqlclient15-dev
apt-get install php5 php5-cli php5-curl php5-gd php5-json(php5-common) php5-mcrypt php5-mhash php5-mysql php5-suhosin php5-xmlrpc php5-xsl php-pear
apt-get install apache2 apache2-mpm-prefork


Setup Accounts:
adduser --system --home /var/lib/asterisk --group asterisk
mkdir /var/run/asterisk
chown -R asterisk:asterisk /var/run/asterisk


Download Asterisk:

wget ftp.digium.com/pub/asterisk/releases/asterisk-1.4.21.1.tar.gz

wget ftp.digium.com/pub/asterisk/releases/asterisk-addons-1.4.7.tar.gz

wget ftp.digium.com/pub/libpri/releases/libpri-1.4.4.tar.gz


Uncompress Asterisk Sources:

tar xzvf asterisk-1.4.21.1.tar.gz

tar xzvf asterisk-addons-1.4.7.tar.gz

tar xzvf libpri-1.4.4.tar.gz

Compile Asterisk Sources:
cd asterisk-1.4.13 && ./configure && make install && make samples && cd -
cd asterisk-addons-1.4.4 && ./configure && make install && cd -
cd libpri-1.4.2 && make && make install && cd -


Setup MySQL:

mysql -u root –p (Enter your password to check if mysql is running properly or not)

mysqladmin -u root password ''
mysqladmin -p create asterisk create asteriskcdrdb
echo "GRANT ALL PRIVILEGES ON asterisk.* TO asterisk@localhost IDENTIFIED BY '';" | mysql -u root –p
echo "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asterisk@localhost IDENTIFIED BY '';" | mysql -u root -p

Configure Asterisk Files:
(/etc/apache2/apache2.conf):
User asterisk
Group asterisk

(/etc/asterisk/asterisk.conf):
astrundir => /var/run/asterisk

(/etc/php5/apache2/php.ini):
post_max_size = 20M
upload_max_filesize = 20M

Install PEAR for PHP:
pear install db

Setup Asterisk:

edit /etc/init.d/skeleton

DAEMON=/usr/src/asterisk/asterisk

NAME=Asterisk

DESC="Asterisk PBX"

save file as asterisk in /etc/init.d/

>
chmod +x /etc/init.d/asterisk
/etc/init.d/asterisk start
nano /etc/inittab
chown -R asterisk:asterisk /var/spool/asterisk/
chown -R asterisk:asterisk /var/log/asterisk/

Setup FreePBX:
svn co https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/branches/2.3/ /usr/src/freepbx
mysql -p asterisk < /usr/src/freepbx/SQL/newinstall.sql mysql -p asteriskcdrdb < /usr/src/freepbx/SQL/cdr_mysql_table.sql cd /usr/src/freepbx

./install_amp

Username to connect to the asterisk database

[asteriskuser]asterisk

Password to connect to the asterisk database

[amp109]

Hostname of Asterisk Database [localhost]

Username to connect to the Asterisk Manager Interface[admin]

Password to connect to the Asterisk Manager interface[amp111]

Path to use for your AMP web root[/var/www/html]

Ip address or hostname used to access the AMP web-admin [xx.xx.xx.xx]

Password to perform call transfer with the flash operator panel[passw0rd]

Use simple Extensions [extensions] admin or separate Devices and Users [devicesandusers]

Directory to store AMP executable scripts [/var/lib/asterisk/bin]

Directory to store super user scripts [/usr/local/sbin]

If it fails running or problem connecting to the database try

./install_amp –username=root –password=[password]

&& cd -

Update Ubuntu Startup Files:
update-rc.d zaptel defaults
update-rc.d asterisk defaults

Setup Zaptel if Required:
(/etc/zaptel.conf)
span=1,0,0,esf,b8zs
bchan=1-23
dchan=24

Load Zaptel Modules:
modprobe zaptel
modprobe wct1xxp
ztcfg -vv

Visit the Web Interface:
http:///html/





AddThis Feed Button


Setting Up Outbound Settings

Setting Up Outbound Settings
Registering lets the remote server know where we are. Thus, it will start sending telephone calls to us. By default, Asterisk will use the settings specified in the [general] section of sip.conf.
Example: using a DeFuniac Telephone we can create a section that will route incoming telephone calls from them to their own special context in your dial plan and allow the Dial() command to omit the username and password.

[defuniactelephone]
type=peer
secret=mondal
username=aurobindo
host=voip.worldtelephone.com
fromuser=mgaribaldi
fromdomain=voip.defuniactelephone.com
context=incoming_world


After you add this, issue a reload command. What this specifically does is create an account on the system for the connection.This account will match any phone calls coming into the server voip.worldtelephone.com with the username aurobindo and the password mondal, and route those phone calls into the context incoming_world in your dial plan.

Step 17: Setting Up an SIP Server

[sipclient]
type=friend
context=internal
username=sipclient
secret=password
mailbox=201
host=dynamic
callerid="SIP Client" <3115552368>
dtmf=inband


It will set up an account for a channel called “sipclient” that is identified via the username “sipclient” and the ultra-secure password “password”.We
specify it is a dynamic host, which means the client can connect from anywhere so it
will be registering with us.The client will sit in the internal context where the appropriate dial strings should be. Also, we assign the voice-mail box 201 to the client so they can be notified about waiting messages.We also specify that outbound calls from the client will have the caller ID string SIP CLIENT <3115552368>.

After a reload, the system is now ready to accept an SIP client connection. Point an SIP phone to the server with the correct username and password and you will be ready to dial away.

Step 18: Configuring Voice Mail

Voice-mail settings are listed within voicemail.conf in the Asterisk configuration directory. There are a lot of bits to configure in voice mail, such as time zone settings, voice mail to e-mail settings, and options on how to pronounce time, among others. Unless you want to get fancy, most of the defaults should work fine.A common option that may need to be adjusted is the maxmsg option which limits the number of messages a user can have in their mailbox. Another option that may need to be adjusted is the tz option that controls what time zone the messages will be based in.This is commonly used if the server’s time zone is different than the time zone the company is based in. The tz option, by default, can only be set to options specified in the [zonemessages] section, which by default is set to the following:

[zonemessages]
eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours'
military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM


The syntax for this is

ZONENAME=TIMEZONE|DATESTRING

where ZONENAME is the name you want to give the setting, TIMEZONE is the Linux time-zone name you want the system to use for the setting, and DATESTRING is a string of Unix date variables and sound files. Not the most elegant solution, but it is very customizable. Let’s say we wanted to add a Pacific time zone, we would just add the following line:

pacific=America/Los_Angeles|'vm-received' Q 'digits/at' IMp


which would make a pacific zone based on the America/Los_Angeles time zone and would play the standard voice-mail envelope string.

Step 19: Configuring Mailboxes
Mailboxes are in the [default] section. A typical run-of-the-mill mailbox for Auro would look like this:

867 => 5309,Aurobindo Mondal,auro@company.com

This sets up mailbox 867 for Aurobindo Mondal, with a password of 5309. Any messages left in the mailbox would be attached to an e-mail sent to auro@socal.com, allowing him to listen to the message without calling the server.This setup is suitable for most users; however, there are other options as well. Asterisk has the ability to send a second message without the attachment that is more suitable for text messages or mobile phone e-mail as well:

867 => 5309,Aurobindo Mondal,aurobindo@company.com,3115552368@worldtelephone.com

This is handy since it allows the user to receive a notification on their mobile device about a voicemail message without having to download a possibly large audio file over a slow mobile data link. If we want to attach the voice-mail messages to the e-mail messages, but still wants to receive a notification.This is done with the attach option:

867 => 5309,Aurobindo Mondal,auro@company.com,,|attach=no

If he is in a separate time zone from the company and wants to have his mailbox say the time in the Central time zone. We would then adjust the mailbox like this:

867 => 5309,Aurobindo Mondal,steve@example.net,,|attach=no|tz=central

Step 20: Leaving and Retrieving Message
All of the voice-mail functions are contained in two applications: Voicemail(), which handles the portions of a user leaving a message on the system; and VoicemailMain(), which handles the users of the PBX to access their voice mail.We briefly touched upon VoiceMail()

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-conglomocorp)
exten => s,3,Background(conglomocorp-mainmenu)
exten => 100,1,Voicemail(u100)
exten => 200,1,Voicemail(b200)
exten => 300,1,VoicemailMain()
exten => 400,1,VoicemailMain(${CALLERID(num)})

Extension 100 sends you to voice mail to leave a message for mailbox 100. The u preceding the mailbox number tells Asterisk to use that mailbox’s “unavailable” greeting. Extension 200 does the same thing, except this time the b preceding the mailbox number tells Asterisk to use that mailbox’s “busy” greeting. Besides the greetings, both of these do the same thing: they take a message for the mailbox they are given. Extension 300 sends you to the voicemail system as if you are a user of the system. In this case, the system will prompt you for a mailbox number and password and if you give it valid credentials, it will let you listen to messages for that mailbox. Extension 400 does the same thing, except it attempts to find a mailbox corresponding to the caller’s caller ID number. If it does, it will prompt just for the password. If it does not, it will behave as if there was no number given to it.

The default keys are “1” to play messages, “6” to skip to the next message, “4” to go to the previous message, and “7” to delete the current message.

Step 20: Configure Music On Hold
The musiconhold.conf comes with a music on hold class ready for files, so often all you need to do is put some ulaw encoded files of your favorite songs in the moh/ subdirectory of your Asterisk sounds directory, usually /var/lib/
musiconhold.conf generally looks like

[default]
mode=files
directory=/var/lib/asterisk/moh

If you want to add another class for the support department.
Just add:

[support]
mode=files
directory=/var/lib/asterisk/moh/support

Then create the directory and add ulaw encoded files to /var/lib/asterisk/moh/support.
Once this is done, you will need to edit the support context and assign a new music
on hold class to it.You can do this via the SetMusicOnHold() command. Using the supportmenu
we would set the class like this:

[supportmenu]
exten => s,1,SetMusicOnHold(support)
exten => s,2,Background(conglomocorp-supportmenu)
exten => 1,1,Dial(SIP/blivetsupportline)
exten => 2,1,Dial(SIP/widgetsupportline)
exten => 3,1,Dial(SIP/frobsupportline)
exten => #,1,Goto(s,2)

This now assigns the caller to the support class until another command assigns it
to somewhere else. To configure your musiconhold.conf to support MP3s,
you will need to change the mode= to custom and specify the exact syntax of the MP3 player command:

[RiverBottomGang]
mode=custom
directory=/var/lib/asterisk/moh/RiverbottomNightmareBandMP3s
application=/usr/bin/mpg123 -q -r 8000 -f 8192 -b 2048 --mono -s

This example would create a new class called RiverBottomGang, which would then
use MPG123 to play all the songs in

/var/lib/asterisk/moh/RiverbottomNightmareBandMP3s.

This is somewhat less reliable than using ulaw encoded files because of the conversions involved.
N.B.: Sometimes, if your files are not encoded in a way that is just right, your music on hold will sound like it is playing a twice the speed.

[supportmenu]
exten => s,1,SetMusicOnHold(support)
exten => s,2,Background(conglomocorp-supportmenu)
exten => 1,1,Dial(SIP/blivetsupportline)
exten => 2,1,Dial(SIP/widgetsupportline)
exten => 3,1,Dial(SIP/frobsupportline)
exten => #,1,Goto(s,2)


Step 21: Configure Call Queues
In a call queue, all callers form a virtual line wait to be answered by a person answering a phone. When an “answerer” hangs up, the system takes the next person out of the queue and rings the answerer’s phone.
Call queues are managed by queues.conf.A typical call queue configuration would
look like this:

[supportqueue]
musicclass=support
strategy=ringall
timeout=10
wrapuptime=30
periodic-announce = conglomocorp-your-call-is-important
periodic-announce-frequency=60
member=>SIP/10
member=>SIP/20

Starting off each queue section is the queue’s name written in brackets. The next line defines the queue’s music on hold class—which, here, is the support class we defined in the last section. The strategy line defines the ringing strategy—in this case, ringall: ring all the phones until someone picks up. The system can be configured to use a roundrobin system that will ring the phones one by one starting from the first, or do a roundrobin with memory called rrmemory in which the system will start with the next phone after the phone it rang last. The timeout line specifies how long, in seconds, a phone should ring until the system determines that no one is there. The wrapuptime line specifies how long, also in seconds, after a call is completed that the system should wait before trying to ring that phone again. The periodic-announce and the periodic-announce-frequency specify a sound file the system should play for callers instead of the music on hold music and how long it should wait after playing a file until playing it again. Finally, each member line adds a member to the pool of phones that have people answering the queue.

[supportmenu]
exten => s,1,SetMusicOnHold(support)
exten => s,2,Playback(conglomocorp-welcome-to-support-queue)
exten => s,3,Queue(supportqueue)

Step 22: Setting Agents
agents.conf In this file, you can control the sounds the agents hear when they log on and off, whether or not you want to record the conversations they have with callers, and what music on hold class the agents should be assigned. The part in which you would control agents is at the bottom of the file at the end of the [agents] section. Each agent will be configured by an agent line. The agent line syntax is:

agent => AgentNumber,Password,AgentName

If we add some agents for our queue:

agent => 1001,867,Joe Random Agent
agent => 1002,5309,James Random Agent

Now edit the support queue:

[supportqueue]
musicclass=support
strategy=ringall
timeout=10
wrapuptime=30
periodic-announce = conglomocorp-your-call-is-important
periodic-announce-frequency=60
member=>SIP/10
member=>SIP/20
member=>Agent/1001
member=>Agent/1002

Step 22: Setting Up a Conference

The first step in setting up a conference is opening up meetme.conf and adding a conference room. Conference rooms are numbered, but these are only used when connecting to conferences from extensions.conf. Users should never have to interact with them.
In meetme.conf, the conference rooms are listed under the [rooms] section.The
syntax for rooms are

conf => RoomNumber,UserPIN,AdminPIN

In a conference room, both the User PIN and Admin PIN are optional. Let’s set
up a simple, un-PINed conference room.

conf => 1234

Now, let’s edit our extensions.conf. We are putting this in a separate context for the
same reason we put the agent login in a separate context: we don’t want regular users to stumble into the conference by accident.

[conference]
exten => s,1,MeetMe(1234)

Now, just set up a way to access this context and issue a reload command to the Asterisk CLI. You should be all set. When entering the context, you should hear two beeps and silence. Then, when someone else calls in, you should both hear the same two beeps and subsequently be connected to each other. This process repeats for each person who connects. Put yourself on the back.



AddThis Feed Button

Running and Managing Asterisk

Running and Managing Asterisk:

asterisk -vvvc

It will execute the server. These options tell the server not to run in the background and to run at a verbosity level of three, which means all the important messages will be displayed and enough less important ones and that the user will see all diagnostic messages. While many messages will quickly scroll by on the screen, most of these are simple initialization messages that can be ignored. If any fatal errors occur, Asterisk will stop and exit so the message remains on the screen. Asterisk will display “Asterisk Ready” when it has successfully run.

asterisk

The other way to run Asterisk is to start the daemon by running the command without any arguments at the command prompt.This will start the server in the background. Starting in the background as opposed to the foreground has advantages and disadvantages. While the server won’t tie up a terminal or exit when the terminal is closed, it will not display any diagnostic messages to the terminal during startup either. Running Asterisk in the background is the most common way to run Asterisk since normally an Asterisk process would be running at all times. One would want to run Asterisk in the foreground if diagnosis information is needed. To connect to an already running Asterisk process, run the command.

asterisk -vvvr

This will duplicate the verbosity settings to the above command.

You can issue the stop or restart command to Asterisk in three ways. When issuing the restart or stop command, you can tell Asterisk to do it now, gracefully, or when convenient.These control how the server will go about shutting down.

now : The server process is shut down immediately, without any concerns for activity.Any active calls are terminated and all active threads are killed.This is not normally the way to shut down the server in a production environment.


gracefully: it is a much cleaner way to shut down or restart. After the command is issued, Asterisk stops answering all new calls.

convenient: continues functioning normally, the server restarts or stops when there are no active calls within the system. While this is the best when talking in terms of lost productivity, if the system constantly has active calls on it, the system will never stop or restart.

reload : reloads all the configuration files on-the-fly without interrupting system activity.

Configuring Asterisk:
If you enter into your Asterisk configuration directory, /etc/asterisk, you’ll see 65 files.
Asterisk Configuration Files:
adsi.conf Controls Asterisk Analog Display Services Interface settings.
adtranvofr.conf Contains settings related to Voice over Frame Relay and AdTran equipment.
agents.conf Contains settings for call agents that work call queues.
alarmreceiver.conf Contains settings for the Alarm Receiver application.
alsa.conf Contains settings for the CLI sound system if using ALSA sound drivers.
amd.conf Contains settings for answering machine detection on outbound calls.
asterisk.adsi Asterisk Analog Display Services Interface script.
cdr.conf Contains settings for Call Detail Records (CDRs).
cdr_custom.conf Contains settings for custom Call Detail Record mappings.
cdr_manager.conf Contains settings for sending CDRs to the Asterisk Management Interface.
cdr_odbc.conf Contains settings for storing your CDRs into a database connected via ODBC.
cdr_pgsql.conf Contains settings for storing your CDRs into a PostgreSQL SQL database.
cdr_tds.conf Contains settings for storing your CDRs into a FreeTDS database.
CODECs.conf Contains CODEC settings.
dnsmgr.conf Contains settings about Domain Name System (DNS) lookups done by Asterisk.
dundi.conf Controls Distributed Universal Number Discovery connections and settings.
enum.conf Controls Telephone Number Mapping/E164 connections and settings.
extconfig.conf Contains mappings for external database connections for configuration settings.
extensions.ael Contains the dial plan settings, written in Asterisk Extension Language.
extensions.conf Contains the dial plan settings.
Features.conf Contains settings for call parking.
festival.conf Contains settings for the connection between Asterisk and the Festival TTS Engine.
followme.conf Contains settings for the FollowMe application.
func_odbc.conf Contains settings for template-based SQL functions accessed via ODBC.
gtalk.conf Controls Google Talk connections and settings.
h323.conf Controls H323 Protocol connections and settings.
http.conf Contains settings for Asterisk’s integrated HTTP server.
iax.conf Controls Inter Asterisk eXchange Protocol Connections and Settings.
iaxprov.conf Contains settings for IAXy provisioning.
indications.conf Contains settings for the system’s Ring, Busy, Reorder, and Special Information tones.
jabber.conf Controls Jabber Protocol connections and settings.
logger.conf Contains settings about where and what to log.
manager.conf Contains settings for the Asterisk Management Interface.
meetme.conf Contains settings for the MeetMe conferencing system.
mgcp.conf Controls Media Gateway Control Protocol connections and settings.
misdn.conf Controls Integrated Serial Digital Networks (ISDNs) connections and settings.
modem.conf Controls ISDN modem settings.
modules.conf Controls which applications and modules are loaded when the server is started.
musiconhold.conf Contains Music on Hold settings.
muted.conf Contains settings for the Mute Daemon.
osp.conf Controls settings and connections for the Open Settlement Protocol.
oss.conf Contains settings for the CLI sound system if using OSS sound drivers.
phone.conf Contains settings for Linux Telephony devices.
privacy.conf Contains settings for the PrivacyManager application.
queues.conf Contains settings for call queues.
res_odbc.conf Contains settings for external database connections for configuration settings.
res_snmp.conf Contains Simple Network Management Protocol settings for the SNMP application.
rpt.conf Controls settings of the app_rpt application, which enables radio systems to be linked via VoIP.
rtp.conf Contains Real-time Transport Protocol settings.
say.conf Contains string settings for the various say_* applications.
sip.conf Controls Session Initiation Protocol (SIP) connections and settings.
sip_notify.conf Contains settings for SIP’s NOTIFY command.
skinny.conf Controls Skinny Client Control Protocol connections and settings.
sla.conf Controls Shared Line Appearance connections and settings.
smdi.conf Contains settings for the Simplified Message Desk Interface.
telcordia-1.adsi Default Telcordia Analog Display Services Interface script.
udptl.conf Contains settings for UDPTL, one of the transports for Faxing over IP Networks.
users.conf A file that controls a combination of settings, allowing for easier user maintenance.
voicemail.conf Contains voice mail settings and mailbox details.
vpb.conf Contains settings for VoiceTronix hardware.
zapata.conf Controls settings for Zapata hardware.

Step 10: Configuring Dial Plan
The dial plan is the logic behind how phone calls are routed through your Asterisk installation. Asterisk runs every incoming call, every outgoing call, and every call in between extensions through the dial plan logic in order to determine where it should go and whether or not it should be completed. The dial plan is contained in extensions.conf, and therefore it can be said that extensions.conf is easily the most important configuration file in Asterisk. Removing extensions.conf is similar to removing a traffic light at a complicated intersection; cars will want to enter and cars will want to leave, but there will be no way to direct them. extensions.conf can be broken down into three major parts: 1. Contexts, 2. Extensions, and 3. Variables. Each has their own unique and important function and needs to work together for a good dial plan to function.

1. Contexts : A context is a simple way for grouping extension commands based on what the user has dialed.To begin a context, put the name of a context by itself in square brackets. Each context then contains a list of commands. In extensions.conf there are two special contexts called [general] and [globals] in which certain settings can be set. general has a few special settings that define how extensions.conf behaves. First off is the static setting.This, can be set to either yes or no, but for some reason, only yes has been implemented.This will eventually control Asterisk from rewriting the extensions.conf every time an extension is added or deleted.The next setting is writeprotect. This can also be set to either yes or no, and this controls the ability of someone at the CLI to rewrite your dial plan via the save dialplan command.This may seem handy, but doing so will delete all comments in the file. Each extension follows a similar syntax. exten => EXTENSION,PRIORITY,COMMAND(ARGS). exten => precedes every extension.This is a directive that tells Asterisk to define an extension, as opposed to a context.The next three parts of an extension are 1) EXTENSION, 2) PRIORITY, and 3) COMMAND(). Let’s cover these three portions.

1) EXTENSION--- Extensions can be broken down into three types: a constant extension, a wildcard extension, and a special extension. A constant extension is an extension that when coded to a literal constant is the dial plan. A wildcard extension is a context that uses wildcards to match multiple possibilities for the extension.Wildcards can be either internal Asterisk wildcards or RegEx-like patterns given below:

[0126-9]--- Any digit within the pattern. (In this case: 0,1,2,6,7,8, and 9).
X ---Any number 0 through 9. The equivalent of [0-9].
Z --- Numbers between 1 through 9. The equivalent of [1-9].
N -- Numbers between 2 through 9. The equivalent of [2-9]. This scheme is used most commonly in Area Code and Prefix assignments.
.(dot)--- Any number, one or more times.

Example: Let’s say a department in your building, the ever-important Chemical department, have moved to another division and wanted to leave a message at their old extensions informing callers that they had moved.They previously occupied Extensions 300 through 329 on your PBX. Rather than rewrite 30 lines; you can add a single extension of
exten => 3[0-2]X,1,Playback(ChemicalDeptHasMoved)
This will have any caller dialing the department’s former extensions greeted by a message informing them of the move.

N.B. - Playback is a command that plays back a sound file stored on the system.

In addition to wildcard and literal extensions, there are also special extensions that correspond to special events in the dial plan:

S --> Start --> Used when a caller is put in a context before dialing a number.
I --> Invalid --> Used when a caller dials an extension not defined in the current context.
H --> Hangup --> Used when a caller hangs up.
T --> Time Out --> Used when a caller does not respond within the response timeout period.
T --> Absolute
Time Out --> Used when a caller does not respond within the about timeout period.
O --> Operator.

2) PRIORITY--- it controls the flow in which commands are executed. For each extension, this is either controlled by an increasing number or a special n syntax.The n syntax tells Asterisk to execute the extension one line after the other:

[incomingcall]
exten => s,1,Answer()
exten => s,n,Playback(mainmenu)
exten => s,n,Hangup()

In this example, any call being routed to the “incomingcall” extension in Asterisk would have its call answered, a menu would then play, and then the call would be terminated. After Asterisk finishes executing one line, the next line would be executed. Numbering the steps provides greater flexibility with the dial plan since it is possible to control the flow logically rather than line by line. For example, the extension shown earlier could be rewritten with a numbered sequence

[incomingcall]
exten => s,2,Playback(mainmenu)
exten => s,1,Answer()
exten => s,3,Hangup()

Asterisk still answers, plays the menu, and hangs up because it executes by line number rather than by the order in which the lines appear. It executes step 1, followed by steps 2, and then 3.These steps could be scattered throughout the context and intertwined with hundreds of extensions. As long as they are numbered correctly, Asterisk will execute them in order for that context.

3) COMMAND()----The commands are the heart of any dial plan.They are what actually cause Asterisk to answer the call, ring the phone, transfer the call, play the menu, and do numerous other things.

Dial(CHANNEL) ---> Dials a channel
Answer() ---> Answers a ringing channel
Playback(FILE) ---> Plays a sound file in the foreground
Background(FILE) ---> Plays a sound file in the background, while waiting for the user to input an extension
Hangup() ---> Hangs up the call
SayDigits(NUMBER) ---> Says a number, digit by digit

N.B: Extensions are the physical numbers assigned to a device, while channels, on the other hand, are the connections to the devices themselves.
For example, you can have a phone at your desk set up to ring on three separate extensions; however, each of these extensions will ring the same
channel—namely, your phone.

2. Extensions: Variables in extensions.conf are nothing special.They act like variables in any other language.Variables are set via the Set() command and are read via the variable name encased in ${}:

[example]
exten => s,1,Set(TEST=1)
exten => s,2,NoOp(${TEST})

Variables are common in simple dial-plan applications and Asterisk uses certain variables for internal functions, but their use is somewhat uncommon in regular dial plan usage.

Now a very extensions.conf looks like:

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-)
exten => s,3,Background(-mainmenu)
exten => s,4,Hangup()
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)


Now what it mean is : When a call enters the [default] context, it is answered by Asterisk. Asterisk then starts playing the mainmenu sound file while waiting for the caller to enter digits. At this point, the caller can either enter 100 and be connected to the channel SIP/10 or 20 and be connected to the channel SIP/20. If the menu finishes playing and the user has not entered any digits, the call will be hung up on.

Now we try to take the file we had before and use some special extensions to have the menu replay if the user hasn’t entered an extension and inform them if the extension they entered is invalid.

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-)
exten => s,3,Background(-mainmenu)
exten => t,1,Goto(s,2)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,2)
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)


Creating submenu: Now to have a support menu that allows customers to direct their questions to the appropriate support group. We can accomplish this by creating a second context that contains the appropriate menu and extensions. Let’s build on the previous example again and add a second menu that allows callers to be connected to the Technical, Widget, or Chemical support lines.

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-socal)
exten => s,3,Background(socal-mainmenu)
exten => t,1,Goto(s,2)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,2)
exten => 3,1,Goto(s,1,supportmenu)
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)
[supportmenu]
exten => s,1,Background(socal-supportmenu)
exten => 1,1,Dial(SIP/technicalsupportline)
exten => 2,1,Dial(SIP/widgetsupportline)
exten => 3,1,Dial(SIP/chemicalsupportline)
exten => #,1, Goto(s,2,default)
exten => t,1,Goto(s,1)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,1)


Now here If a caller dials 3, they are connected to the [supportmenu] context with a Goto() statement. Goto() can be called many different ways.You can jump between priorities in the same extension by just specifying Goto(priority) or you can jump between extensions in the same context by specifying Goto(priority,extension). Lastly, you can switch contexts by specifying Goto(context, extension, priority).

N.B: For example: Goto(supportmenu,s,1) will behave differently than Goto(supportmenu, s, 1). In the first example, Goto will behave as expected and jump to the “s” extension, priority 1. However, in the second example, Goto will jump to the “s” extension, priority 1. Note how there is a space that precedes the “s”. This can be a source of frustration if you don’t know to look for it.

Asterisk permits other contexts to be joined together via the include => directive.This allows other contexts to be include-ed into the current context and act as one giant context.

Creating Voice Mail Support for Existing Extensions:
[default]
include => specialextensions
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-socalLabs)
exten => s,3,Background(
socalLabs-mainmenu)
exten => 3,1,Goto(supportmenu,s,1)
exten => 100,1,Dial(SIP/10,20)
exten => 100,2,Goto(s-100-${DIALSTATUS},1)
exten => s-100-NOANSWER,1,Voicemail(u100)
exten => s-100-NOANSWER,2,Hangup()
exten => s-100-BUSY,1,Voicemail(b100)
exten => s-100-BUSY,2,Hangup()
exten => _s-.,1,Goto(s-100-NOANSWER,1)
exten => 200,1,Dial(SIP/20)
exten => 200,2,Goto(s-200-${DIALSTATUS},1)
exten => s-200-NOANSWER,1,Voicemail(u200)
exten => s-200-NOANSWER,2,Hangup()
exten => s-200-BUSY,1,Voicemail(b200)
exten => s-200-BUSY,2,Hangup()
exten => _s-.,1,Goto(s-200-NOANSWER,1)
[supportmenu]
include => specialextensions
exten => s,1,Background(
socalLabs-supportmenu)
exten => 1,1,Dial(SIP/blivetsupportline)
exten => 2,1,Dial(SIP/widgetsupportline)
exten => 3,1,Dial(SIP/frobsupportline)
exten => #,1,Goto(s,2)
[specialextensions]
exten => t,1,Goto(s,1)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,1)

Step 11: Configuring extensions.ael :
The alternative to extensions.conf is extensions.ael. extensions.ael is extensions.conf written in a scripting language called Asterisk Extensions Language (AEL). AEL is language maintained by Digium solely for writing dial plans in Asterisk. While it is functionally equivalent to extensions.conf, AEL is syntactically much more powerful and allows for greater flexibility in simple scripting and logical operations.

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-)
exten => s,3,Background(-mainmenu)
exten => s,4,Hangup()
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)

is written in extensions.conf the same thing we can write in extensions.ael like this,

context default {
s => {
Answer();
Background(thank-you-for-calling-conglomocorp);
Background(conglomocorp-mainmenu);
Hangup();
};
100 => Dial(SIP/10);
200 => Dial(SIP/20);
};

And this

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-conglomocorp)
exten => s,3,Background(conglomocorp-mainmenu)
exten => t,1,Goto(s,2)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,2)
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)


can be this

context default {
s => {
Answer();
restart:
Background(thank-you-for-calling-conglomocorp);
Background(conglomocorp-mainmenu);
Hangup();
};
100 => Dial(SIP/10);
200 => Dial(SIP/20);
t => { goto s|restart;}
i => {
Playback(sorry-thats-not-valid);
goto s|restart;
}
};


Step 12: Protocols Support :
SIP --> Session Initiation
Protocol --> Most common VoIP protocol. Used in numerous devices.
IAX --> Inter Asterisk
eXchange Protocol --> Used primarily in connections between Asterisk servers.
SCCP --> Skinny Client
Control Protocol --> Used in Cisco devices.
MGCP --> Media Gateway Control Protocol --> Used in some VoIP devices, notably D-Link.
H323 --> H.323 Protocol --> Used in some older VoIP devices.

Each protocol is controlled by a different file. Multiple connections can be set up in a single file, or the files can be broken down and linked via include statements. Each file has certain specific configuration options that are used only for the protocol the file governs, and they also have options that are common across all files. Let’s go over some of the conventions:

Have a look at iax.conf

[my_iax_server]
type=peer
auth=md5
notransfer=yes
host=10.0.23.232
disallow=all
allow=ulaw


Asterisk uses some peculiar classifications for its VoIP connections.They are classified by the type= setting, which is either set to user, friend, or peer.
A user is a connection that will be used to make telephone calls to the local server; a peer is a connection that will be used to make telephone calls from the local server; and a friend is a connection that will be used to make telephone calls both to, and from, the local server.


Step 13: Allowing and Disallowing Codecs
Asterisk supports numerous codecs for audio. Codecs can save bandwidth and allow for more simultaneous phone calls on a data link.

Codecs Speed Simultaneous Calls
ยต-Law---> 64 Kbps -------> 24
G.723.1 --->5.3/6.3 Kbps -->289/243
G.726 --->16/24/32/40 Kbps --->96/64/48/38
G.729 ----->8 Kbps ------------> 192----------> Requires license
GSM ------->13 Kbps ----------->118
iLBC -------->15 Kbps ----------->102
LPC-10 ------>2.5 Kbps ---------->614
Speex ------->2.15 to 44.2 Kbps -->714 to 34----> “Open” codec

Say your shiny new Asterisk server has a connection to your telephone provider via the IAX2 protocol. However, whenever a phone call is made through the provider, the GSM codec is used, rather than the ulaw codec that is used when you call between extensions in the office.This needs to be fixed. So opening up the iax.conf configuration file you add the following line to the section controlling the connection:

disallow=gsm
Then issue a reload command to Asterisk.

The correct way to ensure ulaw is used as the codec would be to add the following lines to iax.conf.
disallow=all
allow=ulaw


Step 14: Configuring SIP Connections

SIP is the most common VoIP protocol in use today. It is an official Internet standard and is supported by almost every VoIP device and service on the market. SIP connections are configured in the sip.conf file in the system’s configuration directory, usually /etc/asterisk.

To address the firewall issue, you need to open up the firewall to allow connections from external sources to the Asterisk server on a massive amount of ports.This is a bit of an issue if the server is accepting connections from all over the Internet since there is no way to lock the access down to specific address blocks.A way to limit the amount of ports you need to open up is to edit rtp.conf in the Asterisk configuration directory:

;
; RTP Configuration
;
[general]
;
; RTP start and RTP end configure start and end addresses
;
rtpstart=10000
rtpend=20000


In sip.conf, there are three settings: the externip setting, the localnet setting, and the nat setting.The nat setting determines whether or not the server is behind a NAT.This can be set to four different settings: yes, no, never, and route.The yes setting is the straightforward setting. It informs Asterisk that we are behind a NAT and it should assume so whenever it sends SIP messages.The no setting is a bit more complicated than “No, the server is not behind a NAT.”The no setting tells Asterisk it should use RFC3581 to determine whether or not there is a NAT between the local server and the remote server.The next setting, route, is a bit of a kludge to help NAT work with certain phones that do not completely support RFC3581; you likely will never use this, and hopefully this behavior will be moved to another setting in future versions. Finally, there is never, which informs Asterisk to never think the server is behind a NAT.
For example, let’s say we have a server at our office on a 196.168.42.0/24 network that is NATed behind a gateway with an external IP address of 118.23.45.76.This is how we would make our NAT settings:

[general]
nat=yes
externip=118.23.45.76
localnet=192.168.42.0/24


Step 15: Connecting to an SIP Server
1) Registering Your Connection: Most providers do not have your account tied to a specific IP address since it’s becoming less and less common to have static IP addresses in most situations and it’s less of a hassle for you to come to them. So how do we let the provider know where to route the incoming calls? We register with them. Registering is a way of checking in with a remote server, letting them know where to route calls and that the local server is still alive.A typical register line in sip.conf would look like this:

register => auro:mondal@voip.globaltelephone.com/3115552368

In which, after a reload, we would be registering the phone number “311-555-2368” with the server voip.globaltelephone.com using the username karthik and the password reddy.
N.B: Asterisk doesn’t have any security on its configuration files by default, so before you add any sensitive information, you may want to make sure the file permissions are locked down enough that the only nonprivileged user that can read them is the user Asterisk is running under.



AddThis Feed Button