[prev in list] [next in list] [prev in thread] [next in thread] 

List:       serusers
Subject:    Re: [SR-Users] environmental variables in kamailio
From:       Daniel-Constantin Mierla <miconda () gmail ! com>
Date:       2019-10-24 9:16:18
Message-ID: 9f89aaba-7413-ad6d-5ce2-8a66e692eb09 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello,

indeed there is a pseudo-variable that gives the environment variables.
Moreover, iirc, Luis Azedo added a while ago (it may be only from 5.3)
support to resolve variables inside substdef (and maybe define) -- so
eventually you should be able to do this with 5.3.0:

#!substdef "/PUBLICIP/$env(KAMPUBLICIP)/"

 listen=udp:$(local_ip):5060 advertise  "PUBLICIP":5060

It might not work for this specific case, because listen value is a
little bit complex definition, not just string values. But with 5.3
there is a command line parameter (-l -- lower case L) to specify listen
socket with advertise address. So just remove listen from kamailio.cfg
and the start kamailio like:

kamailio -l proto:localaddr:lcoalport/publicaddr:publicport

Like:

kamailio -l udp:10.0.0.1:5080/1.2.3.4:5060

See kamailio -h for more details.

Cheers,
Daniel

On 24.10.19 09:28, Rick Barenthin wrote:
> I've never used it but wiki says:
>
>
>     $env(NAME) - environment variables
>
> *$env(NAME)* - value of the environment variable named NAME
>
> So it should be possible.
>
> Alex Balashov <abalashov@evaristesys.com
> <mailto:abalashov@evaristesys.com>> schrieb am Do., 24. Okt. 2019, 08:16:
>
>     It is not. But you can do this via any template system such as
>     Jinja2, or a hand-rolled substitution script.
>
>     —
>     Sent from mobile, with due apologies for brevity and errors.
>
>>     On Oct 24, 2019, at 2:02 AM, Gaurav Bmotra
>>     <saigauravmehra91@gmail.com <mailto:saigauravmehra91@gmail.com>>
>>     wrote:
>>
>>     
>>     hi 
>>     i using kamailio 5.2 
>>     is it possible to use environmental variables value in kamailio.cfg 
>>     like i want to use local ip and public ip in config file 
>>
>>      listen=udp:$(local_ip):5060 advertise  $(public_ip):5060
>>     if iti is possible then how i can use this 
>>
>>
>>     thank you 
>>     -- 
>>
>>
>>
>>
>>
>>
>>
>>
>>     *Regards:*
>>     Gaurav Kumar
>>
>>     _______________________________________________
>>     Kamailio (SER) - Users Mailing List
>>     sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org>
>>     https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>     _______________________________________________
>     Kamailio (SER) - Users Mailing List
>     sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org>
>     https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training, Oct 21-23, 2019, Berlin, Germany -- https://asipto.com/u/kat


[Attachment #5 (text/html)]

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello,</p>
    <p>indeed there is a pseudo-variable that gives the environment
      variables. Moreover, iirc, Luis Azedo added a while ago (it may be
      only from 5.3) support to resolve variables inside substdef (and
      maybe define) -- so eventually you should be able to do this with
      5.3.0:</p>
    <p>#!substdef "/PUBLICIP/$env(KAMPUBLICIP)/"</p>
    <p> listen=<a class="moz-txt-link-freetext" \
href="udp:$(local_ip):5060">udp:$(local_ip):5060</a> advertise  "PUBLICIP":5060</p>  \
<p>It might not work for this specific case, because listen value is  a little bit \
complex definition, not just string values. But with  5.3 there is a command line \
parameter (-l -- lower case L) to  specify listen socket with advertise address. So \
just remove  listen from kamailio.cfg and the start kamailio like:</p>
    <p>kamailio -l proto:localaddr:lcoalport/publicaddr:publicport</p>
    <p>Like:</p>
    <p>kamailio -l <a class="moz-txt-link-freetext" \
href="udp:10.0.0.1:5080/1.2.3.4:5060">udp:10.0.0.1:5080/1.2.3.4:5060</a><br>  </p>
    <p>See kamailio -h for more details.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 24.10.19 09:28, Rick Barenthin
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAPriEK7FvDLQNZcpiA-__M58t_encWJEVEGA_GQsox_pX9y_7w@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="auto">
        <div>I've never used it but wiki says:
          <div dir="auto"><br>
          </div>
          <div dir="auto">
            <h2 style="padding:0px;line-height:1.2;margin:0px 0px
              0.666em;color:rgb(51,51,51);font-family:arial,sans-serif">$env(NAME)
              - environment variables</h2>
            <div
style="margin:0px;padding:0px;color:rgb(51,51,51);font-family:arial,sans-serif;font-size:16px"
  dir="auto">
              <p style="margin:0px 0px 1.4em;padding:0px"><strong>$env(NAME)</strong> \
-  value of the environment variable named NAME</p>
            </div>
          </div>
          So it should be possible.<br>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">Alex Balashov &lt;<a
                href="mailto:abalashov@evaristesys.com" target="_blank"
                rel="noreferrer" \
moz-do-not-send="true">abalashov@evaristesys.com</a>&gt;  schrieb am Do., 24. Okt. \
2019, 08:16:<br>  </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="auto">It is not. But you can do this via any
                template system such as Jinja2, or a hand-rolled
                substitution script.<br>
                <br>
                <div dir="ltr">—
                  <div>Sent from mobile, with due apologies for brevity
                    and errors.</div>
                </div>
                <div dir="ltr"><br>
                  <blockquote type="cite">On Oct 24, 2019, at 2:02 AM,
                    Gaurav Bmotra &lt;<a
                      href="mailto:saigauravmehra91@gmail.com"
                      rel="noreferrer noreferrer" target="_blank"
                      moz-do-not-send="true">saigauravmehra91@gmail.com</a>&gt;
                    wrote:<br>
                    <br>
                  </blockquote>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div dir="ltr">hi 
                      <div>i using kamailio 5.2 </div>
                      <div>is it possible to use environmental variables
                        value in kamailio.cfg <br>
                        like i want to use local ip and public ip in
                        config file </div>
                      <div><br>
                      </div>
                      <div> listen=<a class="moz-txt-link-freetext" \
href="udp:$(local_ip):5060">udp:$(local_ip):5060</a> advertise   $(public_ip):5060<br \
                clear="all">
                        <div>if iti is possible then how i can use this </div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>thank you </div>
                        -- <br>
                        <div dir="ltr" data-smartmail="gmail_signature">
                          <div dir="ltr">
                            <div>
                              <div dir="ltr">
                                <div>
                                  <div dir="ltr">
                                    <div dir="ltr">
                                      <div dir="ltr">
                                        <div>
                                          <div dir="ltr"><br>
                                            <br>
                                            <br>
                                            <br>
                                            <br>
                                            <br>
                                            <br>
                                            <br>
                                            <font color="#999999"><b>Regards:</b><br>
                                              Gaurav Kumar</font><br>
                                          </div>
                                        </div>
                                        <div><br>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <span>_______________________________________________</span><br>
                    <span>Kamailio (SER) - Users Mailing List</span><br>
                    <span><a href="mailto:sr-users@lists.kamailio.org"
                        rel="noreferrer noreferrer" target="_blank"
                        \
moz-do-not-send="true">sr-users@lists.kamailio.org</a></span><br>  <span><a
                        \
href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"  rel="noreferrer \
                noreferrer" target="_blank"
                        \
moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a></span><br>
  </div>
                </blockquote>
              </div>
              _______________________________________________<br>
              Kamailio (SER) - Users Mailing List<br>
              <a href="mailto:sr-users@lists.kamailio.org"
                rel="noreferrer noreferrer" target="_blank"
                moz-do-not-send="true">sr-users@lists.kamailio.org</a><br>
              <a
                href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"
                rel="noreferrer noreferrer noreferrer" target="_blank"
                moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
  </blockquote>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" \
wrap="">_______________________________________________ Kamailio (SER) - Users \
Mailing List <a class="moz-txt-link-abbreviated" \
href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a> <a \
class="moz-txt-link-freetext" \
href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
 </pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" \
href="http://www.asipto.com">www.asipto.com</a> <a class="moz-txt-link-abbreviated" \
href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a \
class="moz-txt-link-abbreviated" \
href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a> Kamailio \
Advanced Training, Oct 21-23, 2019, Berlin, Germany -- <a \
class="moz-txt-link-freetext" \
href="https://asipto.com/u/kat">https://asipto.com/u/kat</a></pre>  </body>
</html>


[Attachment #6 (text/plain)]

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic