[06:00] <thatguydan> Hey gents, I was hoping someone could help WRT the right way to execute a command as another user in a script stanza while preserving /etc/environment
[06:01] <thatguydan> exec sudo -u user1 -i "/usr/bin/foo /opt/bar >> /var/log/bar.log 2>&1" works in shell, but doesn't in the upstart script
[06:01] <thatguydan> and I can't for the life up me get it working with su
[06:02] <thatguydan> I was trying to source the environment from /etc/environment.local, but I was having problems getting upstart to monitor the right PID
[06:03] <thatguydan> It was working if I sourced from /etc/environment.local with su, but no love with the PID's, that's why I'm trying to get it going with sudo
[06:05] <thatguydan> I've spent about a day on this, and the more I read the less I know
[07:41] <thatguydan> Is it at all possible to run a command as another user with upstart?
[07:45] <jodh> thatguydan: http://upstart.ubuntu.com/cookbook/#run-a-job-as-a-different-user
[07:51] <thatguydan> I've tried the su way of doing it, but stopping the service just leads the bash/su being killed, not the actual command i'm trying to run
[07:53] <thatguydan> su -s /bin/sh -c 'exec "$0" "$@"' username -- /path/to/command 
[07:53] <thatguydan> that just did it
[07:54] <thatguydan> found after hours of reading
[07:54] <thatguydan> i can't believe the use case of running a command as non-privileged and passing through environment variables is so difficult to accomplish
[07:55] <thatguydan> or at least it was for me
[07:55] <thatguydan> i might be an idiot though
[14:37] <pixie79> hi, it there a way to have two variables passed to an upstart job, i see we have instance which would allow one variable but i also need to import a second for example customer
[14:37] <SpamapS> you can pass as many variables as you want
[14:37] <SpamapS> pix	instance expands all variables
[14:37] <SpamapS> pixie79: ^^
[14:38] <SpamapS> pixie79: so you can have instance $VAR1$VAR2$VAR3
[14:38] <pixie79> ok then i take it to start the job i would do something like, 'start job TTY=1 cust=demo'
[14:39] <SpamapS> pixie79: exactly
[14:39] <pixie79> thanks
[14:39] <SpamapS> pixie79: note that if you have a 'start on' line you can also pick up any exported variables from jobs that cause you to start
[14:40] <pixie79> ok
[14:51] <pixie79> SpamapS: is there a way to require that the variables have both been given otherwise refuse to start?
[15:04] <SpamapS> pixie79: yes in pre-start you can check for them and if they're not set just run 'stop; exit 0;'
[15:04] <pixie79> ok thanks
[16:04] <pixie79> SpamapS: does this look ok? http://pastie.org/4575169
[16:07] <pixie79> at the moment when i run it i am getting unknown job
[16:21] <pixie79> back later to fix my pre-start script
[16:25] <SpamapS> pixie79: you can try 'init-checkconf /etc/init/yourjob.conf'
[16:27] <SpamapS> pixwell if pixie79 comes back.. I think he fell victim to bug 328366
[16:28] <SpamapS> s/he/they/ :-P