Hi,
since we use git also for our kamailio stuff, we need to check in also host specific stuff. (same kamailio.cfg but different addresses and ... ) For this I thought an include_file for different hosts would be nice, but I can not check in the different host specific files, because I can not use something like:
|include_file "$HN(n).cfg"
It is not allowed in kamailio 5.6.x Or better: the pseudo variable is not replaced.
Is there a way to work arround, or is it possible to make it possible?
Best regards
Bernd |
Hello,
On 13.11.23 12:14, Bernd Krueger-Knauber via sr-users wrote:
Hi,
since we use git also for our kamailio stuff, we need to check in also host specific stuff. (same kamailio.cfg but different addresses and ... ) For this I thought an include_file for different hosts would be nice, but I can not check in the different host specific files, because I can not use something like:
|include_file "$HN(n).cfg"
It is not allowed in kamailio 5.6.x Or better: the pseudo variable is not replaced.
Is there a way to work arround, or is it possible to make it possible? |
the variables are mostly runtime elements (evaluated at every execution) for kamailio.cfg, while include is a pre-processor directive which is evaluated at reading the file, even before the file content is understood by the interpreter (think of include_file directive as a copy and paste to build a larger cfg file that is then passed to the interpreter for parsing and understanding).
A way that might work, although I haven't tested it at all, is to leverage environment variables that can be accessed via #!defenv, like:
- in shell
export HOSTFILECFG=abc.cfg
- in config file
#!defenv HOSTFILECFG
include_file HOSTFILECFG
Cheers, Daniel
||
Hello,
not sure if the environment replacement there works in later versions, have not tested it.
You could just use another template system like ansible etc.. to deploy the name dynamically.
Cheers,
Henning
-- Henning Westerholt – https://skalatan.de/blog/ Kamailio services – https://gilawa.comhttps://gilawa.com/
From: Bernd Krueger-Knauber via sr-users sr-users@lists.kamailio.org Sent: Montag, 13. November 2023 12:15 To: sr-users@lists.kamailio.org Cc: Bernd Krueger-Knauber bkk@ednt.de Subject: [SR-Users] pseudo variable in include_file not possible
Hi,
since we use git also for our kamailio stuff, we need to check in also host specific stuff. (same kamailio.cfg but different addresses and ... ) For this I thought an include_file for different hosts would be nice, but I can not check in the different host specific files, because I can not use something like:
include_file "$HN(n).cfg"
It is not allowed in kamailio 5.6.x Or better: the pseudo variable is not replaced.
Is there a way to work arround, or is it possible to make it possible?
Best regards
Bernd