On Tue, 2 Oct 2012, Mitch Claborn wrote:
I'd like to be able to use the same config files in CVS and have the
differences resolved at run time, based on host name of the asterisk
server.
Another idea would be to write a simple perl or other program to
pre-process the files and put some markers in the files themselves.
I don't use CVS, old bad habits die hard :)
I use a preprocessor. Specifically:
http://git.dyne.org/freej/plain/lib/javascript/config/preprocessor.pl
(Not where I got it from, but it's the same file.)
because it had enough features and because my production hosts already
have Perl so I didn't have to add yet another scripting language.
This preprocessor allows you to do '#if HOSTNAME==v0' where HOSTNAME is a
shell environment variable or it can be defined on the command line.
You can also define variables in an 'include' file
It will do a whole lot more, but 'if' and substitution were the only
features I needed at the time. If I could have deciphered 'm4' I might
have used that, but the sendmail.mc files look too damn ugly to maintain.
I hacked in CURDATE and CURTIME as 'pre-defined variables'.
Here's a sample of one of my files:
#
# Filename: /source/src/${PROJECT}/manager.conf.pre
#
# Version: 001
#
# Edit date: 2008-12-02
#
# Facility: Asterisk
#
# Abstract: Define connections to the manager interface.
#
# Environment: Asterisk
#
# Author: Steven L. Edwards
#
# Modified by
#
# 000 2008-10-17 SLE Started documenting.
# 001 2008-12-02 SLE Preprocessorize.
#expand ; Created by makefile on __CURDATE__ at __CURTIME__
#expand ; from __FILE__
[general]
enabled = yes
port = 5038
#if HOSTNAME==v0
bindaddr = 127.0.0.1
#else
bindaddr = 0.0.0.0
#endif
[@AMI_USERNAME@]
deny = 0.0.0.0/0.0.0.0
#if HOSTNAME==v0
permit = 127.0.0.1/255.255.255.255
#else
permit = 192.168.0.0/255.255.255.0
#endif
read = all
secret = @AMI_SECRET@
write = all
; (end of /etc/asterisk/manager.conf)
# (end of /source/src/${PROJECT}/manager.conf.pre)
This gets munged by my makefile so deployment consists of 'make rsync;
make config'
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards [email protected] Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users