#!/bin/sh
#
# Startup script for Wiki based on Tomcat Servlet Engine
# User under which tomcat will run
TOMCAT_USER=project
# shutdown port for tomcat
SHUTDOWN_PORT=8009
DEBUG_PORT=8000
[ start == $1 ] && sleep 20
# Check if port is listing
checkListeningPort(){
if [ `uname -s` = "SunOS" ]; then
netstat -an -P tcp | grep LISTEN | grep "\*\.$1" >/dev/null
else
netstat -lnt | grep ":$1" >/dev/null
fi
}
# start, debug, stop, and status functions
start() {
# Start Tomcat in normal mode
checkListeningPort $SHUTDOWN_PORT
if [ $? -eq 0 ]; then
echo "Tomcat is already running, shutdown port is $SHUTDOWN_PORT"
return 1
fi
echo "Starting tomcat..."
su - $TOMCAT_USER -c "tomcat/bin/startup.sh" > /dev/null
echo "tomcat started."
}
stop_server() {
checkListeningPort $SHUTDOWN_PORT
if [ $? -ne 0 ]; then
echo "Tomcat is not running."
return 1
fi
echo "Stopping tomcat..."
su - $TOMCAT_USER -c "tomcat/bin/shutdown.sh" > /dev/null
}
status() {
checkListeningPort $SHUTDOWN_PORT
if [ $? -ne 0 ]; then
echo "Tomcat is not running."
return 1
fi
MODE="normal"
checkListeningPort $DEBUG_PORT
[ $? -eq 0 ] && MODE="debug"
echo "Tomcat is running in $MODE mode"
}
#echo "Pass 001" >>/tmp/tomcat.log
case "$1" in
start)
start
;;
stop)
stop_server
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
#echo "Pass 002" >>/tmp/tomcat.log
阅读(1229) | 评论(0) | 转发(0) |