Freeswitch CI/CD on Ubuntu 22.04 & Debian 11 [PART 1]

Install Freeswitch across Ubuntu 22.04 LTS & Debian 11 bullseye, Better handling of dependencies, create FreeSWITCH .deb files

Freeswitch CI/CD on Ubuntu 22.04 & Debian 11 [PART 1]
Photo by Quino Al on Unsplash

This series of articles is for Freeswitch developers who fork the official repositories and add their own features, requiring custom compilations every time. Also for those who need FreeSWITCH on the current Linux distributions.

Note: to achieve this we have to downgrade some essential components such as OpenSSL, and GCC in order to accomplish the compilation of Freeswitch.

The following tutorials will enable you to install Freeswitch on AMD and ARM architectures, as I do on daily basis.

Our goal in this series of articles is to cover in :

  • PART 1: Install Freeswitch across Ubuntu 22.04 LTS & Debian 11 bullseye, Better handling of dependencies, generate FreeSWITCH.deb files, and push them into an s3 bucket for future deployments.
  • PART 2: Continuous Integration (CI) using GitHub Actions or DroneCI.
  • PART 3: Adding Freeswitch sounds & custom ringtones to the FreeSWITCH.deb installer.
  • PART 4: Continuous Deployment (CD) for FreeSWITCH deployment with Ansible.

Step 1 : (Skip if you already forked the Freeswitch repository) :

Forking Freeswitch repository

Step 2: Compiling Freeswitch on a Ubuntu 22.04 LTS VM

Let’s update the packages of the VM first :

apt update -y  
apt upgrade -y  
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata

Installing Freeswitch dependencies (ubuntu 22.04)

apt install curl wget git subversion build-essential autoconf automake libtool libncurses5 libncurses5-dev make libjpeg-dev libtool libtool-bin libsqlite3-dev libpcre3-dev libspeexdsp-dev libldns-dev libedit-dev yasm liblua5.2-dev libopus-dev cmake libtiff-dev  libcodec2-dev libcodec2-dev portaudio19-dev libmagickcore-dev libmp3lame-dev libmpg123-dev libshout3-dev libvlc-dev libpq-dev libmariadb-dev libldap2-dev erlang librabbitmq-dev libsmpp34-dev libyaml-dev libmongoc-dev libopencv-dev  libmemcached-dev libavformat-dev  libh2o-dev libsoundtouch-dev libhiredis-dev libopus-dev  autoconf automake devscripts gawk gettext libcurl4-openssl-dev libdb-dev libedit-dev libgdbm-dev libldns-dev libncurses5-dev libopus-dev libopus-ocaml libpcre3-dev libperl-dev libpq-dev libspeex-dev libspeexdsp-dev libssl-dev libtiff5-dev libtool libtool-bin libvorbis0a libogg0 libsqlite3-dev libogg-dev libvorbis-dev portaudio19-dev libshout3-dev libmpg123-dev libmp3lame-dev yasm libbsd-dev flite flite1-dev libflite1 liblua5.2-0 liblua5.2-dev lua5.2 luarocks libsndfile-dev -y

We have to downgrade GCC to version 10 instead of the latest version to have a working compilation :

apt install gcc-10 g++-10 cpp-10 -y  
ln -s /usr/bin/gcc-10 /usr/bin/gcc  
ln -s /usr/bin/g++-10 /usr/bin/g++

We have also to downgrade OpenSSL to version1 :(, I have read in their GitHub Issues that they are working on a new release to support Opnessl v3

mkdir -p /opt/openssl  
wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz --no-check-certificate -P /opt/openssl/ 
tar -xzvf /opt/openssl/openssl-1.1.1q.tar.gz -C /opt/openssl/  
cd /opt/openssl/openssl-1.1.1q 
./config  
make install 
cp /usr/local/bin/openssl /usr/bin/openssl

Let’s install Spandsp & Sofia-sip which are the two very essential dependencies to compile Freeswitch.

SpanSDP (low-level signal processing library that modulates and demodulates signals commonly used in telephony, such as the “noise” generated by a fax modem or DTMF touchpad)

cd /opt 
git clone https://github.com/freeswitch/spandsp /opt/spandsp 
cd /opt/spandsp 
./bootstrap.sh 
./configure 
make 
make install

Sofia-sip (SIP User-Agent library, compliant with IETF RFC3261)

cd /opt 
git clone https://github.com/freeswitch/sofia-sip.git /opt/sofia-sip 
cd /opt/sofia-sip 
./bootstrap.sh 
./configure 
make 
make install

Freeswitch compilation :

cd /opt

Clone from the official repository or from your forked repository, you can also replace the master to checkout the branch you wish to use.

we will checkout to the latest version released v1.10.8 :

git clone https://github.com/freeswitch/freeswitch.git -b v1.10.8 /opt/freeswitch
cd /opt/freeswitch 
./bootstrap.sh -j

Then we run the configure command, here I choose to use ZRTP, and PostgreSQL, you can edit as you wish :

CFLAGS=-Wno-error ./configure --prefix=/usr/local/freeswitch --enable-core-pgsql-support --enable-zrtp

Now you can edit the following files to choose the modules to use in FreeSWITCH( I highly recommend putting only the modules needed for better performance/troubleshooting)

Here’s my list of modules :

/opt/freeswitch/modules.conf :

applications/mod_abstraction 
applications/mod_bert 
applications/mod_blacklist 
applications/mod_callcenter 
applications/mod_cidlookup 
applications/mod_cluechoo 
applications/mod_commands 
applications/mod_conference 
applications/mod_curl 
applications/mod_db 
applications/mod_directory 
applications/mod_distributor 
applications/mod_dptools 
applications/mod_easyroute 
applications/mod_enum 
applications/mod_esf 
applications/mod_esl 
applications/mod_expr 
applications/mod_fifo 
applications/mod_fsk 
applications/mod_fsv 
applications/mod_hash 
applications/mod_httapi 
applications/mod_http_cache 
applications/mod_lcr 
applications/mod_sms 
applications/mod_snom 
applications/mod_sonar 
applications/mod_spandsp 
applications/mod_spy 
applications/mod_stress 
applications/mod_valet_parking 
applications/mod_voicemail 
applications/mod_voicemail_ivr 
codecs/mod_amr 
codecs/mod_b64 
codecs/mod_g723_1 
codecs/mod_h26x 
codecs/mod_opus 
codecs/mod_vpx 
dialplans/mod_dialplan_asterisk 
dialplans/mod_dialplan_xml 
endpoints/mod_loopback 
endpoints/mod_portaudio 
endpoints/mod_rtc 
endpoints/mod_rtmp 
endpoints/mod_skinny 
endpoints/mod_sofia 
endpoints/mod_verto 
event_handlers/mod_cdr_csv 
event_handlers/mod_cdr_sqlite 
event_handlers/mod_event_socket 
event_handlers/mod_format_cdr 
event_handlers/mod_json_cdr 
formats/mod_local_stream 
formats/mod_native_file 
formats/mod_png 
formats/mod_portaudio_stream 
formats/mod_shout 
formats/mod_sndfile 
formats/mod_tone_stream 
loggers/mod_console 
loggers/mod_logfile 
loggers/mod_syslog 
say/mod_say_en 
xml_int/mod_xml_cdr 
xml_int/mod_xml_curl 
xml_int/mod_xml_rpc 
xml_int/mod_xml_scgi 
databases/mod_pgsql

then we run the make command to start our compilation, it should take from 5 to 15mins depends on the capabilities of the VM :

make

Once our make command is finished successfully, we are not going to run make install since we want to generate a .deb file that is installable elsewhere.

Deb Creation

The current latest (when writing this article) is version released is v1.10.8

mkdir -p /opt/freeswitch/freesiwtch-v1.10.8/DEBIAN 
 
cat > /opt/freeswitch/freesiwtch-v1.10.8/DEBIAN/control << EOL 
Package: FreeSWITCH  
Version: v1.10.8 
Architecture: all 
Maintainer: Soufiane Bouchaara <[email protected]> 
Description: FreeSWITCH 
EOL 
 
mkdir -p /opt/freesiwtch/freesiwtch-v1.10.8/usr/local 
mkdir -p /opt/freesiwtch/freesiwtch-v1.10.8/usr/local/freesiwtch/lib/ 
mkdir -p /opt/freesiwtch/freesiwtch-v1.10.8/usr/local/bin 
mkdir -p /opt/freesiwtch/freesiwtch-v1.10.8/usr/local/freeswitch/lib 
cp /opt/freesiwtch/freeswitch /opt/freesiwtch/freesiwtch-v1.10.8/usr/local/bin/ 
cp /opt/freesiwtch/fs_cli /opt/freesiwtch/freesiwtch-v1.10.8/usr/local/bin/ 
cp -r /opt/freesiwtch/.libs /opt/freesiwtch/freesiwtch-v1.10.8/usr/local/bin/ 
cp -r /opt/freesiwtch/freesiwtch-v1.10.8/usr/local/bin/.libs /opt/freesiwtch/freesiwtch-v1.10.8/usr/local/freesiwtch/lib 
dpkg-deb --build --root-owner-group /opt/freesiwtch/freesiwtch-v1.10.8

The deb file must be created, you can check it as follow :

ls freesiwtch-v1.10.8.deb

You can copy it to your S3 bucket for further deployments :

aws s3 cp freesiwtch-v1.10.8.deb s3://<your bucket name>

The next articles will cover the following topics :

If you face any issues, please feel free to contact me at contact[at]soufianebouchaara.com