Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

boxofrad
Copy link
Contributor

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 :)

@kares
Copy link
Member

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 ?

@boxofrad
Copy link
Contributor Author

Yep that sounds like a plan ;)

@kares
Copy link
Member

kares commented Jan 19, 2012

you're right - less talking more coding :)

kares@a328d4b

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

@kares
Copy link
Member

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 kares closed this Jan 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants