(Repeating a reply I sent a week or so ago.)
I made this by modifying one for a different service.
It's set up so that tomcat runs as the user tomcat. In order to do that you'll
need to tweak the ownership of the files in the tomcat directory. I just made
everything owned by tomcat except webapps, which I own, but which is group
owned and writable by tomcat so it can explode the wars.
I'm on ubuntu (notice the two flavors of the functions file it sources).
You may not need the HUDSON_HOME stuff and I'm sure you won't need the
Dwaitlistd.host=${HOST} so delete stuff as necessary.
If you want it to run as root I'm guessing that you'd need to delete the
--chuid and --user lines.
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
export JAVA_OPTS=-server
export JAVA_HOME=/usr/java
export TOMCAT_DIR=/usr/local/tomcat
export HUDSON_HOME=/usr/local/hudson
TOMCAT_START=${TOMCAT_DIR}/bin/startup.sh
TOMCAT_STOP=${TOMCAT_DIR}/bin/shutdown.sh
TOMCAT_USER=tomcat
HOST=`/bin/hostname | sed -e 's/\..*//'`
export JAVA_OPTS="-server -Dwaitlistd.host=${HOST}"
test -f ${TOMCAT_START} || exit 0
# redhat
# . /etc/init.d/functions
# debian
. /lib/lsb/init-functions
case "$1" in
'start')
log_daemon_msg "Starting tomcat" "tomcat"
cd /var/log
# ${TOMCAT_START}
eval /sbin/start-stop-daemon \
--start \
--quiet \
--chuid ${TOMCAT_USER} \
--user ${TOMCAT_USER} \
--startas ${TOMCAT_START}
log_end_msg $?
;;
'stop')
log_daemon_msg "Stopping tomcat" "tomcat"
# ${TOMCAT_STOP}
eval /sbin/start-stop-daemon \
--stop \
--quiet \
--user ${TOMCAT_USER} \
--startas ${TOMCAT_STOP}
log_end_msg $?
;;
'restart')
${0} stop
log_action_msg "sleeping for several seconds ..."
sleep 13
${0} start
;;
*)
log_action_msg "Usage: ${0} {start|stop|restart}"
;;
esac
Kaushal Shriyan wrote:
Hi
I am not able to start tomcat as tomcat user on ubutu 8.04 Linux,
Below is my start/stop script
Any ideas as what is going wrong ?
Thanks and Regards
Kaushal
###################################################################################################
#!/bin/sh
#
# Startup script for Tomcat
JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
export JAVA_HOME
CATALINA_OPTS="-Xms512m -Xmx10000m"
export CATALINA_OPTS
start_tomcat=/usr/local/apache-tomcat-5.5.27/bin/startup.sh
stop_tomcat=/usr/local/apache-tomcat-5.5.27/bin/shutdown.sh
start() {
echo -n "Starting tomcat: "
su -c ${start_tomcat} tomcat
echo "done."
}
stop() {
echo -n "Shutting down tomcat: "
${stop_tomcat}
echo "done."
}
# See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
###################################################################################################
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]