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 :)
Fix cases where $USER is not defined.
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.
jsvc -user kares
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"
and than of course completely remove the -user $USER \ line
-user $USER \
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 ?
$EUID -eq 0
Yep that sounds like a plan ;)
you're right - less talking more coding :)
but I'll need to test it before pull-ing ...
closing in favor of #12 thanks for bringing this up @boxofrad
let us know if you run into any issues with the new approach