/srv/irclogs.ubuntu.com/2012/08/23/#upstart.txt

thatguydanHey 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/environment06:00
thatguydanexec sudo -u user1 -i "/usr/bin/foo /opt/bar >> /var/log/bar.log 2>&1" works in shell, but doesn't in the upstart script06:01
thatguydanand I can't for the life up me get it working with su06:01
thatguydanI was trying to source the environment from /etc/environment.local, but I was having problems getting upstart to monitor the right PID06:02
thatguydanIt 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 sudo06:03
thatguydanI've spent about a day on this, and the more I read the less I know06:05
thatguydanIs it at all possible to run a command as another user with upstart?07:41
jodhthatguydan: http://upstart.ubuntu.com/cookbook/#run-a-job-as-a-different-user07:45
thatguydanI'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 run07:51
thatguydansu -s /bin/sh -c 'exec "$0" "$@"' username -- /path/to/command 07:53
thatguydanthat just did it07:53
thatguydanfound after hours of reading07:54
thatguydani can't believe the use case of running a command as non-privileged and passing through environment variables is so difficult to accomplish07:54
thatguydanor at least it was for me07:55
thatguydani might be an idiot though07:55
pixie79hi, 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 customer14:37
SpamapSyou can pass as many variables as you want14:37
SpamapSpixinstance expands all variables14:37
SpamapSpixie79: ^^14:37
SpamapSpixie79: so you can have instance $VAR1$VAR2$VAR314:38
pixie79ok then i take it to start the job i would do something like, 'start job TTY=1 cust=demo'14:38
SpamapSpixie79: exactly14:39
pixie79thanks14:39
SpamapSpixie79: note that if you have a 'start on' line you can also pick up any exported variables from jobs that cause you to start14:39
pixie79ok14:40
pixie79SpamapS: is there a way to require that the variables have both been given otherwise refuse to start?14:51
SpamapSpixie79: yes in pre-start you can check for them and if they're not set just run 'stop; exit 0;'15:04
pixie79ok thanks15:04
pixie79SpamapS: does this look ok? http://pastie.org/457516916:04
pixie79at the moment when i run it i am getting unknown job16:07
pixie79back later to fix my pre-start script16:21
SpamapSpixie79: you can try 'init-checkconf /etc/init/yourjob.conf'16:25
SpamapSpixwell if pixie79 comes back.. I think he fell victim to bug 32836616:27
SpamapSs/he/they/ :-P16:28

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!