Configuring Freepbx to use externnotify

Hi all, my first post though I’ve tried to read though these forums for a similar issue. I must be missing something obvious…

I have a simple bash script that I have been using with asterisk for the externnotify option on voicemail. I’m moving over to FreePBX, however when I enter even a test bash script into the externnotify field in FreePBX, the script never appears to execute when a new voicemail is left.

I’ve seen that FreePBX debug can log something like DEBUG[xxxxx] app_voicemail.c: Executing /dir/to/script.sh. When I review my logs, before during and after leaving voicemail, I never see this line hit the log, so it appears app_voicemail.c isn’t trying to use the externnotify path. I also checked /etc/asterisk/voicemail.conf, and the path to the script is showing up in that directory after I apply the setting from the FreePBX GUI.

I’m working with a vanilla install in a lab with only a few test phones, is there a configuration option in either the extension or the voicemail admin that I am missing in order to use the externnotify feature?

Thanks in advance for any help!

For reference:

Asterisk 11
FreePBX: 2.11.0.43

directory is /root/test.sh
[test.sh]
#!/bin/bash
echo “Test” >> testfile.txt

the script identified by externnotify needs to be readable and executable by the asterisk user or it won’t run, it is probably best as /var/lib/asterisk/bin/test.sh and any issue needs to go to a file fully defined by a path that is writable by the asterisk user.

Thanks for the advice, unfortunately I’m still not having any luck. I tried moving the script to var/lib/asterisk/bin but still nothing logged in the CLI when leaving a voicemail, and the script doesn’t execute.

ls -l test.sh yields:
-rwxr-xr-x 1 root root May 11 14:06 test.sh

Asterisk is running as root (I’ll probably change this later, but leaving it while debugging).

Also from the asterisk CLI, if I run ./test.sh, the script executes normally, so I don’t think it is a permissions issue.

You will see the script called and any errors if you have debug level set above 1 ( I think)

grep for app_voicemail in your logs after increasing that level.

That’s the part that has me scratching my head… from the shell:

[root@localhost asterisk]# pwd
/var/log/asterisk
[root@localhost asterisk]# grep app_voicemail.c full
[2015-05-11 12:40:04] VERBOSE[14700][C-00000005] app_voicemail.c: – Recording the message
[2015-05-11 14:09:03] VERBOSE[21266][C-00000006] app_voicemail.c: – Recording the message
[2015-05-11 16:30:01] VERBOSE[5965][C-00000001] app_voicemail.c: – Recording the message
[2015-05-11 16:32:38] VERBOSE[6297][C-00000002] app_voicemail.c: – Recording the message
[2015-05-11 16:35:40] VERBOSE[6853][C-00000000] app_voicemail.c: – Recording the message
[2015-05-11 16:47:17] VERBOSE[8194][C-00000001] app_voicemail.c: – Recording the message
[2015-05-11 16:49:19] VERBOSE[8968][C-00000002] app_voicemail.c: – Recording the message
[2015-05-11 16:49:31] VERBOSE[8968][C-00000002] app_voicemail.c: – Saving message as is
[2015-05-11 16:50:36] VERBOSE[9146][C-00000003] app_voicemail.c: – Recording the message
[2015-05-11 16:52:25] WARNING[9566][C-00000004] app_voicemail.c: No more messages possible
[2015-05-11 16:57:20] VERBOSE[10066][C-00000005] app_voicemail.c: – Recording the message


The part about no more messages possible… I set the max messages to 1 just to see if the settings were taking hold for my test calls, and the maxmsg=1 definitely seems to work. I was hoping to see app_voicemail.c complain about not having permission to execute the script or something, but instead it just appears to not try at all. I’ve tried entering different directories with good/bad syntax into the externnotify field, but nothing ever happens on the CLI or log when I leave a voicemail.

There are no DEBUG[numbers] log lines posted, you will not see anything useful until you set your debug level above 2 ( I thought I already suggested that :wink: ), if you have maxmsg (sic) set to 1 then your script would never be called if there was already a message in the box.

For a full documentation of what you need in /etc/asterisk/voicemail.conf to make it work :-

http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/Voicemail_id263499.html

apart from that I can’t offer anymore advice as it has always WFM.

1 Like

Oh, that got it!

I wasn’t cranking up the debug level on the logger, as soon as I did I saw that the test script was executing without any permission errors. My bash script was writing testfile.txt in an unexpected directory, as soon as I changed it from
echo “Test” >> testfile.txt
to
echo “Test” >> /var/lib/asterisk/bin/testfile.txt

everything seems to be working fine. I got that bash script and the /root/testfile.txt from a solution I found on google, good to know that was all the problem was.

TYVM for the help!

I think I said that also:-

. . . and any issue needs to go to a file fully defined by a path that is writable by the asterisk user. . . .

as an aside the bin directory is traditionally where you but your executable s, probably not a good idea , asterisk’d home directory was always /var/lib/asterisk/ but now in FreePBX it is /home/asterisk , I would put it there for safety’s sake.