FreePBX and Asterisk 1.6 amportal script issue
If you run FreePBX and Asterisk 1.6 and tried to execute “amportal stop” the script might throw an exception and treat that Asterisk is not running and attempts to restart or some weird stuff keep happening.
The issue is caused by the freepbx_engine script which amportal calls that has a depreciated command for stopping Asterisk called “stop gracefully” when it’s actually “core stop gracefully”. The script has two lines one of each, the second one, which is “stop gracefully”.
So, we found a quick workaround. Seem to make the execution of the amportal script to behave correctly. But before that, just so you check that;
1) This is an Asterisk 1.6 with FreePBX 2.5.x or higher systems which are on Debian Lenny (4) – It may happen on different OS/distros.
2) FreePBX permissions/configurations are all set properly in amportal.conf
3) Asterisk run directory /var/run/asterisk/ exist and that the ctl and pid are properly configured to use this directory (in amportal.conf and/or in freepbx_engine) and that the permission to read and write that directory is give to the user which runs asterisk (normally the asterisk user).
This is what i use to get when i “amportal stop” or “amportal restart”. We get a “Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)” command thrown at us and sometimes, it becomes worse and may cause Asterisk to crash.
This above sometimes goes on a crazy loop until i kill –9 the asterisk process properly.
This is how you fix this.
nano /var/lib/asterisk/bin/freepbx_engine
Locate (ctrl-w) the command “stop gracefully”. Comment out that whole line from the beginning and it should look something like this;
Notice the # before /usr/sbin/asterisk –rx “stop gracefully” well, that basically disables that line. Safe and do amportal “whatever” and see it will no longer throw and exception.
Now we are all happy campers.
No more crashes or weird error messages.