DIY PBX Chapter 4: An Asterisk is Born

Previously, I had purchased and installed a TDM410P telephony card, and compiled, installed and configured the drivers that went with it. But my DIY PBX cannot consist of just a telephony interface card; without a PBX application, you can't even get a dialtone. I need a PBX application to manage and drive it all. And so, in quest of my dialtone, and advancing in this DIY PBX journey, I installed Asterisk.

Back to Digium and Asterisk

If you look, you can find a number of open-source PBX applications on the Internet, but none more popular than Asterisk. Asterisk started as a "home-grown" solution to a software-developer's business need, and blossomed into a full-fledged PBX, handling both analogue and digital PSTN circuits, Voice-over-IP telephony, and a host of other telecommunications protocols. Since it's initial release, back in 1999, Asterisk has found it's way into many projects, from full-scale commercial PBX solutions to home-brew VoIP devices, and, in my case, the IP04 PBX from Rowetel.

Since I already have Asterisk installed on my IP04, and plenty of "sweat-equity" invested in the software infrastructure I built around it, I had (naturally) turned to Asterisk for the replacement PBX that I intend to build. The IP04 uses Asterisk, which Digium released around 2006; my DIY PBX would use a more recent version: Asterisk 18.1.0, released in October, 2020.

Downloading and extracting the Asterisk source

As I did with the DAHDI code, I first prepared a directory tree under /usr/local/src to store the downloaded source, and the various working directories and files I would use to install Asterisk.

# mkdir -p /usr/local/src/asterisk/tarballs
# mkdir -p /usr/local/src/asterisk/install

From there, I downloaded and unzipped the latest asterisk source code package, and

# cd /usr/local/src/asterisk/tarballs
# wget
# cd ..
# tar -xzf ./tarballs/asterisk-18-current.tar.gz

which left me with the /usr/local/src/asterisk/asterisk-18.1.0 source directory and all it's code.

The text file in asterisk-18.1.0 tells a simple story about how to perform the installation:

  1. Run ./configure, then, optionally
  2. Run make menuselect, then
  3. Run make, and finally
  4. Run make install

The optional make menuselect step allows the installer to pick and choose which Asterisk components to enable, with some components disabled when the system lacks it's prerequisite software. But, before we make menuselect, we first must configure the install to place it's elements in the proper directories, and not to attempt to use the IODBC connector that Slackware supplies:

# cd /usr/local/src/asterisk/asterisk-18.1.0
# ./configure --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var --libdir=/usr/local/lib64 --without-iodbc

Next, on to menuconfig, where I selected a number of options that I will use (such as support for MP3 audio files), and deselected others that I won't use (such as support for GSM mobile channels). I included in my selection the various audio clips that Asterisk supplies, as some of the features and functions I would use in my testing depend on or use these clips. Once past that, I executed make to build the selected configuration:

# make menuconfig
# make

Finally, I installed Asterisk to my fake-root installation directory, where I built packages for Slackware's native package management tool:

# make DESTDIR=/usr/local/src/asterisk/install install

Surprise, surprise, surprise!

The asterisk install surprised me, in a couple of ways. First off, the whole make process, from ./configure to make install ran smoothly; there were no major issues to sort out, no glitches due to differences in compiler level or code quality, nothing. The whole process ran smoothly.
And, secondly, despite the instructions in the README, the make install step isn't the last step. make install, after populating the target directories with it's cargo, presented me with:

 +---- Asterisk Installation Complete -------+
 +                                           +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 + For generic reference documentation:      +
 +    make samples                           +
 +                                           +
 + For a sample basic PBX:                   +
 +    make basic-pbx                         +
 +                                           +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +               make progdocs               +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +

So, I had some thinking to do, and some choices to make. Did I want to proceed with the "bare-bones" Asterisk install, or did I want to add some sample configuration to it. And, If I chose to add the configuration, should I pick the "generic reference" or the "basic PBX"?

Rather than combine one of the configurations to my installation, I decided to create seperate installation packages for each. I started with the full sample configuration:

