Skip to content

Instantly share code, notes, and snippets.

@Niemi
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Niemi/d53bb149cebfadb0ae2b to your computer and use it in GitHub Desktop.
Save Niemi/d53bb149cebfadb0ae2b to your computer and use it in GitHub Desktop.
tomcat init.d script [SysV] for SLES or OpenSuSe
#!/bin/sh
#source "http://tr.opensuse.org/Tomcat_HOWTO"
# Tomcat Startup Script
### BEGIN INIT INFO
# Provides: Tomcat
# Required-Start: $local_fs $network $remote_fs apache2
# Required-Stop: $local_fs $network $remote_fs apache2
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Tomcat
# Description: Tomcat
### END INIT INFO
CATALINA_HOME=/opt/tomcat; export CATALINA_HOME
JAVA_HOME=/usr/java/latest; export JAVA_HOME
TOMCAT_OWNER=tomcat; export TOMCAT_OWNER
RETVAL=0
start() {
echo -n "Starting Tomcat: "
su -s /bin/bash $TOMCAT_OWNER $CATALINA_HOME/bin/startup.sh
sleep 2
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/tomcat
echo
}
stop() {
echo -n "Stopping Tomcat: "
su -s /bin/bash $TOMCAT_OWNER $CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/tomcat
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: tomcat {start|stop|restart}"
exit
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment