Setting up tomcat autostart on Linux?

Solution 1:

/etc/init.d/tomcat-wepappname

#!/bin/sh 
### BEGIN INIT INFO 
# Provides:          tomcat-wepappname 
# Required-Start:    $all 
# Required-Stop:     
# Default-Start:     2 3 4 5 
# Default-Stop:      0 1 6 
# Short-Description: foo bar 
# Description:       long desc
### END INIT INFO 
# Author: Foo Bar <[email protected]> 

. /lib/lsb/init-functions 

# Actions 
case "$1" in 
 start) 
  log_action_begin_msg "Starting tomcat webapp" "tomcat-webappname"
  su - tomcat-webappuser -c "/home/sites/tomcat-webappname/webappname.sh $1" 
  log_end_msg 0 
  ;; 
 stop) 
  su - tomcat-webappuser -c "/home/sites/tomcat-webappname/webappname.sh $1" 
  ;; 
# restart) 
# something else...
#  ;; 
esac

exit 0

At least, register the service:

update-rc.d activemq defaults