Hello- For maintenance purposes, if possible I'd like to use the same iax.conf file in several different asterisk systems. However, on one of the systems only, I would like to include an IAX "register" command to another external system. Within iax.conf or other configuration files (other than extensions.conf), is there a way of determining what system I'm running on, and include a particular configuration item conditionally? I guess what I'm asking is there a way to conditionally "include" lines in a configuration depending on the value of some linux environment variable? thanks
-----Original Message----- From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Scott Stingel Sent: Wednesday, July 07, 2010 1:18 PM To: Asterisk Users Mailing List Subject: [asterisk-users] Conditional "includes" in iax.conf Hello- For maintenance purposes, if possible I'd like to use the same iax.conf file in several different asterisk systems. However, on one of the systems only, I would like to include an IAX "register" command to another external system. Within iax.conf or other configuration files (other than extensions.conf), is there a way of determining what system I'm running on, and include a particular configuration item conditionally? I guess what I'm asking is there a way to conditionally "include" lines in a configuration depending on the value of some linux environment variable? thanks -- Rather than trying to determine what system you are on, just make the included file be empty on all except the desired server. As for the "actual" answer to your question, it's not "fair" since you could be using files or a "real-time" database. -- _____________________________________________________________________ -- 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
On 7/7/2010 11:25 AM, Danny Nicholas wrote:> > -- > Rather than trying to determine what system you are on, just make the > included file be empty on all except the desired server. > > >OK, thanks. I thought I might have to do it that way, which is slightly less desirable, as it makes the systems "different" from each other. cheers Scott
You may be looking for a configuration management system. http://trac.mcs.anl.gov/projects/bcfg2 or http://www.puppetlabs.com/ ~ Andrew "lathama" Latham lathama at gmail.com * Learn more about OSS http://en.wikipedia.org/wiki/Open-source_software * Learn more about Linux http://en.wikipedia.org/wiki/Linux * Learn more about Tux http://en.wikipedia.org/wiki/Tux On Wed, Jul 7, 2010 at 2:18 PM, Scott Stingel <scott at evtmedia.com> wrote:> Hello- > > For maintenance purposes, if possible I'd like to use the same iax.conf > file in several different asterisk systems. ? However, on one of the > systems only, I would like to include an IAX "register" command to > another external system. > > Within iax.conf or other configuration files (other than > extensions.conf), is there a way of determining what system I'm running > on, and include a particular configuration item conditionally? ? I guess > what I'm asking is there a way to conditionally "include" lines in a > configuration depending on the value of some linux environment variable? > > thanks > > > > -- > _____________________________________________________________________ > -- 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 >
On Wed, 7 Jul 2010, Scott Stingel wrote:> For maintenance purposes, if possible I'd like to use the same iax.conf > file in several different asterisk systems. However, on one of the > systems only, I would like to include an IAX "register" command to > another external system. > > Within iax.conf or other configuration files (other than > extensions.conf), is there a way of determining what system I'm running > on, and include a particular configuration item conditionally? I guess > what I'm asking is there a way to conditionally "include" lines in a > configuration depending on the value of some linux environment variable?I ran into this a couple of years ago. I looked at several "preprocessors" like gcc, sed, m4 and others I've since forgotten. I settled on: http://mxr.mozilla.org/mozilla-central/source/config/preprocessor.pl It's been "deprecated" in favor of a Python script, but it still works fine. It allows you to do "includes" and token substitutions. I cobble it all up in my makefile so I just type "make config" to make all of the configuration files needed on each host. A "source" config file looks like this iax.conf.pre snippet: #if HOSTNAME!=example ; calls from example [general](+) register = @HOSTNAME@:@PASSWORD@@example.vtpv.privatebilling.com #endif [example] context = start host = dynamic qualify = yes secret = example trunk = yes type = friend username = example ; (end of /etc/asterisk/@PROJECT@/iax.conf) And then the makefile entry looks like: config: # /etc/asterisk/ for FILE in\ asterisk.conf\ extensions.ael\ extensions.conf\ iax.conf\ iaxprov.conf\ logger.conf\ manager.conf\ meetme.conf\ modules.conf\ musiconhold.conf\ rtp.conf\ sip.conf\ ;\ do\ preprocessor.pl -E -I preprocessor.pre $$FILE.pre\ >/etc/asterisk/${PROJECT}/$$FILE;\ chmod u=rw,g=r,o=r /etc/asterisk/${PROJECT}/$$FILE;\ done sudo /etc/init.d/asterisk reload This has been a big time saver for me. I only have to maintain a single set of configuration files and any changes can be automagically rolled out and applied to all of the hosts using "make rsync; make remote-config." In addition to the files in /etc/asteris/, I use this method to maintain: /etc/hosts /etc/init.d/asterisk /etc/sysconfig/iptables /scripts/* (project specific scripts) /usr/local/etc/openser/dispatcher.list /var/spool/cron/* ~/.my.cnf across multiple projects and many hosts. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000