Hey Fred,<div><br></div><div>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.</div><div><br></div><div>In the end I created an init script that lived within the installed location and symlinked to it from /etc/init.d/<service_name></div>
<div><br></div><div>Within the init script I get my install directory by running (in this case the init script lives in <tomcat_dir>/server/bin/helpers):</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><font face="courier new, monospace">INSTALL_DIR=`dirname $(readlink -f $0) | sed 's/\/server\/bin\/helpers//'`</font></div><div><br></div></blockquote>The next thing I do in the init script is read in the environment for this instance of tomcat, e.g.<div>
<br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="courier new, monospace">if [ -f $INSTALL_DIR/server/bin/setenv.sh ]; then<br>    . $INSTALL_DIR/server/bin/setenv.sh<br>fi</font></blockquote>
<div><br></div><div>The setenv.sh can contain anything required for this specific instance, e.g. java home, catalina home, java mem params etc...</div><div><br></div><div>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...</div>
<div><br><div><br><div class="gmail_quote">On Wed, Sep 12, 2012 at 12:42 AM, Fred Janon <span dir="ltr"><<a href="mailto:fjanon@yahoo.com" target="_blank">fjanon@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">Hi,<div><br></div><div>I am working on a script to start Tomcat on a CentOS like OS (AWS EC2 Linux).</div><div><br></div><div>
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.</div>
<div><br></div><div>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?</div>
<div><br></div><div>All the scripts I've seen hard code the path, which I want to avoid.</div><div><br></div><div>Any
 suggestion?</div><div><br></div><div>Thanks</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Fred</div><div><br></div></font></span></td></tr></tbody></table><br>_______________________________________________<br>

PLUG discussion list: <a href="mailto:plug@plug.org.au">plug@plug.org.au</a><br>
<a href="http://lists.plug.org.au/mailman/listinfo/plug" target="_blank">http://lists.plug.org.au/mailman/listinfo/plug</a><br>
Committee e-mail: <a href="mailto:committee@plug.org.au">committee@plug.org.au</a><br>
PLUG Membership: <a href="http://www.plug.org.au/membership" target="_blank">http://www.plug.org.au/membership</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jason Nicholls<br><a href="mailto:jason@mindsocket.com.au" target="_blank">jason@mindsocket.com.au</a><br>
0430 314 857<br><br>
</div></div></div>