I am wondering why during service start up environment variables are not visible. To be more precise: I created service startup scrip according to LSB spec which starts some java process. For this purpose JAVA_HOME env variable is checked first. This env variable is set in /etc/profile.d/java.sh. That is probably not executed while starting the service. I would like uderstand the process and what is the correct solution in such case?
RC scripts are invoked as non-interactive shell scripts. Thus they do not read /etc/profile. Thus you have to explicitly define your variables in your script. Either directly in your script or use some (covering up) techniques lot of RC script use (main variables defined in /etc/sysconfig/$package).
See how tomcat6 is doing that (although it is quite overcomplicated according to my opinion).