Asterisk PBX on Debian Stable Part 1

What this guide is:

This is basically a step by step reference of an Asterisk PBX quick start setup for anybody who wants to try it out, or if you are going to work for a company which sets up Asterisk PBX telephone systems.

What this guide isn’t:

This is by no means a complete guide, although it is an ongoing reference which I will add to it as I see fit.

Asterisk Docs and Info:

Asterisk is a hugely versatile and complete Open Source telephony system which already has its own documentation, man pages (man asterisk), support forums and wiki.

Debian:

This guide supposes that you have Debian Stable (Currently Lenny) installed, either as your main OS or as a server on the network.

Install and test Asterisk: (Do all the following as root, not with sudo)

apt-get install asterisk asterisk-dev asterisk-dbg asterisk-h323 asterisk-mp3 libasterisk-agi-perl asterisk-doc

We use Perl scripts for automated dialers and other advanced options, so I have added the Perl modules, that’s up to you. You may also like to do an “apt-cache search asterisk” if you need any language-specific files. As I am in Spain, I also add “asterisk-prompt-es”.

Test Asterisk (still as root)

asterisk -vvvvc

As I already have Asterisk installed, it automatically loads at boot, so the message I get is that it is already running:

ricpru:~# asterisk –vvvvc
Asterisk already running on /var/run/asterisk/asterisk.ctl.  Use ‘asterisk -r’ to connect.

So I do as it says:

ricpru:~# asterisk -r
Asterisk 1.4.21.2~dfsg-3+lenny1, Copyright (C) 1999 – 2008 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.
==============================================
This package has been modified for the Debian GNU/Linux distribution
Please report all bugs to http://bugs.debian.org/asterisk
==============================================
Connected to Asterisk 1.4.21.2~dfsg-3+lenny1 currently running on ricpru (pid = 1844)

And I am left with the Asterisk prompt:

ricpru*CLI>

Asterisk is installed and working!

So now what?

First you need to get used to the config files. Then you need to select a phone. Asterisk works with Softphones , Analogue phones, IP phones, Mobile phones, Fax machines, basically anything that can be connected to a network or has an IP address and can make a call or send data.

Where are the config files?

ls /etc/asterisk

Yup, they all end in .conf and there are loads of them! Don’t panic! We are only going to start with a IAX/SIP Software Phone, which is the most basic to configure.

adsi.conf cdr_odbc.conf  features.conf  logger.conf  phone.conf  skinny.conf adtranvofr.conf  cdr_pgsql.conf   festival.conf  manager.conf  privacy.conf  sla.conf agents.conf         cdr_tds.conf  followme.conf  manager.d  queues.conf  smdi.conf alarmreceiver.conf  codecs.conf  func_odbc.conf  meetme.conf  res_odbc.conf  telcordia-1.adsi alsa.conf           dnsmgr.conf  gtalk.conf  mgcp.conf  res_pgsql.conf   udptl.conf amd.conf  dundi.conf   h323.conf  misdn.conf  res_snmp.conf  users.conf asterisk.adsi enum.conf  http.conf       modules.conf  rpt.conf  voicemail.conf asterisk.conf  esel.conf  iax.conf musiconhold.conf  rtp.conf  vpb.conf cdr.conf  extconfig.conf   iaxprov.conf  muted.conf  say.conf  watchdog.conf cdr_custom.conf  extensions.ael   indications.conf  osp.conf  sip.conf  zapata.conf cdr_manager.conf  extensions.conf  jabber.conf  oss.conf        sip_notify.conf

Software SIP/IAX phones:

Skype, Ekiga, etc etc….. there are loads, Google them and choose what you want. Personally I prefer VoixPhone. It’s easy to install and has a lot of features including IAX and SIP, but it’s all a matter of personal choice. The reason I want a phone with IAX is that we also use those configs for Hard Phones such as the Thomson ST2030 IP phone.

Download VoixPhone from HERE, Unpack it, Chmod -x it, and ./ Install it.

*HINT* I installed VoixPhone to /usr/local/bin as opposed to /usr/local which is the default and created a launcher called voix. This way I can launch the VoixPhone executable as voix from the command line.

Create an empty launcher file:

vim /usr/local/bin/voix

Insert this text:

# cat >/usr/local/bin/voix <<EOF
#!/bin/sh
/usr/local/bin/voixphone/VoixPhone
EOF

Then make it executable:

chmod 755 /usr/local/bin/voix

*64bit Hint* VoixPhone is a 32bit app. If you are running a 64bit system, install the ia32 libs:

apt-get install ia32-libs ia32-libs-gtk

Part 2 – Configuring Asterisk and your new VoixPhone:

PART 2 Coming soon………………………

In the meantime, have a read of this PDF Handbook and My Asterisk Bible 🙂

Asterisk PBX Manager

Monitoring Asterisk and Executing Commands

The manager is a client/server model over TCP. With the manager interface, you’ll be able to control the PBX, originate calls, check mailbox status, monitor channels and queues as well as execute Asterisk commands.

AMI is the standard management interface into your Asterisk server. You configure AMI in manager.conf. By default, AMI is available on TCP port 5038 if you enable it in manager.conf.

Events, Actions and Responses

AMI receive commands, called “actions”. These generate a “response” from Asterisk. Asterisk will also send “Events” containing various information messages about changes within Asterisk. Some actions generate an initial response and data in the form list of events. This format is created to make sure that extensive reports do not block the manager interface fully.

Management users are configured in the configuration file manager.conf and are given permissions for read and write, where write represents their ability to perform this class of “action”, and read represents their ability to receive this class of “event”.

Asterisk Documentation: http://www.asterisk.org/docs

How to redirect old website url to new url including page links

The situation is that you have an old domain with a website or even various websites and sub-domains. You have moved all your files to another server or web address but you don’t want to lose the traffic from all the people who have bookmarked or link to you.

You want http://myoldcrapsite.com/a_post_about_monkeys.html to lead to http://mylovelynewsite.com/a_post_about_nicer_monkeys.html

In fact, you want ALL old links to go to the exact same place on the new server. This is how you redirect everything all in one go permanently with the htaccess file.

Creat a .htaccess file (don’t forget the DOT before it, it’s hidden from public view)

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^myoldcrapsite.com [nc]
rewriterule ^(.*)$ http://mylovelynewsite.com/$1 [r=301,nc]

Upload it to the root of your website, usually where your index.html or index.php files are and you are all set. Google some of your old links and see where they take you. It should be to the same page on the new website.

One thing to remember is this will only work on a Linux Apache webserver which allows the Mod Rewrite function.

PS: If you are on a Windows Server, try Googling the html redirect method.

That’s it, now all incoming links from any of the old posts/pages will be forwarded to the new site 🙂

How to Linux quick, easy, file sharing server with one command

Don’t install a server, just issue one command!

So, you want to share a file with a friend. It could be a document, a song, a directory of photos, anything.

Do you want to install and set up a server? NO!

Do you want to go to a directory and issue one command? YES!

Open your terminal and cd to the directory where you want to share the file(s) from:

cd /home/rich/shared

Now start the Python Simple HTTP Server:

python -m SimpleHTTPServer

That’s it! Open your browser and go to this url:

http://localhost:8000 or http://127.0.0.1:8000

Now you will see the files that you want to share. All you need to do is send a message to your friend with your IP address and port :8000 and he/she can download anything from your /shared directory.

You can get your external IP address by going to:

http://www.whatsmyip.org/

Once you have finished, go back to your terminal and hit Ctrl+C and the server will stop.

LxH is closing down

Goodbye Linux-Hardcore

After a lot of thinking, humming and hahing (is that how you spell it?), I have decided to finally shutdown my linux-hardcore.com domain. I have spent the last few months handing other sites to friends who offered to take them over, and i’ve just shutdown the other sites which no longer served a purpose or weren’t getting any interest.

Samey Linux Community

There must be millions of Linux blogs and forums now, and whatsmore they all seem to have the same stuff. The newest theme for Ubuntu YAY! [/sarcasm], How to burn an iso [/yawn]….. but not much else. It just got so hard to find anything interesting, or to find a blog/forum with character or soul. Most forums now inflict so many rules that they just beat the members into submission, and blog after blog just repeat the news from everybody else, sometimes just blatantly copy ‘n’ pasting. I just lost interest completely.

Crunchbang Linux & Community

This is probably the only place you’ll find me posting occasionally as Crunchbang Statler is an awesome distro, and the community is great. Not too big, not too small but always interesting, helpful and fun.

Thanks to the LxH Crew

It’s been a great 5 (ish) years and we’ve seen a lot of changes in the Linux community as well as formed part of many changes ourselves. Linux projects need a good team, and I was lucky enough to be a part of something that kept me learning and meeting new people practically every day over 5 years.

