Installing FreeSWITCH 1.8 on Debian 9 (Raspbian Stretch, the basic image of the SmartDomain system MajorDoMo on Rasbperri Pi)

  • Tutorial
I continue a small series of articles devoted to the creation of a “smart home” and step-by-step instructions for self-installation / configuration.

But now it will be mainly about Freeswitch and IP telephony.

In August, the developer of the open VoIP IP telephony platform FreeSWITCH, Signalwire, published a public release of the new software version - 1.8. (1.8.2 has already been released).
In connection with the release of this version of the Freesfitch 1.8 IP telephony platform, there was a decision to install it on Raspberry 3 with the MajorDoMo smart home system installed in a basic way, under the Raspbian (Debian 9 Stretch) operating system with some home automation elements.



Under the cut, a description of the installation of the VoIP platform from source codes with small notes and explanations.

Three months after the release and announcement of the public release of the 1.8 version in the installation manual for Debian 9 on the official website, FreeSWITCH currently has an installation manual.

Installing FreeSWITCH 1.8

However, I was not able to install any of the options given in the instructions on my Rasberry. Not so long ago there was a warning about incompatibility and it was necessary to install from source codes. Also in the official documentation you can find the installation on the Raspberry Pi, but it is already outdated. Therefore, I will describe my installation option on the Raspberry P, making a small step-by-step instruction. In previous articles I tried to describe how to start working with the terminal and the command line, so, if a little incomprehensible, I recommend reading the previous articles (links will be given at the end of the article). The principle is the same, I did it - it worked, I rechecked, I prepared the instructions so that the eldest son could repeat and sort out a little what he was doing.

Installing FreeSWITCH 1.8.2 from sources


Connect to Raspberry via Putty.

In order not to type sudo before each command, execute the command sudo –i. After that, we work with the rights of the system administrator, automatically moved to the root directory. To find out in which directory you are, you can run the Pwd command.

We update the system:

apt-getupdate
apt-get upgrade 

Go to the home directory, then download the version of freeswitch 1.8.2:

cd /home/pi
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git -bv1.8.2 freeswitch

After the download is complete, the Freswitch source folder appears in the home directory. Go to it (full path: / home / pi / freeswitch) and install the necessary programs to build from source and go to the freeswitch directory:

cd freeswitch
apt-get install autoconf libtool libtool-bin

Before you build a program from source, you must first build a configurator, run:

./bootstrap.sh –j

The Freeswitch platform has a modular structure, so before installing, we edit the list of required modules:

nano /freeswitch/modules.conf

For the most part, the list remains as the default, my video codecs are disabled (only G723 and G729 are included), the Russian language module is connected, mod curl endpoints, mod_portaudio.
Install dependencies for server configuration and build. Use the –y flag to let the team automatically answer Yes to all questions of the system:

apt-get install -y g++ zlib1g-dev libjpeg9 pkg-config sqlite3 libsqlite3-dev libcurl4-openssl-dev libpcre3 libpcre3-dev libspeexdsp-dev libldns-dev libedit-dev libtiff-dev
apt-getinstall -y yasm lua5.2 lua5.2-dev libsndfile-dev portaudio19-dev

Installable packages depend on plugins. If a package is missing, then an error may occur in the next two steps.

Configuration and Installation of FreeSWITCH Server


After that, you need to run the configurator to check for all dependencies, as well as install additional assembly options. The configurator will build a Makefile based on the knowledge gained and the makefile.am file.

Execute the command:

./configure --enable-system-lua

If everything went well, then we get the following message:



Let's proceed to the installation itself:

Make
Make install

If the result is positive, Freeswitch is installed by default into the directory /usr/local/freeswitch, at the end of the configuration we can view the list and location of the FS directories.


If during installation or configuration you get an error like mod_lua.cpp: 37: 17: fatal error: lua.h: No such file or directory #include "lua.h", then you need to install the necessary libraries using the search command. I was unable to install freeswitch with liblua5.3-0 liblua5.3-dev packages, I had to install version 5.2.

Apt search lua



Install the audio files with the support of the Russian language:

make cd-sounds-install
make cd-sounds-ru-install cd-moh-install

At this point, the installation process can be said to be complete.

To prevent small database files from being written to flash memory and increase its lifespan, we add a line to the / etc / fstab file: After restarting, temporary files created by FS will be written to RAM.

tmpfs /usr/local/freeswitch/db tmpfs defaults 0 0




System setup after installing FreeSWITCH.


There is a warning in the FreeSWITCH documentation, so I do not recommend trying to run FS immediately after installation.

**Attention! If you installed FreeSWITCH from source code, you need to set permissions on directories and files. If you start FreeSWITCH after installation, it will start as 'root' by default. It is necessary to change the rights to directories before the initial launch. **

Create a new user and set the permissions and change the owners to FreeSwitch files

