VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
madduck at madduck.net Guest
|
Posted: Sat May 16, 2015 2:32 pm Post subject: [asterisk-users] Asterisk "virtual hosting" |
|
|
Hello,
I am in the peculiar situation to have to set up a PBX for two
independent sites, but operated by the same entity. Yes, I could set
up two VPSs and install Asterisk to each, put common stuff (e.g.
conferencing setup) into Git and share between both using includes,
but for various reasons (among them simplicity and cost), I'd prefer
a single Asterisk instance.
I know I can #include files from sip.conf and extensions.conf, so
making a extensions.conf that consists of
#include ext-common.conf
#include foo/extensions.conf
#include bar/extensions.conf
is trivial. Unfortunately, the contexts in each of these files must
not clash, and so I will be forced to use e.g. [bar-incoming] in
bar/extensions.conf.
That's a bit of redundancy here (which I am always trying to avoid
like the plague) and I am wondering if there are better ways. Do you
know of any, short of writing a script to "compile" the files and
change the contexts based on path (which will be dirty and hard to
get right)?
Thanks,
--
@martinkrafft | http://madduck.net/ | http://two.sentenc.es/
"oh what a tangled web we weave,
when first we practice to deceive.
but my how we improve the score,
as we practice more and more."
-- sir walter scott
spamtraps: madduck.bogus@madduck.net
--
_____________________________________________________________________
-- 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 |
|
Back to top |
|
|
asterisk.org at sedwar... Guest
|
Posted: Sat May 16, 2015 4:22 pm Post subject: [asterisk-users] Asterisk "virtual hosting" |
|
|
On Sat, 16 May 2015, martin f krafft wrote:
Quote: | I am in the peculiar situation to have to set up a PBX for two
independent sites, but operated by the same entity. Yes, I could set
up two VPSs and install Asterisk to each, put common stuff (e.g.
conferencing setup) into Git and share between both using includes,
but for various reasons (among them simplicity and cost), I'd prefer
a single Asterisk instance.
I know I can #include files from sip.conf and extensions.conf, so
making a extensions.conf that consists of
#include ext-common.conf
#include foo/extensions.conf
#include bar/extensions.conf
is trivial. Unfortunately, the contexts in each of these files must
not clash, and so I will be forced to use e.g. [bar-incoming] in
bar/extensions.conf.
That's a bit of redundancy here (which I am always trying to avoid
like the plague) and I am wondering if there are better ways. Do you
know of any, short of writing a script to "compile" the files and
change the contexts based on path (which will be dirty and hard to
get right)?
|
I use a preprocessor
(http://software.hixie.ch/utilities/unix/preprocessor/) to tailor
dialplans and configuration files to each host based on the client
(or project) and the hostname.
This lets me do stuff like:
[globals]
DATABASE-DATABASE = @DATABASE_DATABASE@
DATABASE-PASSWORD = @DATABASE_PASSWORD@
DATABASE-PRODUCTION-SERVER = @DATABASE_PRODUCTION_SERVER@
DATABASE-REPORTING-SERVER = @DATABASE_REPORTING_SERVER@
DATABASE-ROOT-PASSWORD = @DATABASE_ROOT_PASSWORD@
DATABASE-USERNAME = @DATABASE_USERNAME@
and
#ifdef A11
exten = s,n, execif($[${ACCEPT-COUNTER} < 0]?hangup)
#else
exten = s,n, execif($[${ACCEPT-COUNTER} < 0],hangup)
#endif
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards@sedwards.com 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 |
|
Back to top |
|
|
madduck at madduck.net Guest
|
Posted: Sun May 17, 2015 12:36 am Post subject: [asterisk-users] Asterisk "virtual hosting" |
|
|
also sprach Steve Edwards <asterisk.org@sedwards.com> [2015-05-16 23:22 +0200]:
Quote: | I use a preprocessor
(http://software.hixie.ch/utilities/unix/preprocessor/) to tailor
dialplans and configuration files to each host based on the client
(or project) and the hostname.
|
Yeah sure, templating works, but it introduces a layer of complexity
that can make debugging hard(er).
I just had the following alternative ideas.
- when #include parses a file, prefix all stanzas found therein
with text derived from the path, e.g.
* #include foo/extensions.conf → "foo-"
* #include bar.conf → "bar-"
* #include foo/bar/moo.conf → "foo-bar-moo-"
- if e.g. a context includes another context using a path
separator, then the [common] context is looked up in a different
location:
* include foo/common → "foo/extensions.conf"
* include foo/bar/common → "foo/bar/extensions.conf:foo/bar.conf"
The same logic could be applied e.g. in the arguments of the
Dial() application or local channels or registry instructions in
sip.conf.
The first is probably easier to implement, while the second is
clearer to the user.
Is this something to consider?
--
@martinkrafft | http://madduck.net/ | http://two.sentenc.es/
"when faced with a new problem, the wise algorithmist
will first attempt to classify it as np-complete.
this will avoid many tears and tantrums as
algorithm after algorithm fails."
-- g. niruta
spamtraps: madduck.bogus@madduck.net
--
_____________________________________________________________________
-- 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 |
|
Back to top |
|
|
asterisk.org at sedwar... Guest
|
Posted: Sun May 17, 2015 1:32 am Post subject: [asterisk-users] Asterisk "virtual hosting" |
|
|
On Sun, 17 May 2015, martin f krafft wrote:
Quote: | also sprach Steve Edwards <asterisk.org@sedwards.com> [2015-05-16 23:22
+0200]:
|
Quote: | Quote: | I use a preprocessor
(http://software.hixie.ch/utilities/unix/preprocessor/) to tailor
dialplans and configuration files to each host based on the client (or
project) and the hostname.
|
|
On Sun, 17 May 2015, martin f krafft wrote:
Quote: | Yeah sure, templating works, but it introduces a layer of complexity
that can make debugging hard(er).
|
While preprocessing could be called 'templating,' this may be confusing
because Asterisk already as a configuration file feature called
'templates.'
Quote: | I just had the following alternative ideas.
- when #include parses a file, prefix all stanzas found therein
with text derived from the path, e.g.
* #include foo/extensions.conf → "foo-"
* #include bar.conf → "bar-"
* #include foo/bar/moo.conf → "foo-bar-moo-"
- if e.g. a context includes another context using a path
separator, then the [common] context is looked up in a different
location:
* include foo/common → "foo/extensions.conf"
* include foo/bar/common → "foo/bar/extensions.conf:foo/bar.conf"
The same logic could be applied e.g. in the arguments of the
Dial() application or local channels or registry instructions in
sip.conf.
The first is probably easier to implement, while the second is clearer
to the user.
|
And you find preprocessing/templating complex?
Quote: | Is this something to consider?
|
I don't think so, primarily because it is specific to your problem. The
audience is too small.
Let's take a closer look at preprocessing using the preprocessor I
referenced above to make sure I understand your needs.
If we had extensions.conf.pre containing:
#filter substitution
#define PREFIX a
#include generic.conf.pre
#define PREFIX b
#include generic.conf.pre
# (end of extensions.conf.pre)
(Note that '#include' is seen by the preprocessor, not by Asterisk's
configuration file parsing code.)
and generic.conf.pre containing:
[@PREFIX@-long-distance]
exten = s,1, verbose(1,[${EXTEN}@${CONTEXT}!${ANI}])
#if PREFIX==a
same = n, verbose(a specific code)
#endif
same = n, hangup()
# (end of common.conf.pre)
we could process these files with a command like:
./preprocessor.pl extensions.conf.pre >/etc/asterisk/extensions.conf
which would create extensions.conf containing:
[a-long-distance]
exten = s,1, verbose(1,[${EXTEN}@${CONTEXT}!${ANI}])
same = n, verbose(a specific code)
same = n, hangup()
[b-long-distance]
exten = s,1, verbose(1,[${EXTEN}@${CONTEXT}!${ANI}])
same = n, hangup()
This lets you write generic contexts that will be prefixed as well as
'tailor' code specific to the value of the prefix. Isn't this what you're
looking to accomplish?
Also note, the 'real' extensions.conf contains no additional complexity so
it is as easy to understand and maintain as you want it to be.
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards@sedwards.com 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 |
|
Back to top |
|
|
madduck at madduck.net Guest
|
Posted: Sun May 17, 2015 1:43 am Post subject: [asterisk-users] Asterisk "virtual hosting" |
|
|
also sprach Steve Edwards <asterisk.org@sedwards.com> [2015-05-17 08:31 +0200]:
Quote: | While preprocessing could be called 'templating,' this may be
confusing because Asterisk already as a configuration file feature
called 'templates.'
|
Fair point. Preprocessing it shall be.
Quote: | And you find preprocessing/templating complex?
|
Hehe. The difference is that e.g. when encountering a problem, in
your situation one always has to look at the preprocessor output,
identify the issue, and then translate it into a fix in the input.
Whereas with hierarchical includes, the files you edit are the same
files Asterisk reads and hence this can be taken into account e.g.
in log messages etc.
Quote: | Quote: | Is this something to consider?
|
I don't think so, primarily because it is specific to your
problem. The audience is too small.
|
You know the Henry Ford quote about faster horses, right?
Quote: | Let's take a closer look at preprocessing using the preprocessor I
referenced above to make sure I understand your needs.
| […]
Quote: | This lets you write generic contexts that will be prefixed as well
as 'tailor' code specific to the value of the prefix. Isn't this
what you're looking to accomplish?
|
Yeah, and it's nicely done. Arguably it's still a hack and debugging
becomes an indirect process (see above). But sure, it'll probably be
the best solution for now.
… although I believe Asterisk would benefit from better namespace
separation between sets of registrations/contexts.
--
@martinkrafft | http://madduck.net/ | http://two.sentenc.es/
"you raise the blade, you make the change
you rearrange me till i'm sane.
you lock the door, and throw away the key,
there's someone in my head but it's not me."
-- pink floyd, 1972
spamtraps: madduck.bogus@madduck.net
--
_____________________________________________________________________
-- 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 |
|
Back to top |
|
|
asterisk.org at sedwar... Guest
|
Posted: Sun May 17, 2015 2:35 am Post subject: [asterisk-users] Asterisk "virtual hosting" |
|
|
On Sun, 17 May 2015, martin f krafft wrote:
Quote: | You know the Henry Ford quote about faster horses, right?
|
I do now
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards@sedwards.com 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 |
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|