Untangle, Asterisk PBX and File Server; All-in-One. Part 7.1 (OSLEC)

O.K. I said I’d write a bit about an excellent new echo canceller which happens to work with Asterisk. Here it is it’s called OSLEC the Open Source Line Echo Canceller and it’s written by a chap called David Rowe.

As readers may recall, I’ve built a small home server (VIA CN700) on which I plan to run Asterisk, Samba and Untangle. Samba is up and running and Asterisk is too. I have a single port, very cheap (about £15 inc postage from the USA) x100p card providing an interface to a normal analogue PSTN telephone line.

When we got everything working, we noticed a great deal of echo on voice calls over the x100p. Lots of playing with gains and various settings in the zaptel configuration failed to make any noticeable difference.

I came across this site whilst looking for something completely different and started to read… It sounded like just the thing. A bit of jiggery and a quick patch to the zaptel-1.4.5.1 sources – thanks to the asterisk mailing list – and I got the OSLEC canceller working.

Basically here’s what to do:

  1. Build the OSLEC module (it will need to find your kernel sources – just like zaptel) according to the instructions on the website. Once built and you’ve checked that you can install it by inserting the module into your running kernel, copy it (oslec.ko) to your kernel’s loadable module directory: on my system the zaptel modules reside in /lib/modules/2.6.23/misc/ so that’s where I put the oslec module too.
  2. Patch your zaptel source tree (if you have version 1.4.5.1 you will need to patch Makefile.kernel26 or OSLEC will never get loaded) and rebuild and re-install as described. (Caution: Backup your /etc/zaptel.conf, /etc/asterisk/zapata.conf and your modified SysV init scripts so you can simply overwrite the default files installed when you rerun make install on the zaptel sources.)
  3. Edit your zapata.conf so the following are as below:
    echocancel=yes
    echocancelwhenbridged=no
    ;echotraining=400
  4. Reload everything (if in doubt, stop asterisk and zaptel using your SysV init scripts, e.g # /etc/rc.d/init.d/{asterisk,zaptel} stop. Then start them again. When zaptel starts you should see a message saying Echo canceller OSLEC or something like that; if it says MG2 then it isn’t working so you need to go back and recheck your build and patching and module loading.

That’s it.

Now make or receive a call through your cheap x100p card and marvel at the clear echo free sound! It worked brilliantly for me. Of course YMMV but it is definitely worth a try. Most of the reports on the ‘net are incredibly positive about this.

Untangle, Asterisk PBX and File Server; All-in-One. Part 7

There’s no Untangle in this installment – I’m awaiting a new kernel from the developers before I can get any further; it should be here shortly however.

In the previous article of this series I mentioned that I’d explain how to get Asterisk built and running as a non-root user. It wasn’t too hard to be honest but I’ll document it anyway.

The problem: Asterisk by default, when compiled from source, expects to be run as root. For userspace applications, this is NEVER a good idea in my opinion. After all we’re running on a multi user system that can support non-root processes – unlike Windows – so we really should… ;-)

The solution for Asterisk-1.4.13 on my LFS based system, is as follows:

Build any hardware add-ons and codecs you need before building Asterisk. I built the Zaptel module for my x100p card and the Speex Open Source VBR codec. The zaptel module needs to find your kernel source tree (usually in /usr/src/linux-2.6.x.x). To build the zaptel source:

./configure --prefix=/usr
make menuselect
(to select/deselect the modules you wish to build)
make

then as root:

make install

and optionally:

make config This will install the SysV init scripts and some default configuration files. You may need to modify the init scripts depending on your system.

Simply follow a similar process for the Speex codec…

For Asterisk, start off by creating a group and user that will run and own the asterisk process and files (select {G,U}IDs and names that are appropriate for your system).

groupadd -g 75 asterisk
useradd -c "Asterisk PBX" -d /var/lib/asterisk -g asterisk -s /bin/false -u 75 asterisk

Edit the Makefile in the top of the asterisk source tree so that the line:

ASTVARRUNDIR=${localstatedir}/run becomes ASTVARRUNDIR=${localstatedir}/run/asterisk

