Created
September 1, 2013 03:22
-
-
Save gabrielkfr/6402130 to your computer and use it in GitHub Desktop.
Script de arranque para servicio Tomcat 6 en SCO Openserver 6.0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# tomcat start/stop script | |
# Usage: tomcat6 [ start | stop | enable | disable | restart | status ] | |
# | |
set -a | |
# Definitions | |
# Paths to tomcat files, and a label | |
TOMCAT_HOME="/opt/apache-tomcat-6.0.35" | |
TOMCAT_BIN="$TOMCAT_HOME/bin" | |
CATALINA_HOME=$TOMCAT_HOME | |
CATALINA_LOG=$CATALINA_HOME/logs/catalina.out | |
TOMCAT_START="$TOMCAT_BIN/startup.sh" | |
TOMCAT_STOP="$TOMCAT_BIN/shutdown.sh" | |
TOMCAT_LABEL="Apache Tomcat 6" | |
# More paths, and some wait timeouts | |
PATH="/bin:/usr/bin:/etc:/usr/gnu/bin"; export PATH | |
JAVA_HOME="/usr/java"; export JAVA_HOME | |
SCRIPTDIR="/etc/init.d" | |
SCRIPT="tomcat6" | |
SCRIPTNUM="95" | |
USAGE="Usage: $SCRIPT [ start | stop | enable | disable | restart | status ]" | |
############################################################################# | |
# tomcat_start | |
# start the server daemon running | |
############################################################################# | |
tomcat_start() { | |
# signal the server to start | |
echo -n "Starting $TOMCAT_LABEL ... " | |
# start the server | |
nohup $TOMCAT_START >> ${CATALINA_LOG} 2>&1 | |
# done message | |
echo "done." | |
} | |
############################################################################# | |
# tomcat_stop | |
# stop the server daemon if it is running | |
############################################################################# | |
tomcat_stop() { | |
# signal the server to stop | |
echo -n "Stopping $TOMCAT_LABEL ... " | |
# stop the server | |
nohup $TOMCAT_STOP >> ${CATALINA_LOG} 2>&1 | |
# done message | |
echo "done." | |
} | |
############################################################################# | |
# tomcat_restart | |
# restart the server daemon by sending it a SIGHUP | |
############################################################################# | |
tomcat_restart() { | |
echo "Restarting $TOMCAT_LABEL ..." | |
tomcat_stop | |
tomcat_start | |
} | |
############################################################################# | |
# tomcat_status | |
# status of the service | |
############################################################################# | |
tomcat_status() { | |
PID=`ps -aef | grep java | grep tomcat | sed "s~ *~ ~g" \ | |
| sed "s~^ ~~" | cut -d" " -f2` | |
if [ -n "$PID" ] ; then | |
echo "$TOMCAT_LABEL is running" | |
else | |
echo "$TOMCAT_LABEL is not running" | |
fi | |
} | |
############################################################################# | |
# tomcat_enable | |
# add a link to this script into the /etc/rc2.d directory, then start | |
# the server | |
############################################################################# | |
tomcat_enable() { | |
# Link in /etc/init.d/tomcat6 to /etc/rc[02].d/[SP] startup links. | |
# Remove any pre-existing link. | |
# Otherwise the hard link get out of sync, if /etc/init.d/tomcat | |
# inode is changed. | |
ENABLE_STR=Enabling | |
if [ -f /etc/rc*.d/[PS]$SCRIPTNUM$SCRIPT ]; then | |
echo "$TOMCAT_LABEL is already enabled." | |
ENABLE_STR="Re-freshing the links for" | |
fi | |
echo -n "$ENABLE_STR $TOMCAT_LABEL ... " | |
# Create S$SCRIPTNUM$SCRIPT. UW714 /etc/rc2 script | |
# starts the "S" scripts on boot | |
for FL in /etc/rc2.d/K /etc/rc2.d/S /etc/rc2.d/P \ | |
/etc/rc0.d/P | |
do | |
rm -f $FL$SCRIPTNUM$SCRIPT | |
ln $SCRIPTDIR/$SCRIPT $FL$SCRIPTNUM$SCRIPT | |
done | |
echo "done." | |
# start the server | |
tomcat_start | |
} | |
############################################################################# | |
# tomcat_disable | |
# stop the server, then remove any links to this script in /etc/rc*.d | |
############################################################################# | |
tomcat_disable() { | |
# stop the server | |
tomcat_stop | |
if [ -f /etc/rc*.d/[PS]$SCRIPTNUM$SCRIPT ] ; then | |
echo -n "Disabling $TOMCAT_LABEL ... " | |
# remove the /etc/rc*.d startup link | |
for FL in /etc/rc2.d/K /etc/rc2.d/S /etc/rc2.d/P \ | |
/etc/rc0.d/P | |
do | |
rm -f $FL$SCRIPTNUM$SCRIPT | |
done | |
echo "done." | |
else | |
# file does not exist | |
echo "$TOMCAT_LABEL is already disabled." | |
fi | |
} | |
############################################################################# | |
# main() | |
############################################################################# | |
# check the usage of the script | |
if [ $# -gt 1 ]; then | |
echo "$USAGE" | |
exit 1 | |
fi | |
# function to perform is in $1 | |
function="$1" | |
# execute the routine for the requested function | |
case $function in | |
start) | |
tomcat_start | |
;; | |
stop) | |
tomcat_stop | |
;; | |
enable) | |
tomcat_enable | |
;; | |
disable) | |
tomcat_disable | |
;; | |
restart) | |
tomcat_restart | |
;; | |
status) | |
tomcat_status | |
;; | |
*) | |
echo "$USAGE" | |
exit 1;; | |
esac | |
# done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment