[Lunar-commits] <moonbase> tomcat7-bin: Initial import
Stefan Wold
ratler at lunar-linux.org
Sat Aug 13 15:53:08 CEST 2011
commit 54ade37ac52c1903427bf45dd05ba891248b146d
Author: Stefan Wold <ratler at lunar-linux.org>
Date: Sat Aug 13 15:53:08 2011 +0200
tomcat7-bin: Initial import
---
java/tomcat7-bin/BUILD | 24 ++++++
java/tomcat7-bin/DEPENDS | 2 +
java/tomcat7-bin/DETAILS | 14 ++++
java/tomcat7-bin/POST_INSTALL | 3 +
java/tomcat7-bin/tomcat7-install-instance | 118 +++++++++++++++++++++++++++++
5 files changed, 161 insertions(+), 0 deletions(-)
diff --git a/java/tomcat7-bin/BUILD b/java/tomcat7-bin/BUILD
new file mode 100644
index 0000000..ba63846
--- /dev/null
+++ b/java/tomcat7-bin/BUILD
@@ -0,0 +1,24 @@
+(
+
+ TARGET=/usr/share/tomcat7/
+
+ # 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}/tomcat7-install-instance /usr/bin/ &&
+
+ gather_docs LICENSE RUNNING.txt RELEASE-NOTES NOTICE
+
+) > $C_FIFO 2>&1
diff --git a/java/tomcat7-bin/DEPENDS b/java/tomcat7-bin/DEPENDS
new file mode 100644
index 0000000..8d337a3
--- /dev/null
+++ b/java/tomcat7-bin/DEPENDS
@@ -0,0 +1,2 @@
+depends %JAVA_SDK
+depends netcat
diff --git a/java/tomcat7-bin/DETAILS b/java/tomcat7-bin/DETAILS
new file mode 100644
index 0000000..ddb0c8a
--- /dev/null
+++ b/java/tomcat7-bin/DETAILS
@@ -0,0 +1,14 @@
+ MODULE=tomcat7-bin
+ VERSION=7.0.19
+ SOURCE=apache-tomcat-$VERSION.tar.gz
+ SOURCE_URL=ftp://ftp.sunet.se/pub/www/servers/apache/dist/tomcat/tomcat-7/v${VERSION}/bin
+SOURCE_DIRECTORY=$BUILD_DIRECTORY/apache-tomcat-$VERSION
+ SOURCE_VFY=sha256:d2d9fb328ad1d5a33288ce1d4369326050b4ed79343d6dc03283d6f7a9215207
+ WEB_SITE=http://tomcat.apache.org/
+ ENTERED=20110813
+ UPDATED=20110813
+ SHORT="Servlet container for Java Servlet and JavaServer Pages"
+
+cat <<EOF
+Tomcat 7.0.x servlet container for Java Servlet and JavaServer Pages
+EOF
diff --git a/java/tomcat7-bin/POST_INSTALL b/java/tomcat7-bin/POST_INSTALL
new file mode 100644
index 0000000..8bad3fd
--- /dev/null
+++ b/java/tomcat7-bin/POST_INSTALL
@@ -0,0 +1,3 @@
+
+message "Tomcat 7 is now installed. To setup a tomcat 7 instance"
+message "run the script /usr/bin/tomcat7-install-instance."
diff --git a/java/tomcat7-bin/tomcat7-install-instance b/java/tomcat7-bin/tomcat7-install-instance
new file mode 100755
index 0000000..5af814f
--- /dev/null
+++ b/java/tomcat7-bin/tomcat7-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/tomcat7/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/tomcat7/bin/startup.sh
+EOF
+
+ cat > ${FTARGET}/bin/shutdown.sh <<EOF
+#!/bin/bash
+export CATALINA_BASE=${FTARGET}
+/usr/share/tomcat7/bin/shutdown.sh
+EOF
+
+chmod 755 ${FTARGET}/bin/{startup,shutdown}.sh
+
+ cat <<EOF
+* New Tomcat7 instance installed in ${FTARGET}
+* Run ${FTARGET}/bin/startup.sh to start your Tomcat7 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