Then build as normal

./configure --prefix=/usr
make menuselect
(Turn on/off various modules and options. Select sound files/language/format and extra sounds. Type “s” to save and exit)
make

Then as root:

make install

Asterisk is now installed. But because we will run the process as non-root it needs write permissions for these directories and their contents:

/var/lib/asterisk, /var/log/asterisk, /var/run/asterisk, /var/spool/asterisk, /dev/zap/*.

If you installed the zaptel modules and used the ‘make config’ command, a udev rules file (zaptel.rules) will be written to /etc/udev/rules.d. This enables, by default, udev to create the zaptel device files as user:group asterisk. If you chose another name above you will need to edit this file accordingly.

O.K., lets sort out the ownership and access to the files Asterisk needs. First change the owner:

chown -R asterisk:asterisk /var/{lib/asterisk,log/asterisk,run/asterisk,spool/asterisk}

Now set read/write only by owner, read only by group and no access by other:

chmod 750 /var/{lib/asterisk,log/asterisk,run/asterisk,spool/asterisk}
chmod -R o= /var/{lib/asterisk,log/asterisk,run/asterisk,spool/asterisk}

This switch (chmod -R o=) is pretty cool by the way. It removes all access to all files and directories for the “other” classification, effectively setting them to “0″ but does not change or overwrite any of the permissions for owner and/or group access.

The asterisk process itself only needs read permission for the configuration directory (/etc/asterisk) and its contents (almost1):

chown -R root:asterisk /etc/asterisk
chmod 750 /etc/asterisk
chmod 640 /etc/asterisk/*

Some of Asterisk’s ‘.conf’ files contain cleartext passwords and other potentially sensitive information. Setting the files as above permits read/write only by the user root and read only by members of the group asterisk.

That’s it basically. When you start asterisk from the SysV init scripts, pass the following arguments to have it run, safely, as your new user:

asterisk ${DEBUG} ${ZAP_TIMING} -U ${USER} -G ${GROUP}

In my startup script, I’ve set those constants above to be:
# If you want debug messages to the console and the logs switch the
# comments below
DEBUG=""
#DEBUG="-d"

# The user and group we created earlier
GROUP="asterisk"
USER="asterisk"

# Use this if you want to limit the maximum number of simultaneous calls
# to prevent system failure for example
MAXCALLS=""
#MAXCALLS="-m 20"

# If you have a Zaptel card/timing source, enable it here
#ZAP_TIMING=""
ZAP_TIMING="-I"

That’s it.

When asterisk starts, it will run as the user and group defined above. In the next installment, I will write a bit about a fantastic new echo canceler which sorts out cheap x100p cards and makes them work properly… It’s really excellent.

1. Except for voicemail.conf. When a user changes their pin asterisk writes these changes to the voicemail.conf file.

M$ vs. EU (Open Source): Samba Wins!

This story has been back and forth like a long stroke piston engine, but it now seems as though for a one-time payment of €10k, the Samba team get the necessary stuff they need without prejudice and ongoing royalty commitments.

Microsoft, which has decided not to appeal the Court of First Instance’s September 17 ruling in favor of the European Commission and its 2004 antitrust order against the company, has also agreed to bend its terms to the open source business model and slash the price of its server communication protocols – just like the Samba Project wanted.

I know it isn’t quite free – but come on, €10k, they have already had two “donations”. I should think Redhat and Ubuntu could find that between them in spare change…

Samba always said it could deal with a one-time payment. It just couldn’t abide a royalty stream or a patent agreement. Kroes went to bat for the project and got Microsoft to agree to either a one-time payment of EUR 10,000, roughly $14,300, or a royalty structure, including a worldwide patent license, of 0.4%, down from 5.95% – less than 7% of its original price, the EC preened.

I think this is good news, but as I said it has been back and forth so perhaps this may change again…

Upcoming Free Seminar

A quick plug for our business, The Open Learning Centre, coming up:

On the 20th November in Farnham, Surrey, England. We are running the first of what we hope will be a series of short and hopefully entertaining seminars on Open Source Software aimed mainly for the SME (Small to Medium Enterprise).

The seminar is called “The Way Out is Open!” and we will be using a totally Open Source Software solution to show how a typical business might deal with some of the usual activities surrounding a new product launch. We will demonstrate various popular products such as OpenOffice.org and Joomla! as well as many others.

I appreciate that for the main readership of this blog it will be rather uninteresting, but if you know anyone who could do with being shown the magic of Open Source then send them to this link where they can register to come and see The Open Sourcerers in action: http://www.theopenlearningcentre.com/component/option,com_performs/Itemid,83/.

As I said it is Farnham (not far from Guildford) and will run from 08:30am to 10:30 on the 20th November.

Thanks.

Kudos to Glyn Moody

Glyn Moody’s blog is a source – no a font – no a fountain – of information and commentary regarding all things Open (& Source).

In the last day or so he’s posted three articles (among several others) that have really grabbed my attention:

First this one: I would not have believed it had I not gone to Tesco’s web site and verified it myself.

Tesco may not be a name that means much outside the UK, but the fact that this huge retailer is selling GNU/Linux-based systems – some for as little as £140 (without a screen) – is pretty significant.

PRETTY SIGNIFICANT? It’s nothing short of amazing in my book. I can understand how Dell and Lenovo can do it. But Tesco? They must have a very strong conviction in Linux to sell it to what I imagine to be their “typical” customer. I notice they are supplying the LTS (Long Term Support) version of Ubuntu (6.06) so I wonder if they have a support arrangement directly with Canonical? Does anyone know anything more about this?

Then this on the EU vs. Microsoft case:

I worry that there’s some wiggle room here – just what exactly is “the open source business model”? – but given the soundness of its thrashing, maybe Microsoft really has given up fighting the EU. Let’s hope.

I love a damn good thrashing don’t you? (Bit of an English Public School joke in there somewhere). I tried to get the detail on this yesterday via Groklaw but PJ’s analysis seemed a little dour. But maybe that’s just because of the stupid IP/Patenting laws in the USA.

And then to cap it all this from Mozilla:

It’s also doing rather well on just about every other metric, as Mitchell’s post “Beyond Sustainability” explains. Recommended reading.

Which I hadn’t seen. Thanks for bringing this to our attention. Mitchell’s post is indeed great reading. Mozilla is a true powerhouse in the Open Source ecosystem, and seems for the most part, to be successfully juggling the twin balls of making money and keeping a strong public community behind it. Some of the statistics are incredible… Go and have a read.

And stick Glyn’s blog on your RSS feed reader while you’re there.

Microsoft reported to the OFT by Becta

Remember this article (Would you buy software licenses you can’t use?) I wrote a little while ago? Well it seems as though Becta have had enough trying to negotiate with Microsoft and have referred them to the Office of Fair Trading for alleged anti-competitive practices in the schools software market.

Hooray. This is good news. According to the original article:

The agency’s main concerns surround the limitations Microsoft places on schools using its subscription licensing arrangements and the potential interoperability difficulties for schools, pupils and parents who wish to use alternatives to Microsoft’s Office software, including “free to use” alternatives.

They missed an opportunity here when they could have suggested that Schools deploy OpenOffice.org instead.:

Becta’s advice to schools considering moving to Microsoft’s School Agreement subscription licensing model is that they should not do so. Schools must be legally licensed for all the software they are using, and if licensing Microsoft products is an imperative they should consider using a perpetual agreement such as ‘Select’ until such time as the OFT have responded to our complaint.

But they make up for that slip up a bit by saying here:

Becta’s advice to schools in relation to the deployment of Office 2007 remains that schools and colleges should only deploy Office 2007 when its interoperability with alternative products is satisfactory. That would necessarily imply effective support by Microsoft of the internationally approved ODF file format.

About time too. Next time you talk to your childrens’ teacher tell them about Open Source software and OpenOffice.org in particular. Perhaps we could save the country a few Million quid and get some more teachers/books/hardware/sports equipment or anything else that would be more useful and valuable than a piece of paper from Microsoft; that’s all you get in reality…

Next Page »