This page explains how to install a tomcat servlet container into an existing ubuntu image.
First you have to mount the image as described here:
losetup /dev/loop5 root.img Also you should use the chroot command.
mount /dev/loop5 temp-mnt
Afterwards you have to download a JDK and the tomcat into the image's /opt folder.
Install the JDK as described in the install instructions and set the JAVA_HOME environment variable:
Create a file in the image's folder "/etc/profile.d/" named "java_env.sh": containing:#!/bin/bash -l
export JAVA_HOME="/opt/java/jre1.6.0_18"
Now you have to extract the tomcat
tar xvzf apache-tomcat* and create a file "tomcat" in "/etc/init.d/" containing the following: # Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
export JAVA_HOME=/opt/java/jre1.6.0_18
case $1 in
start)
sh /opt/tomcat/apache-tomcat-5.5.28/bin/startup.sh
;;
stop)
sh /opt/tomcat/apache-tomcat-5.5.28/bin/shutdown.sh
;;
restart)
sh /opt/tomcat/apache-tomcat-5.5.28/bin/shutdown.sh
sh /opt/tomcat/apache-tomcat-5.5.28/bin/startup.sh
;;
esac
exit 0
and make the script executable by running:sudo chmod 755 /etc/init.d/tomcat
Now linking the script with the startup folders:sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat
Finnally umount the image, umount /dev/loop5upload and register it.
losetup -d /dev/loop5