corrections for LSB compliance

This commit is contained in:
Dave Knox 2010-07-01 20:55:12 +00:00
parent 431c79f46f
commit 186acca061

View File

@ -141,8 +141,13 @@ function parseOptions() {
# See how we were called.
function start() {
echo -n "Starting ${TOMCAT_PROG}: "
if [ -f "/var/lock/subsys/${NAME}" ] ; then
if [ "$RETVAL" != "0" ]; then
log_failure_msg
return
fi
if [ -f "/var/lock/subsys/${NAME}" ]; then
if [ -f "/var/run/${NAME}.pid" ]; then
read kpid < /var/run/${NAME}.pid
# if checkpid $kpid 2>&1; then
@ -157,11 +162,15 @@ function start() {
fi
# fix permissions on the log and pid files
export CATALINA_PID="/var/run/${NAME}.pid"
touch $CATALINA_PID
touch $CATALINA_PID 2>&1 || RETVAL="4"
if [ "$RETVAL" -eq "0" -a "$?" -eq "0" ]; then
chown ${TOMCAT_USER}:${TOMCAT_USER} $CATALINA_PID
touch $TOMCAT_LOG
fi
[ "$RETVAL" -eq "0" ] && touch $TOMCAT_LOG 2>&1 || RETVAL="4"
if [ "$RETVAL" -eq "0" -a "$?" -eq "0" ]; then
chown ${TOMCAT_USER}:${TOMCAT_USER} $TOMCAT_LOG
if [ "$CATALINA_HOME" != "/usr/share/tomcat6" ]; then
fi
if [ "$CATALINA_HOME" != "/usr/share/tomcat6" -a "$RETVAL" -eq "0" ]; then
# Create a tomcat directory if it doesn't exist
makeHomeDir
# If CATALINA_HOME doesn't exist modify port number so that
@ -172,32 +181,32 @@ function start() {
${CATALINA_HOME}/conf/server.xml
fi
parseOptions
if [ "$SECURITY_MANAGER" = "true" ]; then
if [ "$RETVAL" -eq "0" -a "$SECURITY_MANAGER" = "true" ]; then
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start-security" \
>> $TOMCAT_LOG 2>&1
>> $TOMCAT_LOG 2>&1 || RETVAL="4"
else
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start" >> $TOMCAT_LOG 2>&1
[ "$RETVAL" -eq "0" ] && $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start" >> $TOMCAT_LOG 2>&1 || RETVAL="4"
fi
RETVAL="$?"
if [ "$RETVAL" -eq 0 ]; then
if [ "$RETVAL" -eq "0" ]; then
log_success_msg
touch /var/lock/subsys/${NAME}
else
log_failure_msg
log_failure_msg "Error code ${RETVAL}"
fi
if [ "$DISTRIB_ID" = "MandrivaLinux" ]; then
echo
fi
return $RETVAL
}
function stop() {
RETVAL="0"
echo -n "Stopping ${TOMCAT_PROG}: "
if [ -f "/var/lock/subsys/${NAME}" ]; then
parseOptions
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} stop" >> $TOMCAT_LOG 2>&1
RETVAL="$?"
if [ "$RETVAL" -eq "0" ]; then
touch /var/lock/subsys/${NAME} 2>&1 || RETVAL="4"
[ "$RETVAL" -eq "0" ] && $SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} stop" >> $TOMCAT_LOG 2>&1 || RETVAL="4"
fi
if [ "$RETVAL" -eq "0" ]; then
count="0"
if [ -f "/var/run/${NAME}.pid" ]; then
@ -212,7 +221,7 @@ function stop() {
done
if [ "$count" -gt "$SHUTDOWN_WAIT" ]; then
if [ "$SHUTDOWN_VERBOSE" = "true" ]; then
echo "killing processes which didn't stop after $SHUTDOWN_WAIT seconds"
log_warning_msg "killing processes which did not stop after ${SHUTDOWN_WAIT} seconds"
fi
kill -9 $kpid
fi
@ -221,17 +230,25 @@ function stop() {
rm -f /var/lock/subsys/${NAME} /var/run/${NAME}.pid
else
log_failure_msg
RETVAL="4"
fi
else
log_success_msg
RETVAL="0"
fi
if [ "$DISTRIB_ID" = "MandrivaLinux" ]; then
echo
fi
return $RETVAL
}
function usage()
{
echo "Usage: $0 {start|stop|restart|condrestart|try-restart|reload|force-reload|status|version}"
RETVAL="2"
}
# See how we were called.
RETVAL="0"
case "$1" in
start)
start
@ -260,32 +277,42 @@ case "$1" in
;;
status)
if [ -f "/var/run/${NAME}.pid" ]; then
# status ${NAME}
# RETVAL="$?"
read kpid < /var/run/${NAME}.pid
if [ -d "/proc/${kpid}" ]; then
echo "${NAME} (pid ${kpid}) is running..."
log_success_msg "${NAME} (pid ${kpid}) is running..."
RETVAL="0"
else
# The pid file exists but the process is not running
log_warning_msg "PID file exists, but process is not running"
RETVAL="1"
fi
else
pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} java)"
if [ -z "$pid" ]; then
# status ${NAME}
# RETVAL="$?"
echo "${NAME} is stopped"
log_success_msg "${NAME} is stopped"
RETVAL="3"
else
echo "${NAME} (pid $pid) is running..."
log_success_msg "${NAME} (pid $pid) is running..."
RETVAL="0"
fi
fi
if [ -f /var/lock/subsys/${NAME} ]; then
pid="$(/usr/bin/pgrep -d , -u ${TOMCAT_USER} -G ${TOMCAT_USER} java)"
# The lockfile exists but the process is not running
if [ -z "$pid" ]; then
log_failure_msg "${NAME} lockfile exists but process is not running"
RETVAL="2"
fi
fi
;;
version)
${TOMCAT_SCRIPT} version
;;
*)
echo "Usage: $0 {start|stop|restart|condrestart|try-restart|reload|force-reload|status|version}"
RETVAL="2"
usage
;;
esac
exit $RETVAL