cd /usr/local
groupadd freeswitch
adduser --quiet --system --home /usr/local/freeswitch --gecos "FreeSWITCH open source softswitch" --ingroup freeswitch freeswitch --disabled-password
chown -R freeswitch:freeswitch /usr/local/freeswitch/
chmod -R ug=rwX,o= /usr/local/freeswitch/chmod -R u=rwx,g=rx /usr/local/freeswitch/bin/*

Next, copy the auto start file to systemd, rename it, change the access rights.
FreeSWITCH comes with a systemd file, which, when properly configured during startup, controls FreeSWITCH and starts it as a daemon, restarts it if FS does not work.

cp /home/pi/freeswitch/debian/freeswitch-systemd.freeswitch.service /etc/systemd/system/freeswitch.service
chmod +x /etc/systemd/system/freeswitch.service 

Make a link to the startup file and create a link to the startup file of the FS console:

ln -s /usr/local/freeswitch/bin/freeswitch /usr/bin/freeswitch
ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli 

Add the freeswitch service to the autoload:

systemctl enable freeswitch
systemctl daemon-reload
systemctl start freeswitch

After that, I still didn’t start the FS, generated an error with the * .pid file, I simply edited the nano /etc/systemd/system/freeswitch.service startup file by commenting
out the following line in the file: # PIDFile = / run / freeswitch / freeswitch. pid.



Just in case, we reboot Raspberry (as you remember while we are working as root): reboot

After restarting, we give the command again, enter through sudo -i, start htop and see the running FreeSWITCH processes.

A little about the initial settings:

After installing FreeSWITCH is ready to work, it has 20 subscribers with numbers 1000-1019 by default. The default password for VoIP subscribers is specified in the file /usr/local/freeswitch/conf/vars.xml and is equal to 1234. In the directory/ usr / local / freeswitch / conf / derectory / default there are 20 xml files, each of which is responsible for the subscriber with the corresponding number. We can set a password for each subscriber. By changing the file name and the data in its contents, we can change the subscriber numbering and capacity.

If you need to do this, after editing the files, you need to start the FreeSwitch: console fs_cliand give a command in the console window reloadxml. With this command, FS rereads the XML files and accepts the changes.



Exit the console: ctrl+D either by typing commands /exit or/quit

Now let's try to connect IP subscribers. To check the connection, I used on a Windows PC: MicroSIP and PhonerLite softphones and Android CSipSimle mobile phone, the settings are as follows (account name is a phone number, SIP server is our Raspberry address: A
green icon in the bottom status bar of these programs means that the subscriber is authorized on our VoIP server and is ready for communication.



Having dialed a number, we can check the subscriber’s call and some other IP PBX functions.
But I don’t see any particular home use of a typical PBX. Let's try to use the more advanced features of FreeSWITCH.

Freeswitch has a modular structure, plug-ins can be found in the
modules.conf.xml file

Edit it, I disabled the video codecs and connected the Russian language module as well as mod_xml_rpc.

 nano /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml</>
Включить модуль можно удалив символы <source><!--  -->

in the line before and after the module name. Disable - on the contrary, by placing these symbols, a small example, the first module is enabled, the second is disabled:

<loadmodule="mod_xml_rpc"/><!-- <load module="mod_xml_curl"/> -->

After that we edit, if you want to change, simple settings (port, user, password) of the module itself in the file xml_rpc.conf.xml, which is located in the same directory.
nano /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml

By default: the user is freeswitch, the works password, port 8080.

We reboot either the friswitch or the server itself. You can do this in several ways: by rebooting the entire system (reboot), using service control commands: systemctl stop freeswitchthen systemctl start freeswitchor systemctl restart freeswitch.

After that, typing in the browser http://IP_RASPBERRY:8080/portal/index.html#and logging in under the user freeswitch with the password works, we get into the small administrative panel FreesWITCH. We can see the status, registered users, etc.



Let's try a little further to go:

After typing in the browser the request we get the status display FS:

http://freeswitch:works@IP_RASPBERRY:8080/webapi/sofia?status%20profile%20internal 



The syntax is pretty simple; if a command contains more than one word, then the first and second words are separated by a question mark, and the rest by spaces.

Let's try to execute this command from MajorDoMo: from the main page of the “Smart Home” go to the Control Panel - Console

In it we type the command:

GetURL("http://freeswitch:works@IP_RASPBERRY:8080/webapi/sofia?status%20profile%20internal")

In response, we get the status of our VoIP server.



Now let's try the following experiment:

The idea is to initiate a call (using the originate function) from the “Smart Home” to the subscriber number 1001 (MicroSip), and then transfer the call to the dial plan for outgoing calls to the subscriber 1002 (PhonerLite) . The API command looks like this: originate user / 1001 1002 XML default initiating a call to the console number 1001, after raising (auto-raising) the tube, the number is called and 1002 from the default dial plan.

We translate it into a clear view for MajorDoMo and the browser:

GetURL("http://freeswitch:works@192.168.43.60:8080/webapi/originate?user/1001%201002%20XML%20default")

Initially, one softphone is ringing, after a few seconds, the second is ringing.



As a conclusion, or a small practical implementation


Not so long ago, I had a need to organize communication with a person who could not physically call (dial a number) on a cell phone. At the moment, the need for this has disappeared, but still decided to check the possibility of implementation. Using a VoIP gateway (a more budget solution on FXS terminations or a higher cost GSM gateway), you can implement this if you want to use a smart home button.

The second option: MajorDoMo smart home system has voice assistant Alice. Now you can try to connect the "Smart Home" with the owner and his mobile phone through public networks.

A few links

Website of the company ClueCon developer FreeSWITCH
English documentation FreeSWITCH
Website of the developer MajorDoMo
Part One: A small step-by-step instruction on installing the Smart Home operating system based on the Raspberry single-board computer, the Z-Way RaZberry module and the MajorDoMo software
Part Two: continued: the Z-Way RaZberry module and the MajorDoMo software
Part three: we continue to create wireless smart home

Also popular now: