README.configuration 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. Asterisk Configuration Parser (version 1.1 and later)
  2. -----------------------------------------------------
  3. The Asterisk configuration parser in the 1.1 development version (1.2
  4. stable) and beyond series has been improved in a number of ways. In
  5. addition to the realtime architecture, we now have the ability to create
  6. templates in configuration files, and use these as templates when we
  7. configure phones, voicemail accounts and queues.
  8. These changes are general to the configuration parser, and works in
  9. all configuration files.
  10. General syntax
  11. --------------
  12. Asterisk configuration files are defined as follows:
  13. [section]
  14. label = value
  15. label2 = value
  16. In some files, (e.g. mgcp.conf, zapata.conf and agents.conf), the syntax
  17. is a bit different. In these files the syntax is as follows:
  18. [section]
  19. label1 = value1
  20. label2 = value2
  21. object => name
  22. label3 = value3
  23. label2 = value4
  24. object2 => name2
  25. In this syntax, we create objects with the settings defined above the object
  26. creation. Note that settings are inherited from the top, so in the example
  27. above object2 has inherited the setting for "label1" from the first object.
  28. For template configurations, the syntax for defining a section is changed
  29. to
  30. [section](options)
  31. label = value
  32. The options field is used to define templates, refer to templates and hide
  33. templates. Any object can be used as a template.
  34. No whitespace is allowed between the closing "]" and the parenthesis "(".
  35. Comments
  36. --------
  37. All lines that starts with semi-colon ";" is treated as comments
  38. and is not parsed.
  39. The ";--" is a marker for a multi-line comment. Everything after
  40. that marker will be treated as a comment until the end-marker "--;"
  41. is found. Parsing begins directly after the end-marker.
  42. ;This is a comment
  43. label = value
  44. ;-- This is
  45. a comment --;
  46. ;-- Comment --; exten=> 1000,1,dial(SIP/lisa)
  47. Including other files
  48. ---------------------
  49. In all of the configuration files, you may include the content of another
  50. file with the #include statement. The content of the other file will be
  51. included at the row that the #include statement occured.
  52. #include myusers.conf
  53. You may also include the output of a program with the #exec directive,
  54. if you enable it in asterisk.conf
  55. In asterisk.conf, add the execincludes = yes statement in the options
  56. section:
  57. [options]
  58. execincludes=yes
  59. The exec directive is used like this:
  60. #exec /usr/local/bin/myasteriskconfigurator.sh
  61. Adding to an existing section
  62. -----------------------------
  63. [section]
  64. label = value
  65. [section](+)
  66. label2 = value2
  67. In this case, the plus sign indicates that the second section (with the
  68. same name) is an addition to the first section. The second section can
  69. be in another file (by using the #include statement). If the section
  70. name referred to before the plus is missing, the configuration will fail
  71. to load.
  72. Defining a template-only section
  73. --------------------------------
  74. [section](!)
  75. label = value
  76. The exclamation mark indicates to the config parser that this is a only
  77. a template and should not itself be used by the Asterisk module for
  78. configuration. The section can be inherited by other sections (see
  79. section "Using templates" below) but is not used by itself.
  80. Using templates (or other configuration sections)
  81. -------------------------------------------------
  82. [section](name[,name])
  83. label = value
  84. The name within the parenthesis refers to other sections, either
  85. templates or standard sections. The referred sections are included
  86. before the configuration engine parses the local settings within the
  87. section as though their entire contents (and anything they were
  88. previously based upon) were included in the new section. For example
  89. consider the following:
  90. [foo]
  91. permit=192.168.0.2
  92. host=asdf
  93. deny=192.168.0.1
  94. [bar]
  95. permit=192.168.1.2
  96. host=jkl
  97. deny=192.168.1.1
  98. [baz](foo,bar)
  99. permit=192.168.3.1
  100. host=bnm
  101. The [baz] section will be processed as though it had been written in the
  102. following way:
  103. [baz]
  104. permit=192.168.0.2
  105. host=asdf
  106. deny=192.168.0.1
  107. permit=192.168.1.2
  108. host=jkl
  109. deny=192.168.1.1
  110. permit=192.168.3.1
  111. host=bnm
  112. Additional Examples:
  113. --------------------
  114. (in top-level sip.conf)
  115. [defaults](!)
  116. type=friend
  117. nat=yes
  118. qualify=on
  119. dtmfmode=rfc2833
  120. disallow=all
  121. allow=alaw
  122. #include accounts/*/sip.conf
  123. (in accounts/customer1/sip.conf)
  124. [def-customer1](!,defaults)
  125. secret=this_is_not_secret
  126. context=from-customer1
  127. callerid=Customer 1 <300>
  128. accountcode=0001
  129. [phone1](def-customer1)
  130. mailbox=phone1@customer1
  131. [phone2](def-customer1)
  132. mailbox=phone2@customer1
  133. This example defines two phones - phone1 and phone2 with settings
  134. inherited from "def-customer1". The "def-customer1" is a template that
  135. inherits from "defaults", which also is a template.