On Fri, 19 Jul 2019, Jerry Geis wrote:

I was not aware of the (+) format... basically "add" to the general section.

How far back does that go? T o 1.4.X ?

I don't know, but I checked a sip.conf from 1.2 (2012ish?) and I was using it then.

Is there a documentation piece on that ?

I'm sure there is, I just don't know where :)

Another cool configuration file feature is templates (an exclamation mark instead of a plus sign). It lets you define common 'snippets' once and include them in each context as needed.

Here's an example from that same (1.2 based) project:

; templates
[digit-timeout](!)
        exten = t,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        exten = t,n,                    goto(${CONTEXT},s,1)
[h](!)
        exten = h,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        exten = h,n,                    goto(settle-card,s,1)
[i](!)
        exten = i,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        exten = i,n,                    goto(${CONTEXT},s,1)
[s](!)
        exten = s,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
[max-timeout](!)
        exten = T,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        exten = T,n,                    goto(max-time,s,1)
[x](!)
        exten = _x.,1,                  verbose(1,[${EXTEN}@${CONTEXT}])

; authorized the card
[auth-card](h,i,s,max-timeout,digit-timeout)
        exten = s,2,                    agi(write-cdr)
        exten = s,n,                    set(PRODUCT=${CONTEXT})
        exten = s,n,                    set(PER-MINUTE=0)
        exten = s,n,                    set(PREAMBLE=${CUSTOMER}/menu/m1101)
        exten = s,n,                    
agi(auth-card,${AUTH-FLAGS},${DEBUG-MODE},${VERBOSE-MODE})
        exten = s,n,                    goto(theme,s,1)

The templates are inserted into the auth-card context when the file is parsed. I don't have a 1.2 host running anymore, but a 'show dialplan auth-card' (1.2) would look something like:

[auth-card](h,i,s,max-timeout,digit-timeout)
        exten = T,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        exten = T,n,                    goto(max-time,s,1)

        exten = h,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        exten = h,n,                    goto(settle-card,s,1)

        exten = i,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        exten = i,n,                    goto(${CONTEXT},s,1)

        exten = s,1,                    verbose(1,[${EXTEN}@${CONTEXT}])

        exten = s,2,                    agi(write-cdr)
        exten = s,n,                    set(PRODUCT=${CONTEXT})
        exten = s,n,                    set(PER-MINUTE=0)
        exten = s,n,                    set(PREAMBLE=${CUSTOMER}/menu/m1101)
        exten = s,n,                    
agi(auth-card,${AUTH-FLAGS},${DEBUG-MODE},${VERBOSE-MODE})
        exten = s,n,                    goto(theme,s,1)

        exten = t,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        exten = t,n,                    goto(${CONTEXT},s,1)

Templates are also useful in other configuration files like sip.conf to define 'classes' of parameters like 'dial-in-agent' or 'supervisor' that can be included in endpoint definitions to reduce clutter, increase consistency, and reduce maintenance.

--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       [email protected]      Voice: +1-760-468-3867 PST
            https://www.linkedin.com/in/steve-edwards-4244281

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
     https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to