[HCoop-Help] Daemon with access to environment variables
docelic at hcoop.net
Sat Apr 4 07:41:16 EDT 2009
On Sat, 4 Apr 2009 12:28:30 +0100
Michal <michal at hcoop.net> wrote:
> (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
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.
More information about the HCoop-Help