I thought that I'll post my scripts anyway. But please see notes (*)
/etc/default/java
Code: Select all
# Default path settings for Java Runtime Environment and
# Java Software Development Kit.
# This file can be sourced by any script depending on Java.
# JDK default path
JAVA_HOME=/opt/j2sdk1.4.2_08
# JDK alternative path
JDK_HOME=/opt/j2sdk1.4.2_08
# Update PATH so java and javac can be found
PATH=${JAVA_HOME}/bin:${JDK_HOME}/jre/bin:${PATH}
/etc/default/tomcat
Code: Select all
# Default settings for Jakarta Tomcat server.
# This file is sourced by /etc/init.d/tomcat
# Location of Tomcat installation
CATALINA_HOME=/opt/jakarta-tomcat-5.0.28
# Location of Tomcat public root directory
CATALINA_BASE=/home/services/tomcat
# Location of running process id file
CATALINA_PID=/var/run/tomcat.pid
/etc/init.d/tomcat
Code: Select all
#!/sbin/sh
#
# Manage Tomcat server startup and shutdown
if [ -f /etc/default/java ]; then
. /etc/default/java
fi
# If configuration file is missing, just exit
if [ ! -f /etc/default/tomcat ]; then
exit 0
fi
. /etc/default/tomcat
export JAVA_HOME CATALINA_HOME CATALINA_BASE CATALINA_PID
case "$1" in
start)
echo "Starting Tomcat..."
if [ -x $CATALINA_HOME/bin/startup.sh ] ; then
$CATALINA_HOME/bin/startup.sh
fi
echo "done."
;;
stop)
if [ ! -f $CATALINA_PID ] ; then
echo "Tomcat is not running, not stopping it."
else
echo "Stopping Tomcat..."
if [ -x $CATALINA_HOME/bin/shutdown.sh ]; then
$CATALINA_HOME/bin/shutdown.sh -force
rm -f $CATALINA_PID
fi
echo "done."
fi
;;
restart)
echo "Restarting Tomcat..."
if [ -f $CATALINA_PID ]; then
if [ -x $CATALINA_HOME/bin/shutdown.sh ]; then
$CATALINA_HOME/bin/shutdown.sh -force
rm -f $CATALINA_PID
fi
echo
fi
if [ -x $CATALINA_HOME/bin/startup.sh ] ; then
$CATALINA_HOME/bin/startup.sh
fi
echo "done."
;;
*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;
esac
exit 0
(*) Notes:
1) I always install JDK, not JRE. The JDK I used is 1.4.2_08 installed in /opt.
2) I always separate Tomcat binaries from www root. I place the latter in /home/services/tomcat. Essentially, it is a copy of most directories of Tomcat installation from /opt/jakarta-tomcat-<version>.
If you have no idea what directories to copy there, then copy all directories EXCLUDING /opt/jakarta-tomcat-<version>/bin. Then you can change configuration in conf, install applications in webapps, etc., but you still have original copy of files in /opt.
3) I put start symlink for tomcat in /etc/rc3.d and kill symlinks in /etc/rc1.d and /etc/rc0.d with number 99.
4) Even though after starting the script you get back to prompt quite quickly, Tomcat itself starts in about 10 seconds (not counting applications). So, if you need to restart it sometimes, give it a little time before sending requests or refreshing a browser.
I used the above configuration for some time in production environment with good results.
So at least I know that this setup works for me.
Experience shows that you can never have enough experience.
If someone solves a problem for you, say thanks... and put [SOLVED] in the title!