[HCoop-Help] Daemon with access to environment variables

Michal michal at hcoop.net
Sat Apr 4 08:09:55 EDT 2009


Hi,

Thanks for your replay: I've now tried that, but I can't get it to work.

More specifically, my daemon uses a shared library. The location of
which I have specified in my LD_LIBRARY_PATH / LIBRARY_PATH variable
(ok, I'm not sure which one is right, so I just set both) It runs fine
running it directly from the command line in the foreground as a usual
command. However, with run-in-pagsh I get:

error while loading shared libraries: libgsasl.so.7: cannot open
shared object file: No such file or directory

Also, in my wrapper script I manually echo the value of the variables
just before my daemon is called. They are set right: it seems like
they are not 'transferred' into the environment of the daemon.

(Also: technically there are 4 daemons involved in what I'm trying to
do, but I'm, not sure that's important. In any case, everything I've
described happens if I just try to run one of them)


On Sat, Apr 4, 2009 at 12:41 PM, Davor Ocelic <docelic at hcoop.net> wrote:
> On Sat, 4 Apr 2009 12:28:30 +0100
> Michal <michal at hcoop.net> wrote:
>
>> Hi,
>>
>> (I think) A daemon I'm trying to run requires some environment
>> variables to be set. If just running a program under my own username,
>> I would usually set them in .bashrc or .bash_profile, but these don't
>> seem to be run when using the run-in-pagsh script, which (from what I
>> understand) runs my daemon under the username michal.daemon.
>>
>> How can I run a daemon with specific environment variables set?
>
> Here's the thing:
>
> The daemon will always run under your username; it's just that it will
> obtain privileges of "michal.daemon" for accessing the files on disk.
>
> (Or, strictly,  for accessing Kerberos-enabled services, which in
> this case will be 1 service - OpenAFS filesystem data).
>
> You can't set environment variables in .bash_profile because that file
> is ran for interactive shells only (ssh, login -l etc..).
>
> You could use .bashrc but that too will only work if bash shell is used
> to start the program.
>
> So I would suggest doing the following:
>
> VAR1=VAL1 VAR2=VAL2 run-in-pagsh <command> <args>...
>
>
> I did not check the specific behavior of run-in-pagsh or the commands
> it invokes in turn-- so just verify that none of them reset the
> environment vars before calling the intended daemon.
>
> But here's the final and best solution which will work in any case
> and is the most convenient to call:
>
> 1) Create a run script, say "runjabber", with something like
>
> #!/bin/sh
>
> VAR1=VAL1 VAR2=VAL2 <daemon> <args>
>
> 2) Then run it with: run-in-pagsh runjabber
>
> It'll take care of everything, and you have a single file to modify
> for whatever changes/adjustments you want to make later.
>
> Cya,
> -doc
>
> _______________________________________________
> HCoop-Help mailing list
> HCoop-Help at lists.hcoop.net
> https://lists.hcoop.net/listinfo/hcoop-help
>



More information about the HCoop-Help mailing list