Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mariogasparoni/dc4490fcc85a527ac45f3d42e35a962c to your computer and use it in GitHub Desktop.
Save mariogasparoni/dc4490fcc85a527ac45f3d42e35a962c to your computer and use it in GitHub Desktop.
build-install-freeswitch-1.10-from-source.sh
#!/bin/bash
## Script for building/installing FreeSWITCH from source.
## URL: https://gist.github.com/mariogasparoni/dc4490fcc85a527ac45f3d42e35a962c
## Freely distributed under the MIT license
##
##
set -xe
FREESWITCH_SOURCE=https://github.com/signalwire/freeswitch.git
FREESWITCH_RELEASE=master #or set this to any other version, for example: v1.10.5
PREFIX=/usr/share/freeswitch
# If you want to remove some modules from build, specify/uncomment it here
REMOVED_MODULES=(
# mod_signalwire
# mog_pgsql
)
#Clean old prefix and build
sudo rm -rf $PREFIX
rm -rf ~/build-$FREESWITCH_RELEASE
#install dependencies
sudo apt-get update && sudo apt-get install -y git-core build-essential python python2-dev python3-dev autoconf automake cmake libtool libncurses5 libncurses5-dev make libjpeg-dev pkg-config zlib1g-dev sqlite3 libsqlite3-dev libpcre3-dev libspeexdsp-dev libedit-dev libldns-dev liblua5.1-0-dev libcurl4-gnutls-dev libapr1-dev yasm libsndfile-dev libopus-dev libtiff-dev libavformat-dev libswscale-dev libavresample-dev libpq-dev zip
#clone source and prepares it
mkdir -p ~/build-$FREESWITCH_RELEASE
cd ~/build-$FREESWITCH_RELEASE
PVERSION=( ${FREESWITCH_RELEASE//./ } )
MIN_VERSION=${PVERSION[1]}
PATCH_VERSION=${PVERSION[2]}
if [[ $FREESWITCH_RELEASE = "master" ]] || [[ $MIN_VERSION -ge 10 && $PATCH_VERSION -ge 3 ]]
then
echo "VERSION => 1.10.3 - need to build libsk2, signalwire-c , spandsp and sofia-sip separatedly"
#build and install libks2 - needed for mod_verto and signalwire
git clone https://github.com/signalwire/libks.git
cd libks
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX
make
sudo make install
cd ..
#build and install signalwire-c - needed for mod_signalwire
git clone https://github.com/signalwire/signalwire-c
cd signalwire-c
env PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX
make
sudo make install
cd ..
#build and install libspandev
git clone https://github.com/freeswitch/spandsp.git
cd spandsp
git checkout 67d2455efe02e7ff0d897f3fd5636fed4d54549e # workaround for @signalwire/freeswitch#2158 (thx to @9to1url)
./bootstrap.sh
./configure --prefix=$PREFIX
make
sudo make install
cd ..
#build and install mod_sofia
git clone https://github.com/freeswitch/sofia-sip.git
cd sofia-sip
./bootstrap.sh
./configure --prefix=$PREFIX
make
sudo make install
cd ..
fi
#avoid git access's denied error
touch .config && sudo chown $USER:$USER .config
if [ ! -d freeswitch ]
then
git clone $FREESWITCH_SOURCE freeswitch
cd freeswitch
else
cd freeswitch
git fetch origin
fi
git reset --hard $FREESWITCH_RELEASE && git clean -d -x -f
#remove modules from building
for module in "${REMOVED_MODULES[@]}"
do
sed -i "s/applications\/mod_signalwire/#applications\/mod_signalwire/g" build/modules.conf.in
done
#sed -i "s/databases\/mod_pgsql/#databases\/mod_pgsql/g" build/modules.conf.in
./bootstrap.sh
#configure , build and install
env PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig ./configure --prefix=$PREFIX --disable-libvpx
env C_INCLUDE_PATH=$PREFIX/include make
sudo make install config-vanilla
#package
cd ~/build-$FREESWITCH_RELEASE
zip -r freeswitch-$FREESWITCH_RELEASE.zip $PREFIX
@mariogasparoni
Copy link
Author

Thanks for your script, I can build successfully :-)

Since the things might changed a lot, here are some I updated dependencies:

sudo apt-get update && sudo apt-get install -y git-core build-essential python-is-python3 python3-dev autoconf automake libtool libncurses5 libncurses5-dev make libjpeg-dev pkg-config zlib1g-dev sqlite3 libsqlite3-dev libpcre3-dev libspeexdsp-dev libspeex-dev libedit-dev libldns-dev liblua5.1-0-dev libcurl4-gnutls-dev libapr1-dev yasm libsndfile-dev libopus-dev libtiff-dev libavformat-dev libswscale-dev libswresample-dev libpq-dev zip

spandsp current version not able to compile , need to revert to this version: signalwire/freeswitch#2158 git reset --hard 67d2455efe02e7ff0d897f3fd5636fed4d54549e

also no libks package can install, need to build: sudo git clone https://github.com/signalwire/libks.git /usr/local/src/libks

Thanks @9to1url . I updated the script according to your notes. This should be building fine now.
Also , i included the build for libks in this script, allowing mod_verto to be built without errors.

@mariogasparoni
Copy link
Author

mariogasparoni commented Oct 9, 2023

Yes, I encoutered this issue, as you need to see @mariogasparoni 's script has this: PREFIX=/usr/share/freeswitch

the header file path might different than what you compiled and installed, check that

@sip-stewing
By default, this script generates a zip file which you can copy/extract to install FreeSWITCH to your server.

All files will be extracted at /usr/share/freeswitch and you can run FreeSWITCH with the following command:

sudo /usr/share/freeswitch/bin/freeswitch

@Mubariz00534
Copy link

Thanks for the script. I just i have one question. I was getting the same issue:
"Makefile:966: *** You must install libks to build mod_signalwire. Stop."
After this step:
"sed -i "s/applications/mod_signalwire/#applications/mod_signalwire/g" build/modules.conf.in"
the compilation process finished without an error. My only question will I have signalwire module after installation? Thanks beforehand.
@mariogasparoni

@mariogasparoni
Copy link
Author

@Mubariz00534 , no you won't build mod_signalwire.
Iirc , mod_signalwire requires some lib(s) , but it should be quiet trivial to add it to this script.

I might add mod_signalwire, mod_pgqsql and libvpx so this build will stay as default one (i removed these in the past because they weren't needed by that time)

@Mubariz00534
Copy link

@Mubariz00534 , no you won't build mod_signalwire. Iirc , mod_signalwire requires some lib(s) , but it should be quiet trivial to add it to this script.

I might add mod_signalwire, mod_pgqsql and libvpx so this build will stay as default one (i removed these in the past because they weren't needed by that time)

Thanks so much for the quick reply. I installed all necessary modules, but receiving the same error. I think it might be because of signalwire token. Starting March 17, 2022, it's(token) a must to have. Just wanted to put information here, if someone has the same issue.

@mariogasparoni
Copy link
Author

mariogasparoni commented Nov 6, 2023

Starting March 17, 2022, it's(token) a must to have. Just wanted to put information here, if someone has the same issue.

@Mubariz00534
Yes, if you don't setup your connector at signalwire.com FreeSWITCH logs/console will span a message like this:
2023-11-06 15:51:43.033566 100.00% [NOTICE] mod_signalwire.c:401 Go to https://signalwire.com to set up your Connector now! Enter connection token abcde1234-fghi567...

@mariogasparoni
Copy link
Author

@Mubariz00534
I changed the script so you can build mod_signalwire by default.

Added a var REMOVED_MODULES, if you want to remove any module from building process, but it builds all by default.

@Mubariz00534
Copy link

@mariogasparoni, Thanks so much again for your time. I'll try new script

@wheatforwood
Copy link

wheatforwood commented May 29, 2024

I'm building on a fresh installation of Debian 11. If exclude mod_verto, it works perfectly. But if I try to build mod_verto, I get this error.

mod_verto.c:46:10: fatal error: ks.h: No such file or directory
46 | #include "ks.h"
| ^~~~~~

I see there was previous chatter on this in this thread, about building libks for this. And the script seems to address this by building libks. Yet I still get the error.

I did verify that libks is in ldconfig. and it does seem to be...
debian:~# ldconfig -p | grep libks
libks2.so.2 (libc6,x86-64) => /lib/libks2.so.2
libks2.so (libc6,x86-64) => /lib/libks2.so
libksba.so.8 (libc6,x86-64) => /lib/x86_64-linux-gnu/libksba.so.8

I don't understand why make isn't picking it up. Any thoughts?

@mariogasparoni
Copy link
Author

mariogasparoni commented Jun 24, 2024

@wheatforwood , It looks like libks's headers are missing.

I tried building using debian's 11 docker container and i got no problem. Did you change something before building ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment