text
stringlengths
0
152
Move the docall file into Asterisk’s outgoing folder.
$ sudo mv docall /var/spool/asterisk/outgoing
Sometimes, the easiest way is the best way.
You’ll probably find yourself doing multiple edits on your source call file. You could
just move that file you created, rather than making a copy of it first, but then you’d
have to re-create it each time you make an edit, and this gets annoying. All that typing
can be saved as a one-liner, and run like this:
$ cp ~/call-file docall \
sudo chown asterisk:asterisk docall \
sudo mv docall /var/spool/asterisk/outgoing/
Try it and you’ll see how much easier this is than creating and moving a new call file
every time.
The use of mv instead of cp here is important. Asterisk is watching
for contents to show up in the spool directory. If you use copy,
Asterisk may try to read the new file before the contents have been
copied into it. Creating a file and then moving it avoids this
problem.
Get comfortable with using call files, and you may find them solving problems you’d
otherwise have to perform far more work to achieve.
300
|
Chapter 17: Asterisk Manager Interface and Call Files
Notes About Call Files
The Channel component of the call file is required. Normally, a call coming into
Asterisk is initiated by the endpoint (for example, you make a call from your phone).
In a call file, that connection has to happen the other way around—Asterisk reaches
out to the endpoint, and only when it answers can the call start. Plan accordingly.
You also must specify the Context where the call will begin once the initial channel
has answered. This can be useful, since it means you can connect the call through a
context that wouldn’t normally be accessible to that channel, but in practice we’d sug‐
gest you simply provide the same context that channel would have entered the
dialplan through if it had initiated the call normally.
The Extension must of course also be specified. This would typically be the phone
number that is to be called, but of course it could be any valid extension within the
Context.
The rest of the parameters of the call file are optional, and are detailed both in the
~/src/asterisk-15.<TAB>/sample.call file, and on the Asterisk wiki website.
AMI Quick Start
This section is for getting your hands dirty with the AMI as quickly as possible. First,
put the following configuration in /etc/asterisk/manager.conf:
; Turn on the AMI and ask it to only accept connections from localhost.
[general]
enabled = yes
webenabled = yes
bindaddr = 127.0.0.1
; Create an account called "hello", with a password of "world"
[hello]
secret=world
read=all ; Receive all types of events
write=all ; Allow this user to execute all actions
This sample configuration is set up to allow only local connections
to the AMI. If you intend to make this interface available over a
network, it is strongly recommended that you only do so using
TLS. The use of TLS is discussed in more detail later in this chapter.
Once the AMI configuration is ready, enable the built-in HTTP server by putting the
following contents in /etc/asterisk/http.conf:
; Enable the built-in HTTP server, and only listen for connections on localhost.
[general]
enabled = yes
bindaddr = 127.0.0.1
AMI Quick Start
|
301
Reload the manager and http servers from the Asterisk CLI:
*CLI> manager reload
*CLI> module reload http
AMI over TCP
There are multiple ways to connect to the AMI, but a TCP socket is the most com‐
mon. We will use telnet to demonstrate AMI connectivity. We’ll need to install tel
net for this:
$ sudo yum -y install telnet