[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shellcommands - can't source profile.
From: |
Chris Edillon |
Subject: |
Re: Shellcommands - can't source profile. |
Date: |
Fri, 7 Feb 2003 02:51:32 -0400 (GMT+4) |
On Thu, 6 Feb 2003, Wheeler, John wrote:
> I find myself doing this a lot when I replace jobs previously run through
> cron:
>
> shellcommands:
> '/bin/su - johnnyuser -c "/blah/blah/blah"'
>
> I have to do this to source the profile of that user to pickup critical
> environment variables for this process. I'd prefer to use the owner and
> chdir directives, but I won't get the env then. Is there some way to get
> this loaded without doing the su?
>
i don't think so, since cfagent isn't executing a login shell when
running shellcommands (and certainly not if useshell=false) so the
user dotfiles never get sourced. however, if i have a process which
requires a certain environment, i always write a wrapper script which
explicitly sets it instead of relying on a particular user environment.
when running such things from cfagent, i usually put the scripts in a
$CFINPUTS/scripts directory, and call them from there so all of my
cfengine-y things are in one place.
shellcommands:
wopr::
"${CFINPUTS}/scripts/global_thermonuclear_war.sh" owner=joshua
processes:
wopr:: "tic_tac_toe"
restart="${CFINPUTS}/scripts/tic_tac_toe"
owner=joshua
cfagent could probably be hacked to run external commands via a login
shell (loginshell=true?), but there may be security ramifications.
chris