Thanks go out to djsroknrol, resa, machiner, palemoon, ch@dfluegge who stuck it out through thick and thin both on LxH and Dreamlinux Forums, thanks guys, it’s been a pleasure.

Bit of LxH History 2006 – 2010

LxH  started out as a small community forum hosted at Forumer in 2006, then went to it’s own Godaddy server in 2007. A year later it was moved to ICDSoft where it remains until the end of September 2010. It has had 3 domain names, but has settled on the LxH name, even though home and work-based firewall filters sometimes block the site for having the word “Hardcore” in the title. (I should have thought that one through a little better).

Why Create Yet Another Linux Support Forum?

We are/were all members of larger Linux distro support forums, and noticed that as forums become bigger, the community becomes more impersonal. Larger communities need stricter moderation, more rules and therefore more control. A smaller community needs practically no (people) moderation, only (site) administration. As we aren’t the public image for a company, we don’t have to censor what people post, and therefore the discussions are more “real life”, and permit free speech to a certain extent.

Forum Software

The forum has almost exclusively been run on the SMF forum script, apart from a short-lived experiment with PhPBB in 2007. There have been various designs, layouts and ideas, but basically has now gone with the easier route of having WordPress as a Frontpage due to it’s flexibility and custom plugins.

I tried various SMF portals, Joomla, Drupal cms’s, but none seemed to provide what we were looking for.  I even looked at vBulletin as an option until I realized that using proprietary forum software would be pretty hypocritical for a Linux/Foss based forum. Planet was also recently added to keep everybody updated with LxH members’ and friends’ blogs.

Statistics

LxH currently has over 16,000 Posts in over 2,000 Topics. The Member List is “spring cleaned” regularly and any zero posters, or members who haven’t logged in for a while get removed. Many forums leave all members intact to look “busy” or “popular”, I prefer to keep things clean. It’s quality, not quantity that counts. Whatsmore, LxH is /home for a few “hardcore” friends and was never meant to be the size of Ubuntu Forums for example. LxH Distro-Tests, Howto Guides and Articles regularly attracted over 200,000 hits per month.

Other LxH Founded Sites

We set up and manage: Dreamlinux Forums, Fossunet (Facebook for Foss/Linux users), Linux Gaming NewsConky Hardcore!, LxH Clan Wars (A Travian style MORPG).

Max has moved Linux Gaming News to wordpress.com while he decides what to do with it. Good luck Max! It’s an awesome site.

Conky Hardcore! was taken over by machiner and is already back on its feet again. That is going to be another great site for Conky fans. Thanks for taking it on machiner, i’m sure you will make it a success!

I have moved my blog here to wordpress.com as well, as my final server and domain is laid to rest.

So that’s it, the end of an era for me.

Starting with Perl

I have started to use Perl regularly at work for network, server and telephony systems. Bearing in mind that before I got into Perl, my only other exposure to code was html/php/css for my websites and forums, configuring Conky and putting a few Bash scripts together.

Getting into Perl

Everybody learns differently, and I found it very difficult to grasp Perl just by reading books, man pages and websites. All of these will explain the history of Perl and give you links to everything it can do. This is all well and good until you need to do something specific.

Perl – Conky example

For me personally, to “get” something, I need to have an aim, and put it into action. It’s a bit like when you decide you want to display the weather on Conky with some fancy images, you Google “conky weather” and look for the code that will get the data, then show it at a certain position. You know what you want to do, then you look up how to achieve the goal. I went about learning Perl this way. Have a goal, and look for the way to do it.

How to create a bootable USB pendrive Debian netinstall

**NOTE 1** There are various ways to create pendrive Linux installs, some work and some fail depending on the pendrive model and also how the computer BIOS boots from USB.
**NOTE 2** This didn’t work with a HP 4Gb pendrive, but did with my Kingston pendrive. Also, it worked with my laptop and netbook but didn’t boot on a RAID Cluster server at work when trying to install Debian Lenny Netinstall.

For other distros with Pendrive Install guides, see the end of this post

1. Insert the USB stick, but do not mount it, yet. If it automounts, unmount it.

2. Get the sid install files (even if you install etch/lenny/squeeze):
a) wget ftp.us.debian.org:/debian/dists/sid/main/installer-i386/\current/images/netboot/debian-installer/i386/linux
b) wget ftp.us.debian.org:/debian/dists/sid/main/installer-i386/\current/images/netboot/debian-installer/i386/initrd.gz
c) wget ftp.us.debian.org:/debian/dists/sid/main/installer-i386/\current/images/netboot/mini.iso

