You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by Charles Moulliard <ch...@gmail.com> on 2012/09/04 18:27:28 UTC

Re: Get environment variable

Hi,

I would like to suggest that we implement this modification in Karaf for by
example ssh as until now blueprint (shell-ssh.xml) will only retrieve the
key from org.apache.karaf.shell.cfg file and not using
-Dorg.apache.karaf.shell.sshHost=value. Do we agree on that ? If this is
the case I will create a ticket and makes the modification for Karaf 3.x
and 2.2.x

So the config file for ssh will becomes

    <ext:property-placeholder placeholder-prefix="$["
placeholder-suffix="]">
        <ext:default-properties>
            <ext:property name="karaf.startRemoteShell" value="true" />
            <ext:property name="karaf.admin.role" value="admin" />
            <ext:property name="karaf.sshHost" value="0.0.0.0" />
            <ext:property name="karaf.sshPort" value="8101" />
        </ext:default-properties>
    </ext:property-placeholder>

    <cm:property-placeholder persistent-id="org.apache.karaf.shell"
update-strategy="reload">
        <cm:default-properties>
            <cm:property name="sshPort" value="$[karaf.sshHost]"/>
            <cm:property name="sshHost" value="$[karaf.sshPort]"/>

Regards,

Charles

On Tue, Aug 28, 2012 at 11:06 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:

> Hi Charles,
>
> the easiest way is to use Aries Blueprint ext to get env variable.
>
> <blueprint xmlns:ext="http://aries.**apache.org/blueprint/xmlns/**
> blueprint-ext/v1.0.0<http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0>"
> ...>
>
>   <!-- Load system property -->
>   <ext:property-placeholder />
>
>   <bean ...><property name="foobar" value="${foobar}"/></bean>
>
> </blueprint>
>
> You can use it in combination with <cm/> to load system property as
> default value.
>
> Like this, you can use your env variable as system property:
>
> ./karaf -Dfoobar=$FOOBAR
>
> Regards
> JB
>
>
> On 08/24/2012 09:07 AM, Charles Moulliard wrote:
>
>> Hi,
>>
>> Karaf is deployed on a remote Unix machine where I need to get the
>> following variable :  $OPENSHIFT_INTERNAL_IP which corresponds to this
>> value
>>
>> [fabric-fuse.rhcloud.com <http://fabric-fuse.rhcloud.**com<http://fabric-fuse.rhcloud.com>>
>> fabric]\>
>>
>> printenv | grep OPENSHIFT_INTERNAL
>> OPENSHIFT_INTERNAL_IP=127.6.**51.129
>>
>> This variable has been added in the file org.ops4j.pax.web.cfg -->
>> org.ops4j.pax.web.listening.**addresses=$OPENSHIFT_INTERNAL_**IP
>>
>> but when Karaf boots, this value is not retrieved
>>
>> config:list
>>
>> karaf@root> config:list | grep org.ops4j.pax.web
>> Pid:            org.ops4j.pax.web
>> BundleLocation: mvn:org.ops4j.pax.web/pax-web-**runtime/1.0.10
>>     service.pid = org.ops4j.pax.web
>>     felix.fileinstall.filename =
>> file:/var/lib/stickshift/**2ee23a78e9664b8593ebbc77e16aac**
>> 38/app-root/runtime/fabric/**etc/org.ops4j.pax.web.cfg
>>     org.ops4j.pax.web.listening.**addresses = $OPENSHIFT_INTERNAL_IP
>>
>> Is there a trick to resolve this enviroment variable ?
>>
>> Regards,
>>
>> --
>> Charles Moulliard
>> Apache Committer / Sr. Pr. Consultant at FuseSource.com
>> Twitter : @cmoulliard
>> Blog : http://cmoulliard.blogspot.com
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>



-- 
Charles Moulliard
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Twitter : @cmoulliard
Blog : http://cmoulliard.blogspot.com