[Asterisk-Dev] Astcl - tcl flavored extensions configuration
module for Asterisk
Reed Wade
reed at cadre5.com
Wed Apr 14 06:31:07 MST 2004
Brett Schwarz wrote:
> Hey Reed,
>
> Sounds cool.
>
> I just did a quick (sp?) look at the code, and I was
> wondering why you were using the old Tcl C API? The
> object based interface is more efficient in most
> instances.
I'm a dinosaur. I'll take a look at the object based stuff, it didn't
exist when last I did anything interesting with tcl.
> Also, how do you handle threads. Is the config stuff
> only done within a dedicated thread?
I'm not dealing with threads at all right now but was thinking I would
in future. Since it just runs once at startup it didn't seem useful yet.
thanks for the comments,
-reed
>
> thanks for the code,
>
> --brett
>
> --- Reed Wade <reed at cadre5.com> wrote:
>
>>
>>I speculated a while back on the list about using
>>tcl to configure
>>Asterisk but never had time to pursue this until
>>recently. I've put
>>together a first cut at this that actually works
>>pretty well from what I
>>can tell.
>>
>>See-
>>
>>http://file.cadre5.com/asterisk/
>>
>>Here's the README-
>>
>>------------------------
>>
>>Astcl 0.1
>>13 April 2004
>>
>>------------------------
>>Reed Wade
>>reed at cadre5.com
>>------------------------
>>
>>
>>This version of Astcl is very early. It seems to
>>work without problems
>>but I haven't tested it in a large installation nor
>>over a long period
>>of time.
>>
>>This is a first try and it seems likely to change
>>some.
>>
>>I'm using it today in a small office (8 people) with
>>an empty
>>extensions.conf file.
>>
>>
>>--
>>
>>Astcl
>>
>>Astcl works alongside or as a replacement for the
>>standard extensions
>>configuration (extensions.conf) mechanism. Contexts
>>and extensions can
>>be created then referenced in either.
>>
>>Astcl lives with the rest of the Asterisk modules:
>> /usr/lib/asterisk/modules/pbx_astcl.so
>>
>>Two other files are needed:
>> /etc/asterisk/astcllib.tcl
>> /etc/asterisk/astcl.conf
>>
>>astcllib.tcl contains a library of useful tcl
>>functions and should
>>not need to change for your installation. At the
>>moment it contains
>>the definitions for the ext and user functions.
>>
>>astcl.conf contains the specific configuration for
>>your installation
>>
>>If you're not familiar with TCL, see
>>http://www.tcl.tk/doc/
>>TCL is a lightweight scriptable control interface
>>for systems of
>>all sorts. At first glance, it seems like a perfect
>>match for
>>Asterisk.
>>
>>
>>INSTALLATION
>>
>>At this time, the installation may be a little
>>twitchy. I'd like
>>to hear from folks on that. I've only ever built and
>>run this on
>>one machine (running fedora). It had the 8.3 tcl
>>library installed
>>already. I did have to download the tcl8.3 sources
>>in order to have a
>>set of header files to compile against.
>>
>>Edit the Makefile, you'll probably need to change
>>TCLINCLUDES and
>>ASTINCLUDES to reflect your locations for tcl and
>>asterisk sources.
>>
>>TCLINCLUDES = -I/root/reed/tcl8.3.4/generic
>>ASTINCLUDES = -I/root/asterisk/asterisk/include
>>-I/root/asterisk/asterisk
>>
>>You shouldn't need to change anything else.
>>
>>Type 'make clean all' to build pbx_astcl.so
>>
>>If that works, type 'make install' to copy it to the
>>asterisk modules
>>directory.
>>
>>('make test' doesn't work right now.)
>>
>>Copy astcllib.tcl and astcl.conf to /etc/asterisk/
>>
>>Edit astcl.conf (see below) to fit your
>>installation.
>>
>>Start up Asterisk....
>>
>>
>>CONFIGURATION
>>
>>At startup, astcl does this:
>> - creates an interpreter instance
>> - sets a global tcl variable AST_CONFIG_DIR to the
>>value of
>> the Asterisk config directory (normally
>>/etc/asterisk)
>> - creates a command named "context"
>> - evaluates $AST_CONFIG_DIR/astcllib.tcl
>> - evaluates $AST_CONFIG_DIR/astcl.conf
>>
>>astcl.conf evaluates as a normal tcl script but has
>>access to the
>>AST_CONFIG_DIR variable and three new commands:
>>context, user and ext
>>
>>The context command takes one argument, the name of
>>a new context to
>>be created. It creates the context, then it creates
>>a new tcl command
>>with the same name as the context. If you're
>>familiar with TK, this is
>>similar to the widget creation scheme.
>>
>>This new command is used in four different ways: to
>>create extensions,
>>to includes other contexts, add a switch and to set
>>the ignorepat.
>>Normally, you will not create extensions directly,
>>the "ext" convenience
>>function provides a sweeter interface.
>>
>>
>>Example (see samples/astcl.conf for a better one):
>>
>>set TRUNK Zap/g2
>>
>>context demo
>>
>>demo includes othercontext
>>demo ignorepat 9
>>demo switch IAX2/blah
>>
>>
>>ext demo _91NXXNXXXXXX {
>> SetCallerID 8656904442|a
>> Dial $TRUNK/${EXTEN:1}
>> Congestion ""
>>}
>>
>>
>>user TYS \
>> "Reed Wade" reed at cadre5.com \
>> 310 Zap/3&IAX2/reedwade
>>user TYS \
>> "Chris Luttrell" cgluttrell at cadre5.com \
>> 303 Zap/2
>>
>>
>>context staffExtensions
>>
>>ext staffExtensions TYS {
>> Dial $line|20|r
>> ifbusy {
>> Voicemail b$extension
>> Goto default|s|1
>> }
>> Voicemail u$extension
>> Goto default|s|1
>>}
>>
>>
>>
>>
>>
>>The ext command takes two forms--
>>
>> ext contextName extensionList plan
>> OR
>> ext contextName gangList plan
>>
>>Gangs are sets of users created using the "user"
>>command.
>>
>> user gang name email ext line
>>
>
> === message truncated ===
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> http://taxes.yahoo.com/filing.html
More information about the asterisk-dev
mailing list