Barry Brimer wrote:
I just installed Tomcat and when I run the chkconfig -add tomcat, it tells me that tomcat does not support chkconfig.
In order to support chkconfig, an init script must:
- Be located in /etc/rc.d/init.d (which /etc/init.d is a symlink to)
- Have a commented out line that contains "chkconfig: <default
runlevels for this service> <start priority> <stop priority>" 3. Have a commented out line that contains "description: <a description of the service>" 4. Upon successful service startup, place a lock file in /var/lock/subsys that matches the name of the service script. Upon successful service shutdown, the lockfile must be removed.
It is worth noting that you must use "chkconfig --add <service name>" in order to have the service script placed in the shutdown/restart runlevels correctly.
There are many great examples already provided by existing services. They should be fairly straightforward reading.
Here's the init script we use, if it helps at all:
#!/bin/sh # # Tomcat Server # # chkconfig: 345 96 30 # description: Java servlet container
JAVA_HOME=/opt/jdk
PATH=${JAVA_HOME}/bin:${PATH}
TOMCAT_START=/opt/tomcat/bin/startup.sh
TOMCAT_STOP=/opt/tomcat/bin/shutdown.sh
export JAVA_HOME PATH
start() { if [ -x ${TOMCAT_START} ]; then echo "Starting tomcat server..." ${TOMCAT_START} & else echo "Cannot start tomcat server" fi }
stop() { if [ -x ${TOMCAT_STOP} ]; then echo "Stopping tomcat server..." ${TOMCAT_STOP} & else echo "Cannot stop tomcat server" fi }
restart() { stop sleep 10 start }
status() { echo "No status available for tomcat server" }
case "$1" in 'start') start ;; 'stop') stop ;; 'restart') restart ;; 'status') status ;; *) echo "Please supply an argument [start|stop|restart]" esac