[06:00] 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] 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] and I can't for the life up me get it working with su [06:02] 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] 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] I've spent about a day on this, and the more I read the less I know [07:41] Is it at all possible to run a command as another user with upstart? [07:45] thatguydan: http://upstart.ubuntu.com/cookbook/#run-a-job-as-a-different-user [07:51] 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] su -s /bin/sh -c 'exec "$0" "$@"' username -- /path/to/command [07:53] that just did it [07:54] found after hours of reading [07:54] 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] or at least it was for me [07:55] i might be an idiot though [14:37] 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] you can pass as many variables as you want [14:37] pix instance expands all variables [14:37] pixie79: ^^ [14:38] pixie79: so you can have instance $VAR1$VAR2$VAR3 [14:38] ok then i take it to start the job i would do something like, 'start job TTY=1 cust=demo' [14:39] pixie79: exactly [14:39] thanks [14:39] 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] ok [14:51] SpamapS: is there a way to require that the variables have both been given otherwise refuse to start? [15:04] pixie79: yes in pre-start you can check for them and if they're not set just run 'stop; exit 0;' [15:04] ok thanks [16:04] SpamapS: does this look ok? http://pastie.org/4575169 [16:07] at the moment when i run it i am getting unknown job [16:21] back later to fix my pre-start script [16:25] pixie79: you can try 'init-checkconf /etc/init/yourjob.conf' [16:27] pixwell if pixie79 comes back.. I think he fell victim to bug 328366 [16:28] s/he/they/ :-P