[plug] How to set 'global' environment variables at boot time?

Alexander Hartner alex at j2anywhere.com
Fri Sep 14 11:15:29 WST 2012


Hi Frank

Have you tried putting an entry into /etc/environment or create a new profile file in /etc/profile.d/xyz.sh for example.

Also have a look in tomcat's bin/tool-wrapper.sh script. It only sets CATALINA_HOME if it hasn't been already set. 

So it seems you can specify CATALINA_HOME externally in environment or profile.d and have it override the default value of the tomcat installation.

Hope this helps
Alex

On 12/09/2012, at 3:52 PM, Fred Janon <fjanon at yahoo.com> wrote:

> 
> Thanks for that Jason.
> 
> Does it mean that there is no way to set a global environment variable at boot time?
> 
> I wanted to understand not only for Tomcat but for future use as well.
> 
> Thanks
> 
> Fred
> 
> --- On Tue, 9/11/12, Jason Nicholls <jason at mindsocket.com.au> wrote:
> 
> From: Jason Nicholls <jason at mindsocket.com.au>
> Subject: Re: [plug] How to set 'global' environment variables at boot time?
> To: plug at plug.org.au
> Date: Tuesday, September 11, 2012, 7:04 PM
> 
> Hey Fred,
> 
> I had a similar requirement to make a generic init script for a tomcat application which could be installed anywhere on the filesystem and even multiple copies.
> 
> In the end I created an init script that lived within the installed location and symlinked to it from /etc/init.d/<service_name>
> 
> Within the init script I get my install directory by running (in this case the init script lives in <tomcat_dir>/server/bin/helpers):
> 
> INSTALL_DIR=`dirname $(readlink -f $0) | sed 's/\/server\/bin\/helpers//'`
> 
> The next thing I do in the init script is read in the environment for this instance of tomcat, e.g.
> 
> if [ -f $INSTALL_DIR/server/bin/setenv.sh ]; then
>     . $INSTALL_DIR/server/bin/setenv.sh
> fi
> 
> The setenv.sh can contain anything required for this specific instance, e.g. java home, catalina home, java mem params etc...
> 
> Initially I had it configured to use something in /etc/defaults but I had to abstract things out to work with multiple installs on the same host plus support multiple flavours of Linux and other commercial UNIXes. The init scripts differ a bit but all come back to that setenv...
> 
> 
> On Wed, Sep 12, 2012 at 12:42 AM, Fred Janon <fjanon at yahoo.com> wrote:
> Hi,
> 
> I am working on a script to start Tomcat on a CentOS like OS (AWS EC2 Linux).
> 
> I need to configure a 'global' environment variable in the system that is set when the system boots and before the tomcat scripts executes to start the service. I did some research on z InnerNet and tried quite a few things with no success.
> 
> Basically I need to set and export the environment variable with a path ($CATALINA_HOME), maybe from /etc/profile?, and then read it from another script at boot time. Also how do I read and display the variable from the script to verify it is set properly?
> 
> All the scripts I've seen hard code the path, which I want to avoid.
> 
> Any suggestion?
> 
> Thanks
> 
> Fred
> 
> 
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://lists.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.org.au
> PLUG Membership: http://www.plug.org.au/membership
> 
> 
> 
> -- 
> Jason Nicholls
> jason at mindsocket.com.au
> 0430 314 857
> 
> 
> -----Inline Attachment Follows-----
> 
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://lists.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.org.au
> PLUG Membership: http://www.plug.org.au/membership
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://lists.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.org.au
> PLUG Membership: http://www.plug.org.au/membership

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20120914/0be58b77/attachment.html>


More information about the plug mailing list