Fix issue where $USER is undefined in init. #11

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

boxofrad commented Jan 19, 2012

Hi, me again :P

This commit fixes an issue we've been having where the service would not start on boot correctly because the $USER variable was undefined.

As $USER gets interpolated in the command it'd run (notice the -user flag):

/usr/bin/jsvc -home /usr/lib/jvm/java-6-openjdk/jre      -wait 20   -pidfile /var/run/trinidad.pid   -user    -procname jsvc-   -jvm server  .........

This only shows up for us when the script is getting run by init on boot.

Hope this helps :)

Owner

kares commented Jan 19, 2012

hmm, I was actually thinking of rather getting rid of -user option entirely.

first of all it's not working (for me at least on linux when I run jsvc -user kares as root), secondly in your case it seems redundant as you're not changing the user under which trinidad should boot.

recommended scenario would be running trinidad under a non-root user (even while init-ed under root) and thus we should extend the configuration to support this (optional) option - if the user enters a $RUN_USER and we're running the script as root I would add :

if [[ -n $RUN_USER && $EUID -eq 0 ]]; then
  JSVC="sudo -u $RUN_USER $JSVC"
fi

and than of course completely remove the -user $USER \ line

it is still runnable as root (for those binding to 80) if $RUN_USER is empty
and runs with the priviledges of the non-root current user if executed directly e.g. when doing a restart during capistrano deploy (ssh-d under $RUN_USER)

this should suit your case as well ($EUID -eq 0 will work in your case - no need to whoami), or not ?

Contributor

boxofrad commented Jan 19, 2012

Yep that sounds like a plan ;)

Owner

kares commented Jan 19, 2012

you're right - less talking more coding :)

kares/trinidad_init_services@a328d4b

but I'll need to test it before pull-ing ...

Owner

kares commented Jan 20, 2012

closing in favor of #12 thanks for bringing this up @boxofrad
let us know if you run into any issues with the new approach

kares closed this Jan 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment