Auto start freeswitch in cent OS

After compiling and  installing freeswitch on centOS from freeswitch source files , we can just copy  /usr/src/freeswitch/build/freeswitch.init.redhat   file to /etc/init.d directory and   correct the freeswitch path entries  to make it start at boot time .

copy the file to init.d directory and  add permissions

#cp /usr/src/freeswitch/build/freeswitch.init.redhat /etc/init.d/freeswitch

#chmod 755 /etc/init.d/freeswitch

edit the file  and correct the freeswitch path entries . On my  freeswicth  test server the entries are like below

 

PROG_NAME=freeswitch
PID_FILE=${PID_FILE-/usr/local/freeswitch/log/freeswitch.pid}
FS_USER=${FS_USER-freeswitch}
FS_FILE=${FS_FILE-/usr/local/freeswitch/bin/freeswitch}
FS_HOME=${FS_HOME-/usr/local/freeswitch}
LOCK_FILE=/var/lock/subsys/freeswitch
FREESWITCH_ARGS=”-nc”

 

save the file  and  add it to auto start services list

 

chkconfig –level 345 freeswitch on

 

now chkconfig –list freeswitch should show something like below

<25>:chkconfig –list freeswitch
freeswitch 0:off 1:off 2:off 3:on 4:on 5:on 6:off

 

If we restart the system it should start free-switch automatically .

netstat -ptuln  command output will show if  free-switch is listening to the ports

 

 

Capture

 

 

A2billing and Astersik

Finallly I got the Asterisk+freeswitch  in a single system up and running  with fusion pbx as front end for freeswitch  and A2billing for Astersik .

You may wonder why we needed this complicated  single box all-in one setup . I wanted to use this setup for our office internal PBX   as well as integrating DID number purchase panel and for international calls.

 

 

I have got few issues while configuring  this system .

Issue 1 :

 

After installing freepbx and asterisk on teh same system i wanted to change free switch sip port from 5060 to any other port  as asterisk is already using the port 5060 .

So i edited the file vars.xml

# vi /usr/local/freeswitch/conf/vars.xml

 

Issue2:

Just after installing a2billing , i renamed the default web directory  /var/www/html/a2billing  to something else  and  it caused the extensions/pins i created not registering and I could not reload asterisk from a2billing interface .

I realized that this is  because of missing short link for /var/lib/asterisk/agi-bin/lib -> /var/www/html/renamed/common/lib

# cd /var/lib/asterisk/agi-bin

#ln -s /var/www/html/a2billing/common/lib  lib

 

 Issue 3:

I wanted a2billing take care of asterisk configuration files and not to restart asterisk manually when there is a change ,

for this i turn of  “Asterisk real time” in system settings –>global list —>global

use_realtime=NO

 

Issue4:

Every-time I place a outbound call , a2billing plays the audio saying ” enter the number you wish to dial and press the pound key”. I dont want this but  place the calls directly .

under systemsettings–>Global list –> Agi-conf1  , I changed below values to ‘NO’

play_audio=no

say_timetocall =no
say_balance_after_auth=no
say_balance_after_call=no
say_rateinitial=no

 

Issue 5:

By enabling debug level =4  in agi-conf , I understood why my outbound calls are not connecting .

by disabling caller id authentication in agi-conf,  i made it work finally .

cid_enable = NO

below is the log from a2billing log files

 

#tail -f  /var/log/a2billing/a2billing_agi.log

[03/11/2012 18:25:33]:[file:Class.A2Billing.php – line:2807 – uniqueid:1351947326.58]:[CallerID:27071]:[CN:27071]:[[SET CHANNEL(language) en]]

[03/11/2012 18:25:33]:[file:Class.A2Billing.php – line:2811 – uniqueid:1351947326.58]:[CallerID:27071]:[CN:27071]:[[credit= :: tariff= :: status= :: isused= :: simultaccess= :: typepaid=0 :: creditlimit=0 :: language=en]]
[03/11/2012 18:25:33]:[file:Class.A2Billing.php – line:2850 – uniqueid:1351947326.58]:[CallerID:27071]:[CN:27071]:[[ERROR CHECK CARD : prepaid-auth-fail (cardnumber:27071)]]
[03/11/2012 18:25:33]:[file:a2billing.php – line:178 – uniqueid:1354547326.58]:[CallerID:27071]:[CN:27071]:[[TRY : callingcard_ivr_authenticate]]
[03/11/2012 18:25:33]:[file:a2billing.php – line:620 – uniqueid:1354547326.58]:[CallerID:27071]:[CN:27071]:[[AUTHENTICATION FAILED (cia_res:-2)]]
[03/11/2012 18:25:33]:[CallerID:27071]:[CN:27071]:[[exit]]

Uninstalling freepbx and asterisk manually

 

First stop asterisk . If you are running freepbx enter the command “amportal stop”

 

killall -9 safe_asterisk

killall -9 asterisk
then unload zaptel drivers

lsmod | grep zaptel

if this returns blank , skip this step if it retruns something like below then remove the drivers with modprobe command

zaptel 214820 2 wcfxo,wctdm
crc_ccitt 2113 1 zaptel
we can remove zaptel modules in reverse order
modprobe -r wcfxo
modprobe -r wctdm
repeat this for all other zaptel submodules

modprobe -r zaptel
Now confirm that all zaptel drivers have been removed ,if you enter “lsmod | grep zaptel” it will return nothing.

Now remove asterisk directories
rm -rf /etc/asterisk
rm -f /etc/zaptel.conf
rm -rf /var/log/asterisk
rm -rf /var/lib/asterisk
rm -rf /var/spool/asterisk
rm -rf /usr/lib/asterisk

Uninstalling  freepbx  is as simple as just removing the freepbx web directories and drop the database
rm -rf /var/www/html/panel
rm -rf /var/www/html/admin

 

Changing default passwords of elastix

Elastix , which is a free forked version of asterisk pbx product comes with integrated ready to use add-ons like a2billing  ( billing module for voip/telephony ) , vtigercrm  etc.,

 

After installing we must change default passwords for elastix admin , a2billing and vitigercrm admin .

This can be done easily while installation time ( with new versions ) , or after logging into the panel with default passwords( older versions).

 

But  there was serious security bug ( i think it is patched now ) with elastix , where somebody can hack  the elastix box with the default password of built in user ‘asteriskuser’  and  able to make calls.

 

Here are the steps i followed to change astersikuser password

 

Step1 :

changing  password in database

-ssh to elastixbox with root privileges

-connect to sql  console  by typing  # mysql -u root -p

-now enter the mysql root password ( you can find this in /etc/elastix.conf  and you can even change it by typing #mysqladmin -u root -p’oldpassword‘ password ‘newpassword‘)

 

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| asterisk           |
| asteriskcdrdb      |
| meetme             |
| mya2billing        |
| mysql              |
| roundcubedb        |
| test               |
| vtigercrm510       |
+——————–+
9 rows in set (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> set password for ‘asteriskuser’@’localhost’ = PASSWORD(‘newpassword‘);

Step2:

change asteriskuser password in /etc/amportal.conf

now run command  # /usr/src/AMP/apply_conf.sh to apply the changes

Step3:

type #grep -r “asteriskuser” /etc/asterisk/*   to find files with asteriskuser entries and change the password to newpassword

 

[root@vm2 ]# grep -r “asteriskuser” /etc/asterisk/*
/etc/asterisk/cbmysql.conf:user=asteriskuser
/etc/asterisk/cdr_mysql.conf:user = asteriskuser
/etc/asterisk/res_mysql.conf:dbuser = asteriskuser

 

 

 

*replace newpassword with your own password