Recorder installation v 1.10.10
Pre Conditions:
Before installing Recorder you must run these commands.
#sudo apt update
#sudo apt install -y gnupg2 wget lsb-release [Optional]
#sudo
Navigate to "/etc/apt/sources.list
"
Comment out this line [ deb cdrom:[Debian GNU/Linux 12.2.0 Bookworm - Official amd64 DVD Binary-1 with firmware 20231007-10:29]/ bookworm main non-free-firmware
] with #.
Also make sure that the repositories listed in the "/etc/apt/sources.list
" are for the latest release of Debain. (Currently 12.2 'Bookworm')
Below are the dependencies for Debain Bookworm. If you have a different version please add accordingly.
#deb http://deb.debian.org/debian/ bookworm main
#deb-src http://deb.debian.org/debian/ bookworm main
#deb http://deb.debian.org/debian/ bookworm-updates main
#deb-src http://deb.debian.org/debian/ bookworm-updates main
If you make any changes to the "sources.list
" file. Make sure to run the update command again.
Update your system
#sudo apt-get update
Go into super user mode to get rid of permission issues.
#su
For the latest version of Debian such as Book worm we need to follow the following steps as well.
Before we install the recorder, we need to clone the Sofia-sip and SpandDSP in /usr/src directory. In case git is not installed please install the git by running the 'apt install git' command.
#git clone https://github.com/freeswitch/sofia-sip
#git clone https://github.com/freeswitch/spandsp
Now add all these dependencies. Some of these dependencies may not be available in the future or the latest versions will be available. Please exclude it from the command and add the latest one.
#sudo apt-get -y install build-essential subversion automake autoconf wget libtool libtool-bin libncurses5-dev libssl-dev libsndfile1-dev
#sudo apt-get install git libcurl4-openssl-dev libexpat1-dev libssl-dev libtiff5-dev libx11-dev unixodbc-dev python3-dev zlib1g-dev libasound2-dev libogg-dev libvorbis-dev libperl-dev libgdbm-dev libdb-dev python3-dev uuid-dev bison autoconf g++ libncurses-dev
Run the following commands one by one to install Sofia Sip:
cd /usr/src/sofia-sip
#./bootstrap.sh
#./configure
#sudo make && sudo make install
Run the following commands one by one to install Spandsp:
#cd /usr/src/spandsp
#git reset --hard 67d2455efe02e7ff0d897f3fd5636fed4d54549e
#./bootstrap.sh
#./configure
#sudo make && sudo make install
Go to the signal wire website and login and then make a token.. If you already have a token please proceed.
Now, run the following commands one by one to add repositories to your apt directory
In case you do not have TOKEN for recorder click here to get token for your recorder.
#$TOKEN=pat_8Errev5k19bRCnmsGdJSxGEs [In case you don't have your token please get one from signalwire website]
#wget --http-user=signalwire --http-password=$TOKEN -O /usr/share/keyrings/signalwire-freeswitch-repo.gpg https://freeswitch.signalwire.com/repo/deb/debian-release/signalwire-freeswitch-repo.gpg
#echo "machine freeswitch.signalwire.com login signalwire password $TOKEN" > /etc/apt/auth.conf
#chmod 600 /etc/apt/auth.conf
#echo "deb [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" > /etc/apt/sources.list.d/freeswitch.list
#echo "deb-src [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://freeswitch.signalwire.com/repo/deb/debian-release/ `lsb_release -sc` main" >> /etc/apt/sources.list.d/freeswitch.list
Note that "#" is the indicator of a new command. Do not copy and run all commands at the same time.
After these commands run the update command and the install command.
#sudo apt update
#apt-get build-dep freeswitch
Then get the source. Use the -b flag to get a specific branch for specified version v1.10.10
#cd /usr/src/
#git clone https://github.com/signalwire/freeswitch.git -b v1.10.10 freeswitch
#cd freeswitch
Because we're in a branch that will go through many rebases, it’s better to set this one, or you'll get CONFLICTS when pulling (update).
#git config pull.rebase true
#./bootstrap.sh -j
#./configure
#make
#make install
Edit the Recorder System Service
#sudo nano /etc/systemd/system/freeswitch.service
Replace the previous content with this version (omitting User and Group):
[Unit]
Description=FreeSWITCH
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/freeswitch/run/freeswitch.pid
ExecStart=/usr/local/freeswitch/bin/freeswitch -u root -g root -ncwait -nonat
ExecStop=/usr/local/freeswitch/bin/freeswitch -stop
Restart=always
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=60000
LimitSTACK=250000
TimeoutSec=300
[Install]
WantedBy=multi-user.target
Now Reload System and Enable Recorder
#sudo systemctl daemon-reload
#sudo systemctl enable freeswitch
Now start Recorder
#sudo systemctl start freeswitch
Now Verify Recorder Status
#sudo systemctl status freeswitch
Add to path
#export PATH=$PATH:/usr/src/freeswitch
Also add in the path in the bash or zsh file .
Open the file in an editor:
If you're using bash (most common):
CODE#nano ~/.bashrc
If you're using zsh:
CODE#nano ~/.zshrc
Add this line at the end of the file:
#export PATH=$PATH:/usr/src/freeswitch
Save the file (In nano, press CTRL + X
, then Y
, then ENTER
).
Apply the changes by running:
#source ~/.bashrc # or source ~/.zshrc if using zsh
Now run fs_cli and you Recorder CLI will be opened
Recorder has been installed proceed further to configure it.
1- Recording Script
The first step we need to take on freeswitch is to download record.lua file.
Connect to the VM where free switch is installed.
Place it in the "scripts" directory. It can be found under "/usr/local/freeswitch/scripts/" or "/usr/share/freeswitch/scripts/" depending on whether you installed recorder from source or package, respectively.
Open record.lua and change the url
url = "http://<ip-address>:9900/mixer/sip-data"
. Andurl = "http://<ip-address>:9900/mixapi"
Create a directory with the path /var/vrs/recordings/cucmRecording using mkdir command.
Enter to this cucmRecording folder and create two more directories with names “streams“ and “sessions”.
Assign all user permissions to all these directories i.e cucmRecording, streams, sessions. this could be done using chmod command with 'R' tag
CODE#chmod 777 -R "/var/vrs/"
Edit/open the recording script (record.lua) which could be located on "/usr/local/freeswitch/scripts/" or "/usr/share/freeswitch/scripts/"
Inside record.lua assign the correct paths to the
"recording_dir"
, “recording_path
" and “mixedRecordingDir
" variables.
recording_dir = "/var/vrs/recordings/cucmRecording/streams/"
recording_path = "/var/vrs/recordings/cucmRecording/streams/"
mixedRecordingDir= "/var/vrs/recordings/cucmRecording/sessions/"
session:consoleLog("info", "/var/vrs/recordings/cucmRecording/sessions/")
2 - Dialplan Configuration
Switch to the dialplan directory
/usr/local/freeswitch/conf/dialplan
Add the following lines of code in the public .xml file. Provide your CUCM ip address
<IP_ADDRESS>
make sure the ip is in quotes e.g “192.168.1.26“.
<extension name="outside_call" continue="true">
<condition>
<action application="set" data="outside_call=true"/>
<action application="log" data="INFO PP-----${sip_from_host}--------------Starting Record Dialplan --------------12124"/>
<action application="export" data="RFC2822_DATE=${strftime(%a, %d %b %Y %T %z)}"/>
</condition>
</extension>
<extension name="CUCM Recording Profile">
<action application="log" data="INFO Entering Call from CUCM"/>
<condition field="${sip_from_host}" expression="<IP_ADDRESS>">
<action application="lua" data="record.lua"/>
</condition>
</extension>
in case of multiple CUCM we need to add all the ip addresses using '|' pipe. just as shown in condition field
<extension name="CUCM Recording Profile">
<action application="log" data="INFO Entering Call from CUCM"/>
<condition field="${sip_from_host}" expression="192.168.1.26|192.168.1.27|192.168.1.28">
<action application="lua" data="record.lua"/>
</condition>
</extension>
3 - SIP Profiles
Switch to the sip_profiles directory in
/usr/local/freeswitch/conf/sip_profiles.
Edit the internal.xml and external.xml SIP profiles and enable or uncomment the Third Party Call Control option in both of them.
Change the value flag to "true" if it is set to "false" or "proxy".
<param name="enable-3pcc" value="true"/>
We also need to add one more line to the internal.xml file if it doesn't already exist.
<param name="parse-all-invite-headers" value="true"/>
Now set the rtp-ip, sip-ip, ext-rtp-ip and ext-sip-ip equals to your recorder’s machine ip in external.xml. IP must be in “ “
<param name="rtp-ip" value="<ip-address>"/>
<param name="sip-ip" value="<ip-address>"/>
<param name="ext-rtp-ip" value="<ip-address>"/>
<param name="ext-sip-ip" value="<ip-address>"/>
4- Access Control List (ACL)
Navigate to the directory "/usr/local/freeswitch/conf/autoload_configs
"
Open the file "acl.conf.xml
" and add the following line “<node type="allow" cidr="<CUCM_IP>/32"/>
” under the "<node type="allow" domain="$${domain}"/>"
line. (Replace <CUCM_IP> with the IP address of your CUCM installation). In case of multiple CUCM send invite recorder, add multiple lines each to allow each one of the CUCMs.
<node type="allow" domain="$${domain}"/>
.
.
<node type="allow" cidr="<CUCM_IP>/32"/> <!--- Add this line and replace <CUCM_IP> with the IP address of your CUCM installation -->
5-Disable STUN
Navigate to the file vars.xml in /usr/local/freeswitch/conf
open the file and comment out following lines.
<X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=stun:stun.freeswitch.org"/>
<X-PRE-PROCESS cmd="stun-set" data="external_sip_ip=stun:stun.freeswitch.org"/>
Since it is a pre process we need to restart the Recorder.
#sudo systemctl restart freeswitch
6- Utilities
After the Recorder is restarted, Install the following utilities by running the commands:
#sudo apt install -y lua-socket
#sudo apt install -y lua-dkjson
Restart recorder once configuration is completed
# systemctl restart freeswitch
In case of any problem, complete documentation can be found here.
If Recorder was already installed and you want to reinstall it follow this guide
To completely uninstall recorder from a Debian 12 server, you can follow these steps. This will remove both the recorder application and its configuration files:
Stop recorder
First, stop the Recorder service if it's running:
#sudo systemctl stop freeswitch
Uninstall Recorder Packages
Use apt to remove the recorder packages. This will uninstall recorder but leave the configuration files:
sudo apt remove --purge freeswitch*
The --purge flag ensures that configuration files are also removed.
Remove Dependencies
After uninstalling recorder, you can remove any unneeded dependencies:
sudo apt autoremove
Delete Leftover Files
Check for any leftover Recorder directories or files and remove them manually:
#sudo rm -rf /usr/local/freeswitch
#sudo rm -rf /etc/freeswitch
#sudo rm -rf /var/lib/freeswitch
#sudo rm -rf /var/log/freeswitch
#sudo rm -rf /var/run/freeswitch
Remove User and Group
If Recorder created a specific user and group, you can delete them as well:
#sudo deluser freeswitch
#sudo delgroup freeswitch
Verify Removal
You can check if FreeSWITCH has been completely removed by running:
which freeswitch
This should return no output if Recorder is uninstalled completely.
Reboot (Optional)
If you want to ensure everything is properly cleaned up, you can reboot the server:
#sudo reboot
This process should completely uninstall FreeSWITCH from your Debian 12 server.