Debian DAHDI
Contents
Install DAHDI the Debian way
There isn't a great deal of documentation on how to install Digium's DAHDI component onto Debian, probably because it is so easy and obvious if you are a Deb devotee. Anyhow, for the rest of us, here's a little howto.
The correct "Debian way" to install driver modules uses Debian's module assistant. What it will do is drag the source code from the libraries, compile it, package it into a deb and install it, all on-the-fly. (if you are curious, you can find the deb which it builds in /usr/src/ after the module assistant has finished its machinations). It should work on any Debian Wheezy/Jessie image.
This assumes you have already installed SAIL using the guide HERE (this means that all of the correct Asterisk stuff will already be installed). If you don't intend to install SAIL, then install Asterisk and asterisk-dahdi in the normal manner (using aptitude or apt-get). Run the module assistant as follows;
apt-get install dahdi-source
Wait for it to finish downloading and run the module assistant
m-a a-i dahdi
This will chug along for a while. When it finishes, DAHDI will be installed but you have a little further work to do. The procedure differs for Wheezy and Jessie so follow the section which applies to your distro.
NOTE for BRI card Users
If you are using Cologne BRI cards (from Digium, OpenVox etc) DAHDI BRI drivers won't load properly because the kernel will preload its own card drivers before DAHDI gets a look. To stop this from happening you must blacklist the default driver set. Open or create /etc/modprobe.d/cologne-blacklist.conf and add the following
blacklist avmfritz blacklist hfcmulti blacklist hfcpci blacklist hfcsusb blacklist mISDNinfineon blacklist mISDNipac blacklist mISDNisar blacklist speedfax blacklist w6692
Save it and reboot the box.
Debian 7 (Wheezy)
Unpack and copy the /etc/dahdi samples into /etc/dahdi
gunzip /usr/share/doc/dahdi/examples/genconf_parameters.gz gunzip /usr/share/doc/dahdi/examples/system.conf.sample.gz cp /usr/share/doc/dahdi/examples/system.conf.sample /etc/dahdi/system.conf cp /usr/share/doc/dahdi/examples/genconf_parameters /etc/dahdi/
For some reason, the install puts DAHDI into a group called "dialout" in the udev rules. It needs to be in group asterisk for our purposes or Asterisk won't be able to load chan_dahdi.
These commands will change it to GROUP="asterisk" and restart udev
cp /lib/udev/rules.d/60-dahdi-linux.rules /etc/udev/rules.d sed -i 's/GROUP="dialout"/GROUP="asterisk"/' /etc/udev/rules.d/60-dahdi-linux.rules /etc/init.d/udev reload
Tailor/fix
There is a bug in one of the DAHDI Perl routines which will cause problems if you don't fix it. There is a published patch from Digium but you'll need to fix it manually because the patch won't verify on Debian (the target module is in a different place in Debian). Here is the Digium patch
diff --git a/xpp/perl_modules/Dahdi/Span.pm b/xpp/perl_modules/Dahdi/Span.pm index cf38c80..ea08961 100644 --- a/xpp/perl_modules/Dahdi/Span.pm +++ b/xpp/perl_modules/Dahdi/Span.pm @@ -230,6 +230,11 @@ sub new($$) { last; } } + if (($self->is_soft_term_type == 0) and ($self->termtype eq "UNKNOWN")) { + + } + + + ($self->{NAME}, $self->{DESCRIPTION}) = (split(/\s+/, $head, 4))[2, 3]; $self->{IS_DAHDI_SYNC_MASTER} = ($self->{DESCRIPTION} =~ /\(MASTER\)/) ? 1 : 0; -- 1.7.6.2
Fortunately, it's not very big and only concerns a single module so you can just patch it manually if it isn't already applied. At, or around line 232 in /usr/share/perl5/Dahdi/Span.pm you will find the following (unpatched) code
last; } } ($self->{NAME}, $self->{DESCRIPTION}) = (split(/\s+/, $head, 4))[2, 3]; $self->{IS_DAHDI_SYNC_MASTER} = ($self->{DESCRIPTION} =~ /\(MASTER\)/) ? 1 : 0;
Change it to this (comments optional).
last; } } # # Digium Patch # if (($self->is_soft_term_type == 0) and ($self->termtype eq "UNKNOWN")) { $self->{IS_SOFT_TERM_TYPE} = 1; } # # Digium Patch End # ($self->{NAME}, $self->{DESCRIPTION}) = (split(/\s+/, $head, 4))[2, 3]; $self->{IS_DAHDI_SYNC_MASTER} = ($self->{DESCRIPTION} =~ /\(MASTER\)/) ? 1 : 0;
Generate
Card setup
DAHDI should already be started (after the reboot above) but if it isn't, you can start it now.
/etc/init.d/dahdi start
Now you can run genconf
dahdi_genconf dahdi_genconf modules /etc/init.d/dahdi restart
You may find that the restart fails. This seems to be because genconf sometimes puts blank lines into system.conf or dahdi_channels.conf which DAHDI doesn't like. Remove them and start dahdi normally.
Debian 8 (Jessie)
The package maintainers sought to add a greater degree of automation in Debian 8 so the procedure is different and has some pros and cons vs earlier releases. There is no start/stop daemon for DAHDI as there was in earlier releases, everything happens automatically. The downside of this is that you will need to do a little more work if you make changes to the PCI card definitions.
After you have installed DAHDI, reboot your box. The relevant DAHDI modules will be automatically loaded on restart but your card won't yet be recognised. Run the following commands
dahdi_span_assignments auto dahdi_genconf
This will assign and create the definitions for the card. There does seem to be some uncertainty as to how well this works if you have multiple cards attached so YMMV, but it seems to run just fine for a single card.
The card definition in /etc/dahdi/system.conf will initially be set to US for its loadzone. Here is a freshly generated example.
# Autogenerated by /usr/sbin/dahdi_genconf on Sat Apr 23 12:37:23 2016 # If you edit this file and execute /usr/sbin/dahdi_genconf again, # your manual changes will be LOST. # Dahdi Configuration File # # This file is parsed by the Dahdi Configurator, dahdi_cfg # # Span 1: WCT1/0 "Wildcard TE122 Card 0" (MASTER) CCS/HDB3/CRC4 RED ClockSource span=1,1,0,ccs,hdb3,crc4 # termtype: te bchan=1-15,17-31 dchan=16 echocanceller=oslec,1-15,17-31 # Global data loadzone = us defaultzone = us
Set it to your country code and save it.
dahdi_genconf will also have created dahdi-channels.conf in /etc/asterisk. It seems to be able to figure out which flavour of ISDN to set. Here is an example
; Autogenerated by /usr/sbin/dahdi_genconf on Sat Apr 23 12:37:23 2016 ; If you edit this file and execute /usr/sbin/dahdi_genconf again, ; your manual changes will be LOST. ; Dahdi Channels Configurations (chan_dahdi.conf) ; ; This is not intended to be a complete chan_dahdi.conf. Rather, it is intended ; to be #include-d by /etc/chan_dahdi.conf that will include the global settings ; ; Span 1: WCT1/0 "Wildcard TE122 Card 0" (MASTER) CCS/HDB3/CRC4 RED ClockSource group=0,11 context=from-pstn switchtype = euroisdn signalling = pri_cpe channel => 1-15,17-31 context = default group = 63
General cleanup (both wheezy and Jessie)
dahdi_genconf doesn't create an include for chan_dahdi.conf, so you have to do that yourself. This is true for both Wheezy and Jessie so you can do it now.
echo '#include dahdi-channels.conf' >> /etc/asterisk/chan_dahdi.conf
N.B. you may also need to add some parameters for your local ISDN rules. In the united Kingdom we add the following to chan_dahdi but your country may have different requirements.
language=en-gb pridialplan=unknown prilocaldialplan=unknown internationalprefix = 00 nationalprefix = 0
Last of all, if you are running SARK, we need to set the ownership and perms so that SARK(Apache) can get at the generated files
chown asterisk:asterisk /etc/dahdi/* chmod 664 /etc/dahdi/* chown asterisk:asterisk /etc/asterisk/* chmod 664 /etc/asterisk/*
Now, reboot and you're done.