Package: tomcat5.5 Version: 5.5.20-4 Severity: minor When following the instructions in /usr/share/doc/tomcat5.5/RUNNING.txt.gz, there are a few minor niggles with the current init.d script.
I have written a script to clone one instance (creates the directories etc) which I've attached to this bug report. The sensible thing to do is to change the NAME in the init.d script, however then the CATALINA_HOME variable points to the wrong location. It would be nice to have it set separately. Conversely, CATALINA_BASE is hardcoded to /var/lib/tomcat5.5 and should be set from NAME :-) Adrian -- Adrian Bridgett - [EMAIL PROTECTED] GPG key available on public key servers
#!/bin/sh # Clone tomcat instance so we get another JVM # Written by Adrian Bridgett <[EMAIL PROTECTED]>, Opsera Ltd. SOURCE=tomcat5.5 USERNAME=tomcat55 main() { name="$1" || die "Usage: `basename $0` clone-name" name="$SOURCE-$name" # sanity checking valid_name "$name" check_existing "$name" confirm "$name" # creation create_init "$name" create_etc "$name" create_var "$name" # not required unless you really want to be seperate #create_usrshare "$name" print_todo "$name" } die() { echo "$@" exit 1 } valid_name() { local name="$1" [ "$name" ] || die "No name given" rejected=`echo "$1" | tr -d -- '-_\.[a-z][A-Z][0-9]'` [ "$rejected" ] && die "Invalid characters \"$rejected\" in name" return 0 } check_existing() { local name="$1" if [ -e "/var/lib/$name" ]; then die "Pre-existing tomcat instance \"$name\"" fi return 0 } confirm() { local name="$1" echo -n "Are you sure you wish to create a new tomcat instance \"$name\"? [Yn] " read ans if [ "$ans" = "" ] || [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "yes" ]; then return 0 fi echo "Aborting at user request" exit 1 } create_init() { local name="$1" # CATALINA_HOME must be set to /usr/share/tomcat5.5 # CATALINA_BASE is set per instance to /var/lib/$name # change NAME, CATALINA_BASE, /etc/init.d/$SOURCE (usage statement) sed "s,^NAME=.*$,NAME=$name,g s,^CATALINA_BASE=.*$,CATALINA_BASE=/var/lib/\$NAME,g s,^CATALINA_HOME=.*$,CATALINA_HOME=/usr/share/tomcat5.5,g s,\(/etc/init.d/\)$SOURCE,\1$name,g" \ < /etc/init.d/$SOURCE > "/etc/init.d/$name" chmod 755 "/etc/init.d/$name" update-rc.d "$name" defaults 92 } create_etc() { local name="$1" cp -a /etc/$SOURCE "/etc/$name" cp /etc/default/$SOURCE "/etc/default/$name" } create_var() { local name="$1" install -d "/var/cache/$name" -o $USERNAME -g adm -m700 install -d "/var/log/$name" -o $USERNAME -g root -m750 install -d "/var/lib/$name" -o root -g root -m755 cd "/var/lib/$name" || die "Unable to cd \"/var/lib/$name\"" ln -s "../../log/$name" logs install -d temp -o $USERNAME -g root -m 755 cp -a "/var/lib/$SOURCE/shared" shared cp -a "/var/lib/$SOURCE/webapps" webapps ln -s "../../cache/$name" work cp -a "/var/lib/$SOURCE/conf" conf # change symlinks for file in server.xml web.xml \ jk2.properties workers2.properties workers.properties; do if [ -e "/etc/$name/$file" ]; then ln -sf "/etc/$name/$file" "conf/$file" fi done } create_usrshare() { local name="$1" install -d "/usr/share/$name" -o root -g root -m755 for dir in conf logs temp webapps work ; do ln -s "/var/lib/$name/$dir" "/usr/share/$name/$dir" done for dir in bin common docs server shared; do ln -s "/usr/share/$SOURCE/$dir" "/usr/share/$name/$dir" done } print_todo() { local name="$1" cat << EOF Automated cloning finished. Some items left todo: - change passwords in /var/lib/$name/conf/tomcat-users.xml - change shutdown password in /etc/$name/server.xml - change ports in /etc/$name/server.xml - remove any unwanted webapps from /var/lib/$name/conf/ Upon pressing return, an editor will start to allow you to do this EOF read dummy editor "/var/lib/$name/conf/tomcat-users.xml" "/etc/$name/server.xml" } main "$@"