Posts Tagged ‘asterisk’

Manually start asterisk using asterisk user

Thursday, September 3rd, 2009

Generally we configure asterisk to auto run on system start up. There may be situations when we may be required to run asterisk manually like when asterisk is overloaded or when asterisk is down for some maintenance.

If so happens, always start asterisk from asterisk user:-


#su asterisk
#asterisk

We should not use any custom user and of course not “root” user. If we start asterisk as any non-asterisk user, various functionalities may be affected like our custom applications may not get permissions to execute asteisk cli commands.

For ex. If we run asterisk as root, then php apps running via apache, when execute asterisk cli commands, get following error:-
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

Run this command
#ls -l /var/run/asterisk/asterisk.ctl
srwxr-xr-x 1 root root 0 Aug 3 04:55 /var/run/asterisk/asterisk.ctl

As shown in the above result, non root users have no write permission.

Hence stop the asterisk using following command:-
#asterisk -rx "stop gracefully"
When asterisk will stop, use above mentioned process of starting asterisk as asterisk user.

Auto update call recording settings to all extensions in asterisk-freepbx

Wednesday, July 1st, 2009

I have 150 extensions in my asterisk-freepbx setup, which are broadly divided into following two classes :-

  1. Record Incoming Call On Demand. Record Outgoing Call On Demand
    Extensions in this class:  8001, 8002, 8003, 8004, 8005 (total 5 in number)
  2. Record All Incoming Call. Record All Outgoing Call
    Extensions in this class:  9001, 9002, … , 9145 (total 145 in number)

To avoid manual configuration of each extension, I had taken following steps:-

  1. Execute following queries on asterisk database (mysql):
    UPDATE asterisk.users SET recording='out=Adhoc|in=Adhoc' WHERE extension IN (8001, 8002, 8003, 8004, 8005)
    UPDATE asterisk.users SET recording='out=Always|in=Always' WHERE extension >= 9001 AND extension <= 9145

    The above queries updates the recording setting for extensions in database. The effect for extension 8001 may be seen at http://Your-Asterisk-Freepbx-Server-Domain-Name/admin/config.php?type=setup&display=extensions&extdisplay=8001

  2. Open each extension page and press the submit button. Finally click “Apply Configuration Changes” so that the changes may be propagated in running asterisk server