Skip to content

Instantly share code, notes, and snippets.

@johndiego
Forked from areski/install-fs16.sh
Created August 8, 2022 13:29
Show Gist options
  • Save johndiego/601b89bfc54c3e5c98a73bb222b01360 to your computer and use it in GitHub Desktop.
Save johndiego/601b89bfc54c3e5c98a73bb222b01360 to your computer and use it in GitHub Desktop.
Install FreeSWITCH 1.6
#!/bin/bash
#
FS_CONFIG_PATH=/etc/freeswitch
FS_CONF_PATH=/usr/src/newfies-dialer/install/freeswitch-conf
#Set branch to install develop / default: master
if [ -z "${INSTALL_FS}" ]; then
INSTALL_FS='yes'
fi
# Identify Linux Distribution type
func_identify_os() {
SCRIPT_NOTICE="This script is only intended to run on Debian (64bits) 8.X"
if [ -f /etc/debian_version ] ; then
DIST='DEBIAN'
if [ "$(lsb_release -cs)" != "jessie" ]; then
echo $SCRIPT_NOTICE
exit 255
fi
DEBIANCODE=$(lsb_release -cs)
else
echo $SCRIPT_NOTICE
exit 1
fi
}
# Install FreeSWITCH
func_install_freeswitch() {
echo ""
echo "Setting up dependencies for FreeSWITCH..."
echo ""
if [ -d "/etc/apt/sources.list.d/freeswitch.list" ]; then
echo "FreeSWITCH sources.list already added!"
else
echo "Setup new sources.list entries for FreeSWITCH"
echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list
wget -O - http://files.freeswitch.org/repo/deb/freeswitch-1.6/key.gpg |apt-key add -
fi
apt-get update
apt-get -y install locales-all
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
# Install useful tools
apt-get -y install unzip zip sox sqlite3 ncftp nmap
apt-get -y install flite flite1-dev unixodbc-dev odbc-postgresql
apt-get -y install libvorbis0a libogg0 libogg-dev libvorbis-dev libmp3lame-dev
apt-get -y install autoconf2.64 automake autotools-dev binutils bison build-essential cpp curl flex gcc
# install FreeSWITCH
apt-get -y install freeswitch-all
apt-get -y install python-esl
}
# Install LuaSQL
func_install_luasql() {
if [ ! -d "/usr/src/luasql-2.3.0" ]; then
echo ""
echo "LuaSQL will now be installed..."
echo ""
# Install Dependencies
apt-get -y install lua5.2 liblua5.2-dev
apt-get -y install libpq-dev
# Install LuaSQL
cd /usr/src/
wget --no-check-certificate https://github.com/keplerproject/luasql/archive/v2.3.0.zip
unzip v2.3.0.zip
cd luasql-2.3.0/
# Copy a config file adapted for 64bit
cp config config.orig
rm config
wget --no-check-certificate https://gist.githubusercontent.com/areski/4b82058ddf84e9d6f1e5/raw/5fae61dd851960b7063b82581b1b4904ba9413df/luasql_config -O config
# Compile and install
make
make install
fi
}
# Configure FreeSWITCH
func_configure_fs() {
echo ""
echo "Enable FreeSWITCH modules"
echo "-------------------------"
cd $FS_CONFIG_PATH/autoload_configs/
[ -f modules.conf.xml ] && cp modules.conf.xml modules.conf.xml.bak
sed -i -r -e "s/<\!--\s?<load module=\"mod_smpp\"\/>\s?-->/<load module=\"mod_smpp\"\/>/g" modules.conf.xml
sed -i -r \
-e "s/<\!--\s?<load module=\"mod_lua\"\/>\s?-->/<load module=\"mod_lua\"\/>/g" \
-e "s/<\!--\s?<load module=\"mod_dingaling\"\/>\s?-->/<load module=\"mod_dingaling\"\/>/g" \
-e "s/<\!--\s?<load module=\"mod_shell_stream\"\/>\s?-->/<load module=\"mod_shell_stream\"\/>/g" \
-e "s/<\!-- \s?<load module=\"mod_shell_stream\"\/>\s? -->/<load module=\"mod_shell_stream\"\/>/g" \
-e "s/<\!--\s?<load module=\"mod_shout\"\/>\s?-->/<load module=\"mod_shout\"\/>/g" \
-e "s/<\!--\s?<load module=\"mod_tts_commandline\"\/>\s?-->/<load module=\"mod_tts_commandline\"\/>/g" \
-e "s/<\!--\s?<load module=\"mod_smpp\"\/>\s?-->/<load module=\"mod_smpp\"\/>/g" \
-e "s/<\!--\s?<load module=\"mod_flite\"\/>\s?-->/<load module=\"mod_flite\"\/>/g" \
-e "s/<\!--\s?<load module=\"mod_say_ru\"\/>\s?-->/<load module=\"mod_say_ru\"\/>/g" \
-e "s/<\!--\s?<load module=\"mod_say_zh\"\/>\s?-->/<load module=\"mod_say_zh\"\/>/g" \
-e 's/mod_say_zh.*$/&\n <load module="mod_say_de"\/>\n <load module="mod_say_es"\/>\n <load module="mod_say_fr"\/>\n <load module="mod_say_it"\/>\n <load module="mod_say_nl"\/>\n <load module="mod_say_hu"\/>\n <load module="mod_say_th"\/>/' \
modules.conf.xml
[ -f lua.conf.xml ] && mv lua.conf.xml lua.conf.xml.bak
cp $FS_CONF_PATH/lua.conf.xml lua.conf.xml
#Configure Dialplan
#cd $FS_CONFIG_PATH/conf/dialplan/
#Configure XML CDR
#cd $FS_CONFIG_PATH/conf/autoload_configs/
#this is commented as we don't use xml_cdr anymore
## Place Newfies XML CDR conf in FreeSWITCH
#[ -f xml_cdr.conf.xml ] && mv xml_cdr.conf.xml xml_cdr.conf.xml.bak
# cp $FS_CONF_PATH/xml_cdr.conf.xml xml_cdr.conf.xml
#create dir to store send error of CDR
#mkdir /usr/local/freeswitch/log/err_xml_cdr/
}
# Steps to perform after FreeSWITCH installation
post_freeswitch_install() {
#Install luaSQL
func_install_luasql
#Configure FreeSWITCH
func_configure_fs
#Start FreeSWITCH
service freeswitch restart
}
# Verify that we run Debian 8.x
func_identify_os
if [ $INSTALL_FS = "yes" ]; then
clear
echo ""
echo "FreeSWITCH will now be installed!"
echo "---------------------------------"
#Install FreeSWITCH
func_install_freeswitch
post_freeswitch_install
if [ -f "/usr/bin/freeswitch" ]; then
echo ""
echo "*********************************************"
echo "Congratulations, FreeSWITCH is now installed!"
echo "*********************************************"
echo ""
else
echo ""
echo "FreeSWITCH installation failed!"
echo ""
exit 255
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment