I want to start my tomcat server automatically on startup. Therefore I retrieved a simple LSB conform script from the net and modified it to my needs. This is the script:
# Provide logging functions like log_success_msg, log_failure_msg and log_warning_msg
. /lib/lsb/init-functions
[ -f /etc/default/rcS ] && . /etc/default/rcS
PATH=/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39
case "$1" in
start)
/opt/apache-tomcat-7.0.39/bin/startup.sh
;;
stop)
/opt/apache-tomcat-7.0.39/bin/shutdown.sh
;;
restart|force-reload)
;;
status)
;;
*)
log_failure_msg "Usage: {start|stop|restart|force-reload|status}"
exit 1
esac
exit 0
Now, I copied it to /etc/init.d and applied a "chmod +x tomcat" on it. Then I tried to run it
/etc/init.d # ./tomcat start
/opt/apache-tomcat-7.0.39/bin/startup.sh: 1: /opt/apache-tomcat-7.0.39/bin/startup.sh: uname: not found
/opt/apache-tomcat-7.0.39/bin/startup.sh: 1: /opt/apache-tomcat-7.0.39/bin/startup.sh: dirname: not found
Cannot find /catalina.sh
The file is absent or does not have execute permission
This file is needed to run this program
What am I missing here?
These
show that you're missing a proper PATH.
Try changing the PATH line in your startup script to:
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39
THis is the issue
PATH=/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39
You forgot to append $PATH to that.. it must be
PATH=/opt/jdk1.7.0_21:/opt/apache-tomcat-7.0.39:$PATH