3. Insure these packages are installed on your machine:

apt-get install mbr syslinux mtools -y

4. Apply the following commands, replaceing sdb with the propper device name.

install-mbr /dev/sdb
syslinux /dev/sdb1
mount /dev/sdb1 /media/usb

cp linux initrd.gz mini.iso /media/usb

*NOTE* These are 3 separate commands, do NOT copy, paste and issue as one command. Hit “Enter” after each line.

echo -e "default linux\nappend priority=low vga=normal "\
"initrd=initrd.gz ramdisk_size=12000 root=/dev/ram rw"\
> /media/usb/syslinux.cfg

Now umount from /media/usb
umount /dev/sdb1

Other Distro Pendrive Guides
Crunchbang Statler (Debian Squeeze) http://crunchbanglinux.org/wiki/statler_usb_installation
Crunchbang Statler on EeePc http://richs-lxh.com/howto_crunchbang-statler-xfce-on-eeepc/
Debian Installer from USB http://linux.derkeiler.com/Mailing-Lists/Debian/2008-02/msg02948.html
Debian on USB + Links http://wiki.debian.org/BootUsb

Relevant Perl Man Pages

Man pages are awesome! To find the “Manual” for anything in Linux, just open a terminal and type man with the subject you are looking for. ie:

man perl

What if it’s something less precise? Use the -k switch to get a list of anything containing the subject you are looking for. ie:

man -k network

Once you’ve read what you need, just hit q to quit back to the terminal.

Relevant Perl man pages:

perl - overview               perlfaq - frequently asked questions
perltoc - doc TOC                perldata - data structures
perlsyn - syntax                 perlop - operators and precedence
perlrun - execution              perlfunc - builtin functions
perltrap - traps for the unwary   perlstyle - style guide

"perldoc" and "perldoc -f"

Perl and Elinks Search from script to terminal

I was Googling for some neat things to do with Perl (I have a pile of scripts in /usr/local/bin), when I thought, hey!? Why not use Perl to search Google? I’ve already started to use Elinks terminal web browser,(available in all Linux repos) so obviously any scripts that mean I am just one command away from finding any needed info would be a bonus.

I decided to call this script “goose”, yeah, I know lol! GooSe as in GOOgle SEarch.

sudo vim /usr/local/bin/goose

Add this:

#!/usr/bin/perl -w

# Created by Rich Scadding 02/08/2010

$browser = “/usr/bin/elinks”;

exec $browser, “http://www.google.com/advanced_search&#8221; unless @ARGV;

for ( @ARGV ){ s/.*/%22mce_markeramp;%22/ if y/ /+/; $s .= $s?”+$_”:”$_”; }

# $ENV{LANG} = “en_US.UTF8”;

#!/usr/bin/perl -w# Created by Rich Scadding 02/08/2010$browser = “/usr/bin/elinks”;
exec $browser, “http://www.google.com/advanced_search&#8221; unless @ARGV;
for ( @ARGV ){ s/.*/%22mce_markeramp;%22/ if y/ /+/; $s .= $s?”+$_”:”$_”; }
# $ENV{LANG} = “en_US.UTF8”;exec $browser, “http://www.google.com/search?num=30&hl=en&as_qdr=all&q=$s&btnG=Google+Search&#8221;

Now take ownership with chown and chmod -x it to run it from the terminal.

EXAMPLE: goose linux-hardcore

Thanks to Ben Okopnik for Perl inspiration ( http://okopnik.com/ ) He has a lot of scripts and articles  floating around the net which are great to learn from. ie. http://linuxgazette.net/134/okopnik.html

Having an online tidy up

Over the last year I have been passing projects over to friends and gradually reducing my online responsibilities. Work and family life have taken priority.

I have spent the day cancelling domains, cancelling the renewal of hosts, and advising users of site close-downs. The only host and domain i’m keeping is linux-hardcore.com which has always been /home for myself and a few close friends.

I’ve been slowly losing interest in the Linux community, and haven’t got the enthusiasm I used to have for setting up sites and trying new ideas. It’s been great fun over the last 5 years and i’ve made some good friends but as hard as I try to find something new or interesting, everything seems to have become “samey”.

So I am going to re-theme my blog and add little more “me” to it as well as Linux related material, and see how it goes.