Saturday, January 13, 2007

Installing Asterisk, Java SDK, recompiling Kernel on Debian

This is nothing to be proud off.. two things I wanted to install. Note this is not JAVA for Asterisk, keep googling on how to do that, this is just a few packages I installed on a Debian box.

------

a) Java SDK - Sun webpage has jdk-6-linux-i586.bin but I followed some instructions (running the binary and trying to create the Debian package) but they didn't work so I check what was available. I found that testing (etch) had a Sun Java package ready to apt-get install.

-------


b) Asterisk again (this is a second server, I want to experiment with IAX and SIP trunks between asterisks)

For (a) I couldn't install it on normal ways so I cheated. Following is what I did -not on purpose.

Installed Sarge from Netinstall and updated it.
5 cd /etc/apt/
1 vi sources.list
2 apt-get update
3 apt-get dist-upgrade
4 shutdown -r now


Upgraded to Etch (by changing the sourcelist)
5 cd /etc/apt/
12 apt-get install fakeroot
13 apt-get install java-package ncurses-dev wget bzip2
17 vi sources.list
18 apt-get update
19 apt-get dist-upgrade
20 uname -r
21 shutdown -r now


Install Jdk 5 (not 6)
22 apt-get install sun-java5-jdk
23 which java

After this I went to install asterisk but when compiling Zaptel I got the error that the headers didn't match although they were there and they were the same as the uname -r. I tried to uninstall them and install them again but once uninstalled I couldn't install them again... so I decided to do something that I always fails... build the kernel from the sources.

Upgraded the kernel to latest one on kernel.org
I install a bunch of packages that not sure what they are for
105 apt-get install kernel-package ncurses-dev fakeroot wget bzip2
106 apt-get install make-kpkg kernel_image
130 apt-get install yaird fakeroot
134 apt-get install initramfs-tools


Also in the process I created a Sudo account.
apt-get install sudo
adduser ricardosudo
visudo -> modified a file with PICO
added ricadosudo ALL=(ALL) ALL
sudo adduser ricardosudo src


And here it gets weird:
cd /usr/src
tar jxf /path/to/linux-2.6.19.2.tar.bz2
cd linux-2.6.19.2/
cp /boot/config-$(uname -r) .config
---> basically I am copying the .config left by the default installation to avoid starting from zero.
make oldconfig ---> not sure if necessary. Here you are asked A LOT of things. Try to answer what you can but probably this will remind you a Windoze NEXT NEXT NEXT era.
make menuconfig --> here again I think that I could avoid the previous step. anyway go through the options and remove anything you think you don't need as it will make the kernel smaller and compile quicker. What do I don't need you ask? Go for the obvious - like removing support for ATI if you have an Intel Graphic board.

Example of the screen of menuconfig:



A few things to check are:
Processor type and features ---> Processor family (Pentium 4)
Processor type and features ---> Timer Frequency (1000 Hz)
Processor type and features ---> Preemption Model ---> Preemptible Kernel (Low-Latency Desktop)


Exit to the main menu and SAVE then run:
fakeroot make-kpkg clean

Run the make-kpkg commmand like: fakeroot make-kpkg --append-to-version "<-suffix>" --revision "" --us --uc --initrd kernel_image kernel_headers Where <-suffix> is whatever you want (like -mykernel), and change with a number (like the date, 05112006.)

Example: fakeroot make-kpkg --append-to-version "-mykernel" --revision "01132007" --us --uc --initrd kernel_image kernel_headers

After this you will get 2 deb files, you can use dpkg -i to install them.

dpkg -i linux-headers-2.6.19.2-mykernel_01132007_i386.deb
dpkg -i linux-image-2.6.19.2-mykernel_01132007_i386.deb

Here my box went wrong saying that I needed Yaird initramfs-tools and another package and could continue. I try to apt-get install those package bUt it kept saying "The following packages have unmet dependencies." but also it said to try to run apt-get install -f (note alone, not any other instance).

After this I run the dpkg again and now it worked.

After this I was able to install Asterisk as always and it worked. I am sure that I am doing something wrong and hope to learn what it is along the way.

NOTE: When compiling Zaptel I run the modprobe zaptel and modprobe ztdummy as I don't have any fxo,fxs,tdm board on this box. It will us the ztdummy for timing. An lsmod shows the modules...

rbtest:/usr/src# lsmod
Module Size Used by
ztdummy 5544 0
zaptel 208932 1 ztdummy
crc_ccitt 2304 1 zaptel

Something good came out of this.. NO KERNEL PANIC on an attempt to recompile a kernel. I have to say.. first time I didn't got one of this.

Some links that I used to do this were:

http://www.falkotimme.com/howtos/debian_kernel2.6_compile/
http://wizah.blogspot.com/2005/12/debian-how-to-custom-kernel-compile.html
http://www.debianhelp.co.uk/kernel2.6.htm

Monday, January 08, 2007

Installing Asterisk again

I installed Asterisk again. This time version 1.4.

As always I did a Debian Sarge netsinstall. On boot I choose the linux26 option to have a 2.6 kernel rather than the 2.4 that comes by default.. Why? Have no idea.

The installation is really basic, I don't choose any configuration when Debian asksfor "Desktop", "Web Server", etc.. I just give the ok and start with an empty server.

(Note that I tried to run the "testing" or "etch" version of netinstall but Asterisk requieres headers. The etch version repository don't have the headers for the default installation and you need to recompile.. AND I CANNOT RECOMPILE THE BLODDY KERNEL YET. I tried, I really tried and read several posts/pages and run diferent methods - from building my debian kernel package to actually recompile the kernel from source - but always I get a Kernel Panic. If anybody want's to sit with me and show me how to do it, I will pay for the lunch/coffee).

