1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
\subsubsection{Introduction}
The Asterisk configuration parser in the 1.2 version
and beyond series has been improved in a number of ways. In
addition to the realtime architecture, we now have the ability to create
templates in configuration files, and use these as templates when we
configure phones, voicemail accounts and queues.
These changes are general to the configuration parser, and works in
all configuration files.
\subsubsection{General syntax}
Asterisk configuration files are defined as follows:
\begin{astlisting}
\begin{verbatim}
[section]
label = value
label2 = value
\end{verbatim}
\end{astlisting}
In some files, (e.g. mgcp.conf, dahdi.conf and agents.conf), the syntax
is a bit different. In these files the syntax is as follows:
\begin{astlisting}
\begin{verbatim}
[section]
label1 = value1
label2 = value2
object => name
label3 = value3
label2 = value4
object2 => name2
\end{verbatim}
\end{astlisting}
In this syntax, we create objects with the settings defined above the object
creation. Note that settings are inherited from the top, so in the example
above object2 has inherited the setting for "label1" from the first object.
For template configurations, the syntax for defining a section is changed
to:
\begin{astlisting}
\begin{verbatim}
[section](options)
label = value
\end{verbatim}
\end{astlisting}
The options field is used to define templates, refer to templates and hide
templates. Any object can be used as a template.
No whitespace is allowed between the closing "]" and the parenthesis "(".
\subsubsection{Comments}
All lines that starts with semi-colon ";" is treated as comments
and is not parsed.
The "\verb!;--!" is a marker for a multi-line comment. Everything after
that marker will be treated as a comment until the end-marker "\verb!--;!"
is found. Parsing begins directly after the end-marker.
\begin{astlisting}
\begin{verbatim}
;This is a comment
label = value
;-- This is
a comment --;
;-- Comment --; exten=> 1000,1,dial(SIP/lisa)
\end{verbatim}
\end{astlisting}
\subsubsection{Including other files}
In all of the configuration files, you may include the content of another
file with the \#include statement. The content of the other file will be
included at the row that the \#include statement occurred.
\begin{astlisting}
\begin{verbatim}
#include myusers.conf
\end{verbatim}
\end{astlisting}
You may also include the output of a program with the \#exec directive,
if you enable it in asterisk.conf
In asterisk.conf, add the execincludes = yes statement in the options
section:
\begin{astlisting}
\begin{verbatim}
[options]
execincludes=yes
\end{verbatim}
\end{astlisting}
The exec directive is used like this:
\begin{astlisting}
\begin{verbatim}
#exec /usr/local/bin/myasteriskconfigurator.sh
\end{verbatim}
\end{astlisting}
\subsubsection{Adding to an existing section}
\begin{astlisting}
\begin{verbatim}
[section]
label = value
[section](+)
label2 = value2
\end{verbatim}
\end{astlisting}
In this case, the plus sign indicates that the second section (with the
same name) is an addition to the first section. The second section can
be in another file (by using the \#include statement). If the section
name referred to before the plus is missing, the configuration will fail
to load.
\subsubsection{Defining a template-only section}
\begin{astlisting}
\begin{verbatim}
[section](!)
label = value
\end{verbatim}
\end{astlisting}
The exclamation mark indicates to the config parser that this is a only
a template and should not itself be used by the Asterisk module for
configuration. The section can be inherited by other sections (see
section "Using templates" below) but is not used by itself.
\subsubsection{Using templates (or other configuration sections)}
\begin{astlisting}
\begin{verbatim}
[section](name[,name])
label = value
\end{verbatim}
\end{astlisting}
The name within the parenthesis refers to other sections, either
templates or standard sections. The referred sections are included
before the configuration engine parses the local settings within the
section as though their entire contents (and anything they were
previously based upon) were included in the new section. For example
consider the following:
\begin{astlisting}
\begin{verbatim}
[foo]
disallow=all
allow=ulaw
allow=alaw
[bar]
allow=gsm
allow=g729
permit=192.168.2.1
[baz](foo,bar)
type=friend
permit=192.168.3.1
context=incoming
host=bnm
\end{verbatim}
\end{astlisting}
The [baz] section will be processed as though it had been written in the
following way:
\begin{astlisting}
\begin{verbatim}
[baz]
disallow=all
allow=ulaw
allow=alaw
allow=gsm
allow=g729
permit=192.168.2.1
type=friend
permit=192.168.3.1
context=incoming
host=bnm
\end{verbatim}
\end{astlisting}
It should also be noted that there are no guaranteed overriding semantics,
meaning that if you define something in one template, you should not expect to
be able to override it by defining it again in another template.
\subsubsection{Additional Examples}
(in top-level sip.conf)
\begin{astlisting}
\begin{verbatim}
[defaults](!)
type=friend
nat=yes
qualify=on
dtmfmode=rfc2833
disallow=all
allow=alaw
#include accounts/*/sip.conf
\end{verbatim}
\end{astlisting}
(in \path{accounts/customer1/sip.conf})
\begin{astlisting}
\begin{verbatim}
[def-customer1](!,defaults)
secret=this_is_not_secret
context=from-customer1
callerid=Customer 1 <300>
accountcode=0001
[phone1](def-customer1)
mailbox=phone1@customer1
[phone2](def-customer1)
mailbox=phone2@customer1
\end{verbatim}
\end{astlisting}
This example defines two phones - phone1 and phone2 with settings
inherited from "def-customer1". The "def-customer1" is a template that
inherits from "defaults", which also is a template.
|