Hello ALUG,
I'm trying to write an init script to get Tomcat (4.1) to start at boot. (On Debian).
I've created a file: /var/webapps/tomcat/bin/tomcat.sh =====================================
export TOMCAT_BIN=/var/webapps/tomcat/bin export JAVA_HOME=/usr/lib/j2sdk1.4-sun
case "$1" in start) $TOMCAT_BIN/startup.sh ;; stop) $TOMCAT_BIN/shutdown.sh ;; restart) $TOMCAT_BIN/shutdown.sh $TOMCAT_BIN/startup.sh ;; *) echo "Usage: tomcat.sh {start|stop|restart}" ;; esac
exit 0
=====================================
which works when I run it (e.g. # /var/webapps/tomcat/bin/tomcat.sh start). So far, so good.
Next I created a new init script from /etc/init.d/skeleton: =====================================
#!/bin/sh
set -e
export JAVA_HOME=/usr/lib/j2sdk1.4-sun PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/var/webapps/tomcat/bin/tomcat.sh NAME=tomcat DESC="Tomcat 4.1 Servlet Engine"
PIDFILE=/var/run/tomcat/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed. test -x $DAEMON || exit 0
case "$1" in start) echo -n "Starting $DESC: $NAME" start-stop-daemon --start --quiet --pidfile $PIDFILE \ --chuid tomcat:tomcat --exec $DAEMON --user tomcat --group tomcat echo "." ;; stop) echo -n "Stopping $DESC: $NAME" start-stop-daemon --stop --quiet --pidfile $PIDFILE \ --exec $DAEMON --user tomcat --group tomcat echo "." ;; restart|force-reload) echo -n "Restarting $DESC: $NAME" start-stop-daemon --stop --quiet --oknodo --pidfile \ $PIDFILE --exec $DAEMON --user tomcat --group tomcat sleep 1 start-stop-daemon --start --quiet --pidfile \ $PIDFILE --chuid tomcat:tomcat --exec $DAEMON --user tomcat --group tomcat echo "." ;; *) # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac
exit 0
=====================================
but # /etc/init.d/tomcat start returns: Starting Tomcat 4.1 Servlet Engine: tomcatstart-stop-daemon: Unable to start /var/webapps/tomcat/bin/tomcat.sh: Exec format error
Similarly, # start-stop-daemon --start --pidfile /var/run/tomcat/tomcat.pid --chuid tomcat:tomcat --exec /var/webapps/tomcat/bin/tomcat.sh --user tomcat --group tomcat returns: start-stop-daemon: Unable to start /var/webapps/tomcat/bin/tomcat.sh: Exec format error
Removing --chuid, --user or --group doesn't make any difference either.
Does anyone know how I can make this work?
Cheers, Richard