After the installation I changed the source.list to add contrib and non-free packages when installing new software. The file can be seen below:

rbast:/etc/asterisk# cd /etc/apt/
rbast:/etc/apt# more sources.list
#deb file:///cdrom/ sarge main

deb http://ftp.uk.debian.org/debian/ stable main contrib non-free
deb-src http://ftp.uk.debian.org/debian/ stable main contrib non-free

deb http://security.debian.org/ stable/updates main contrib non-free
rbast:/etc/apt#


You have to run apt-get update after this to let Debian pick up the changes (need to read more about apt).

Then I run the apt-get dist-upgrade to upgrade all the packages installed.

First step after install - as I like to do things remotely - is to do the apt-get install ssh. This will install a ssh client and server (openssh) so I can log in remotely and keep working from my laptop. Ah.. I never mentioned this but the "server" is an old HP PIII box.

Next step install the headers needed for Asterisk:

apt-get install kernel-headers-`uname -r`

Download all the packages again:

wget http://ftp.digium.com/pub/asterisk/releases/asterisk-1.4.0.tar.gz
wget http://ftp.digium.com/pub/zaptel/releases/zaptel-1.4.0.tar.gz
wget http://ftp.digium.com/pub/libpri/releases/libpri-1.4.0.tar.gz
wget http://ftp.digiu
m.com/pub/asterisk/releases/asterisk-addons-1.4.0.tar.gz
wget http://ftp.digium.com/pub/asterisk/releases/asterisk-sounds-1.2.1.tar.gz


And follow the installation as with 1.2.x, only a few things changed (maybe more.. correct me please).

On the asterisk package you need to run the configure utility as show below:
tar xvfz asterisk-1.4.0.tar.gz
cd asterisk-1.4.0
./configure
make
make install
make samples


Also on the asterisk-addons or you will get an error message after the make if not.

Some tips I picked up this time (also the last time but I didn't take note of them at that time) are:

a) run lspci - shows the 2 fxo clones I bought (2 years ago by now).

rbast:/usr/src/asterisk# lspci
0000:00:1f.5 Multimed
ia audio controller: Intel Corp. 82801AA AC'97 Audio (rev 02)
0000:01:0b.0 Communication controller: Tiger Jet Network Inc. Tiger3XX Modem/ISDN interface
0000:01:0e.0 Communication controller: Tiger Jet Network Inc. Tiger3XX Modem/ISDN interface
rbast:/usr/src/asterisk#


b) run lsmod - shows the modules loaded. (I have way too much modules)

rbast:/usr/src/asterisk# lsmod
Module Size Used by
wcfxo 12448 0
zaptel 231332 1 wcfxo


Other usefull things to check are:
cat /proc/zaptel/* --> it should show 2 files.

After installation I need to configure my 2 fxo boards:

In zaptel.conf set the following configuration:

fxsks=1-2
loadzone=uk
defaultzone=uk


Then execute:

/sbin/ztcfg -vvvv

In zapata.conf set the following configuration:

[channels]
language=en

context=zap
signalling=fxs_ks
callerid="Line 1"
channel => 1
callerid="Line 2"
channel => 2


Finally reload chan_zap.so

Set sip.conf as follows to have 2 extensions - a grandstream budgetone 100 and then a normal xlite softphone.

[10001]
type=friend
context=sip
regexten=10001
secret=10001
username=10001
callerid="GrandStream1" <10001>
host=dynamic
nat=no
canreinvite=yes
dtmfmode=info
call-limit=1
disallow=all
allow=ulaw

allow=alaw
callingpres=allowed_passed_screen

[10002]
type=friend
regexten=10002
context=sip
secret=10002
username=10002
callerid="XLite" <10002>
host=dynamic
nat=yes
canreinvite=no
disallow=all

llow=gsm
allow=ulaw
allow=alaw


My extensions.conf atm is rather simple. I have 2 sip phones, 2 zap lines and just for testing the following configuration should work:

[general]
static=yes
writeprotect=no
clearglobalvars=no
[sip]
exten => 10001,1
,Dial(SIP/10001,20,tr);
exten => 10002,1,Dial(SIP/10002,20,tr);
exten => _8XXXX,1,Dial,Zap/1/${EXTEN}
exten => _9XXXXXXXXXXX,1,Dial,Zap/1/${EXTEN}
[zap]
exten => s,1,Dial(SIP/10001,20,tr);

The above configuration should ring the 2 sip phones and allow the sip phones to ring any extension on my office through the 1st zap channel (need to read about macros to use both and pick up an available zap channel).

It will also send any call from my pbx to the grandstream phone.

My PBX is an Avaya CM3. I want to set up an H323 trunk, but at the moment anybody dialing extension 8xxx1 and 8xxx2 (I am not trying to hide the extensions number, I really don't remember them) will send the calls to the grandstream sip phone.

The Grandstream configuration is simple and show on the picture attached. To configure it first check the phone ip - activate dhcp or enter an ip using he keypad - and log in. The default password is admin, if you don't know the password you can reset it by going to the "reset" option on the phone menu throught the keypad and enter the mac address of the phone. Look for the grandstream manual on the net as they have some rules of how to change the mac address letters for numbers.

That is all for today.. Good luck!

Usefull links:
http://kb.digium.com/ -> Digium Knowledge Base.