Skip to content

Instantly share code, notes, and snippets.

@areski
Last active August 2, 2022 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save areski/6ab7ee00d7025a1eaa97 to your computer and use it in GitHub Desktop.
Save areski/6ab7ee00d7025a1eaa97 to your computer and use it in GitHub Desktop.
Install LuaSQL for FreeSWITCH on Debian7
#!/bin/bash
#
# Install LuaSQL on Debian7
#
#Install Dependencies
apt-get install -y lua5.2 liblua5.2-dev
apt-get install -y libpq-dev
#apt-get install lua-sql-postgres-dev
#apt-get install liblua5.1-sql-postgres-dev
#apt-get remove lua-sql-postgres-dev
#apt-get remove liblua5.1-sql-postgres-dev
#Install LuaSQL
cd /usr/src/
wget 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 and Debian7
#You will need to adapt the config to suit the OS and arch
cp config config.orig
rm config
wget https://gist.githubusercontent.com/areski/4b82058ddf84e9d6f1e5/raw/5fae61dd851960b7063b82581b1b4904ba9413df/luasql_config -O config
#Compile and install
make
make install
#Create a file to test postgres on FreeSWITCH via LuaSQL
echo '''
luasql = require "luasql.postgres"
env = assert(luasql.postgres())
''' > /usr/src/testpg.lua
echo ""
echo "You should found this file installed /usr/local/lib/lua/5.5/luasql/postgres.so"
echo ""
echo "Now edit your /etc/freeswitch/autoload_configs/lua.conf.xml and ensure that luasql is reachable"
echo ""
echo '''
<param name="module-directory" value="/usr/local/lib/lua/5.2/?.so"/>
<param name="module-directory" value="/usr/local/lib/lua/5.2/luasql/?.so"/>
'''
echo
echo "then restart FreeSWITCH"
echo "connect on CLI: fs_cli"
echo ""
echo "you can run the script with:"
echo "luarun /usr/src/testpg.lua"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment