[Lunar-commits] <moonbase> tomcat6-bin: Initial import

Stefan Wold ratler at lunar-linux.org
Fri Feb 12 22:47:08 CET 2010


commit afb39a0994105d0a84754fce5b897b5da9833b8d
Author: Stefan Wold <ratler at lunar-linux.org>
Date:   Fri Feb 12 22:47:08 2010 +0100

    tomcat6-bin: Initial import
---
 java/tomcat6-bin/BUILD                    |   23 ++++++
 java/tomcat6-bin/DEPENDS                  |    2 +
 java/tomcat6-bin/DETAILS                  |   13 +++
 java/tomcat6-bin/POST_INSTALL             |    3 +
 java/tomcat6-bin/tomcat6-install-instance |  118 +++++++++++++++++++++++++++++
 5 files changed, 159 insertions(+), 0 deletions(-)

diff --git a/java/tomcat6-bin/BUILD b/java/tomcat6-bin/BUILD
new file mode 100644
index 0000000..68c412b
--- /dev/null
+++ b/java/tomcat6-bin/BUILD
@@ -0,0 +1,23 @@
+(
+  TARGET=/usr/share/tomcat6/
+
+  # Cleaning up
+  rm -rf bin/*.exe bin/*.bat bin/*.tar.gz bin/jsvc-src &&
+
+  prepare_install &&
+
+  mkdir -p ${TARGET}/skel/
+  for i in bin lib; do
+    cp -r $i ${TARGET}/
+  done &&
+  for i in conf logs temp work webapps; do
+    cp -r $i ${TARGET}/skel/
+  done &&
+  mkdir -p ${TARGET}/skel/bin &&
+  chmod 0644 ${TARGET}/skel/conf/{*.xml,*.policy,*.properties} &&
+  chmod 755 ${TARGET}/skel/{work,temp,webapps,logs,conf} &&
+  install -m0755 ${SCRIPT_DIRECTORY}/tomcat6-install-instance /usr/bin/ &&
+
+  gather_docs LICENSE RUNNING.txt RELEASE-NOTES NOTICE
+
+) > $C_FIFO 2>&1
diff --git a/java/tomcat6-bin/DEPENDS b/java/tomcat6-bin/DEPENDS
new file mode 100644
index 0000000..8d337a3
--- /dev/null
+++ b/java/tomcat6-bin/DEPENDS
@@ -0,0 +1,2 @@
+depends %JAVA_SDK
+depends netcat
diff --git a/java/tomcat6-bin/DETAILS b/java/tomcat6-bin/DETAILS
new file mode 100644
index 0000000..28eacdb
--- /dev/null
+++ b/java/tomcat6-bin/DETAILS
@@ -0,0 +1,13 @@
+          MODULE=tomcat6-bin
+         VERSION=6.0.24
+          SOURCE=apache-tomcat-${VERSION}.tar.gz
+      SOURCE_URL=ftp://ftp.sunet.se/pub/www/servers/apache/dist/tomcat/tomcat-6/v${VERSION}/bin/
+SOURCE_DIRECTORY=$BUILD_DIRECTORY/apache-tomcat-$VERSION
+      SOURCE_VFY=sha256:02a5efe773cc2d79e025f96e3aeb747f46d1dd262d0d9b848b84e60d319e6ff6
+        WEB_SITE="http://tomcat.apache.org/"
+         ENTERED=20100212
+         UPDATED=20100212
+           SHORT="Servlet container for Java Servlet and JavaServer Pages"
+cat <<EOF
+Tomcat 6.0.x servlet container for Java Servlet and JavaServer Pages
+EOF
diff --git a/java/tomcat6-bin/POST_INSTALL b/java/tomcat6-bin/POST_INSTALL
new file mode 100644
index 0000000..0060912
--- /dev/null
+++ b/java/tomcat6-bin/POST_INSTALL
@@ -0,0 +1,3 @@
+
+message "Tomcat 6 is now installed. To setup a tomcat 6 instance"
+message "run the script /usr/bin/tomcat6-install-instance."
diff --git a/java/tomcat6-bin/tomcat6-install-instance b/java/tomcat6-bin/tomcat6-install-instance
new file mode 100755
index 0000000..73843aa
--- /dev/null
+++ b/java/tomcat6-bin/tomcat6-install-instance
@@ -0,0 +1,118 @@
+#!/bin/bash
+
+PROGRAM=$(basename $0)
+
+usage() {
+cat <<EOF
+Usage: $PROGRAM [options] <directory>
+  directory: Name of the directory to create for the tomcat instance
+
+Options:
+  -h        Display this help message
+  -p        HTTP port for tomcat instance to listen on, default 8080.
+  -c        Server shutdown control port to listen on, default 8005.
+  -a        AJP port to listen on, default 8009.
+EOF
+}
+
+main() {
+  TPORT=${TPORT:-8080}
+  CPORT=${CPORT:-8005}
+  APORT=${APORT:-8009}
+
+
+  if  [ "$TPORT" == "$CPORT" ] || [ "$CPORT" == "$APORT" ] || [ "$TPORT" == "$APORT" ]; then
+    echo "Error: Port numbers must be different for each listener"
+    exit 1
+  fi
+
+  check_port $TPORT "HTTP"
+  check_port $CPORT "Server control"
+  check_port $APORT "AJP connector"
+
+  targetdir=$1
+
+  mkdir -p ${targetdir}
+  FTARGET=$(cd ${targetdir}; pwd)
+  cp -r /usr/share/tomcat6/skel/* ${FTARGET}/
+
+  sed -i -e "s:Connector port=\"8080\":Connector port=\"${TPORT}\":; \
+             s:Server port=\"8005\" shutdown=\"SHUTDOWN\":Server port=\"${CPORT}\" shutdown=\"SHUTDOWN\":; \
+             s:Connector port=\"8009\":Connector port=\"${APORT}\":" ${FTARGET}/conf/server.xml
+
+  cat > ${FTARGET}/bin/startup.sh <<EOF
+#!/bin/bash
+export CATALINA_BASE=${FTARGET}
+/usr/share/tomcat6/bin/startup.sh
+EOF
+
+  cat > ${FTARGET}/bin/shutdown.sh <<EOF
+#!/bin/bash
+export CATALINA_BASE=${FTARGET}
+/usr/share/tomcat6/bin/shutdown.sh
+EOF
+
+chmod 755 ${FTARGET}/bin/{startup,shutdown}.sh
+
+  cat <<EOF
+* New Tomcat6 instance installed in ${FTARGET}
+* Run ${FTARGET}/bin/startup.sh to start your Tomcat6 instance
+EOF
+}
+
+check_port() {
+  port=$1
+  msg=$2
+
+  if nc localhost $port -z; then
+    echo "Error: Port already in use for: $msg $port"
+    exit 1
+  fi
+
+  if echo $port | egrep -q '^[0-9]+$'; then
+    if [ $port -gt 65535 ] || [ $port -lt 1024 ]; then
+      echo "Error: $msg port should be a number between 1024 - 65535"
+      exit 1
+    fi
+  else
+    echo "Error: $msg port should be a number!"
+    exit 1
+  fi
+}
+
+
+GETOPT_ARGS=$(getopt -n $PROGRAM -o "hp:c:a:" -- "$@")
+
+if [ $? -ne 0 ]; then
+  usage
+  exit
+else
+  eval set -- $GETOPT_ARGS
+
+  while true; do
+    case "$1" in
+      -h)
+        usage
+        exit
+        ;;
+      -p) export TPORT=$2; shift 2;;
+      -c) export CPORT=$2; shift 2;;
+      -a) export APORT=$2; shift 2;;
+      --) shift; break;;
+      *) usage; break;;
+    esac
+  done
+
+  if [ -z "$1" ]; then
+    echo "Error: Missing argument <directory>"
+    usage
+    exit 1
+  fi
+
+  if [ -d $1 ]; then
+    echo "Error: Target directory already exists."
+    exit 1
+  fi
+
+  main $@
+fi


More information about the Lunar-commits mailing list