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 Java PHI wrote:
Hi, Does anyone has a Linux script to run Tomcat as Linux services, i.e. the runlevel scripts ? I have tried to make one, but in case there is a proven script that has been deployed somewhere... can someone please share ? Thanks, Feris
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org