# mkdir /usr/local/src/asterisk/install_sample_config
# make DESTDIR=/usr/local/src/asterisk/install_sample_config samples

but that did not go well. It appears that the "samples" target installs to certain directories that the "install" target creates, and rather than (re)creating those directories itself, it simply assumes their existance. I guess that, for most installations, this is a reasonable assumption, but for my installation, it was not. So, let's try again:

# mkdir -p /usr/local/src/asterisk/install_sample_config/var/lib/asterisk/phoneprov
# make DESTDIR=/usr/local/src/asterisk/install_sample_config samples

And, away it went.

With that, I cautiously approached the "basic-pbx" target:

# mkdir /usr/local/src/asterisk/install_basic_config
# make DESTDIR=/usr/local/src/asterisk/install_basic_config basic-pbx

and encountered similar errors, which I corrected:

# mkdir -p /usr/local/src/asterisk/install_basic_config/etc/asterisk
# make DESTDIR=/usr/local/src/asterisk/install_basic_config basic-pbx

with similar good results.

So, the target directory structure for the samples target looks like:


and the target directory structure for the basic-pbx target looks like:


Installed, configured?

Now that I had native Slackware packages for the base Asterisk install, along with packages for both the full sample-set of configuration files and a basic "working" sample pbx, I could install Asterisk and put together a "minimum" configuration to test my phones against. The install went smoothly (Slackware's package management system took care of that), so all I had to do was ensure that I put together a minimum viable configuration for the TDM410P-connected handsets, and try it out.

From experience with my IP04 (and some reading), I knew that I would need, at least,

  1. /etc/asterisk/asterisk.conf for some basic configuration,
  2. /etc/asterisk/modules.conf to enable (and disable) Asterisk features implemented as loadable modules,
  3. /etc/asterisk/indications.conf for location specific tone indications,
  4. /etc/asterisk/extensions.conf for a basic dialplan that would run the handsets, and, most importantly to me,
  5. /etc/asterisk/chan_dahdi.conf for the configuration of the DAHDI-connected channels.

I cloned the asterisk.conf, modules.conf, and indications.conf from the samples set of configuration samples that I created earlier. Outside of ensuring that the filesystem paths in asterisk.conf were correct, I didn't alter any of these for my test.

extensions.conf was easy enough to craft, having played extensively with it under Asterisk 1.4 on my IP04. So, I built a simple dialplan that would give me a dialtone, and permit me to make calls between the three FXS (handset) channels on my TDM410P card. With spare handsets plugged into each channel, this would give me a good basic test of the system.

However, I had some qualms about chan_dahdi.conf; in the documentation, the next step was to run the DAHDI dahdi-genconf utility, and that tool had left a dahdi-channels.conf file in my /etc/asterisk directory. But, dahdi-channels.conf isn't chan_dahdi.conf, and the documentation was silent on what to do with the file. The header at the beginning of the file implied that the file was meant to be used as chan_dahdi.conf, so, with some carefull editing, I transformed it. I crafted a very skeletal chan_dahdi.conf, and used the Asterisk configfile #include option to embed the dahdi-channels.conf file in it. The resulting chan_dahdi.conf matched my skeleton dialplan in extensions.conf without too many deviations from the supplied default configuration files.

But, will it start?

So, now comes the first moment of truth; will it run? In the source code asterisk-18.1.0/contrib/init.d directory, I found a number of Asterisk startup scripts, including one for Slackware. I cloned this script to my /etc/rc.d directory, made a few cosmetic changes, and started Asterisk for the first time on this machine.

And up it came, sweet as can be. No errors, even with my hastily-crafted configuration.

And that lead me to the second moment of truth: do I have a dialtone?. I picked up one handset, and listened.... to the sweet, sweet sound of a North American signalling dialtone. And, I even managed to dial from that one handset to another, with a full duplex connection with clear sound. Huzzah!

And, now on to the funner part

With a dialtone on each handset, and Asterisk running like a charm, I can now start customizing this installation to take the place of (and even surpass) my aging IP04.

But, that's another chapter in this DIY PBX story.

System Management: