configuration.tex

来自「asterisk 是一个很有知名度开源软件」· TEX 代码 · 共 226 行

TEX
226
字号
\subsubsection{Introduction}The Asterisk configuration parser in the 1.2 versionand beyond series has been improved in a number of ways. Inaddition to the realtime architecture, we now have the ability to createtemplates in configuration files, and use these as templates when weconfigure phones, voicemail accounts and queues.These changes are general to the configuration parser, and works inall 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 syntaxis 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 objectcreation. Note that settings are inherited from the top, so in the exampleabove object2 has inherited the setting for "label1" from the first object.For template configurations, the syntax for defining a section is changedto:\begin{astlisting}\begin{verbatim}	[section](options)	label = value\end{verbatim}\end{astlisting}The options field is used to define templates, refer to templates and hidetemplates. 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 commentsand is not parsed.The "\verb!;--!" is a marker for a multi-line comment. Everything afterthat 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 anotherfile with the \#include statement. The content of the other file will beincluded 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 optionssection:\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 thesame name) is an addition to the first section. The second section canbe in another file (by using the \#include statement). If the sectionname referred to before the plus is missing, the configuration will failto 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 onlya template and should not itself be used by the Asterisk module forconfiguration. The section can be inherited by other sections (seesection "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, eithertemplates or standard sections. The referred sections are includedbefore the configuration engine parses the local settings within thesection as though their entire contents (and anything they werepreviously based upon) were included in the new section.  For exampleconsider the following:\begin{astlisting}\begin{verbatim}[foo]permit=192.168.0.2host=asdfdeny=192.168.0.1[bar]permit=192.168.1.2host=jkldeny=192.168.1.1[baz](foo,bar)permit=192.168.3.1host=bnm\end{verbatim}\end{astlisting}The [baz] section will be processed as though it had been written in thefollowing way:\begin{astlisting}\begin{verbatim}[baz]permit=192.168.0.2host=asdfdeny=192.168.0.1permit=192.168.1.2host=jkldeny=192.168.1.1permit=192.168.3.1host=bnm\end{verbatim}\end{astlisting}\subsubsection{Additional Examples}(in top-level sip.conf)\begin{astlisting}\begin{verbatim}[defaults](!)type=friendnat=yesqualify=ondtmfmode=rfc2833disallow=allallow=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_secretcontext=from-customer1callerid=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 settingsinherited from "def-customer1".  The "def-customer1" is a template thatinherits from "defaults", which also is a template.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?