OpenGrok revision 979
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainen#!/bin/sh
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# OpenGrok Wrapper (initial setup and cron job updating)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Supported Operating Systems:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - Solaris 10 (SunOS 5.10)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - OpenSolaris (SunOS 5.11)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - Debian (Linux)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Supported Deployment Engines:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - Tomcat 6
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - Tomcat 5.5
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - Glassfish
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen# Supported Environment Variables:
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
40a5aeebf6b4858b93f0ddff0bf12fba769cf903Timo Sirainen#
40a5aeebf6b4858b93f0ddff0bf12fba769cf903Timo Sirainen# Supported Environment Variables for configuring the default setup:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - EXUBERANT_CTAGS Full Path to Exuberant CTags
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - JAVA_HOME Full Path to Java Installation Root
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_REMOTE_REPOS Disable History Cache for (remote) Repositories (*)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)_
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen#
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - READ_XML_CONFIGURATION file with read only configuration - a temp workaround for bug # 327
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen#
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# Notes:
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# (*) Any Non-Empty String will enable these options
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen#
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen#
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# Usage
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen#
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo SirainenUsage()
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen{
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen echo 1>&2
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen echo "Usage: ${0} <deploy|update|updateQuietly|usage>" 1>&2
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen echo " ${0} index [<directory>]" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo " Optional environment variables:" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo " OPENGROK_CONFIGURATION - location of your configuration" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo " See the code for more information on configuration options / variables" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen exit 1
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Runtime Configuration
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenOS_NAME="`/bin/uname -s`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenOS_VERSION="`/bin/uname -r`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# TODO: Handle symlinks correctly (especially in ${0})
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenSCRIPT_DIRECTORY="`dirname ${0}`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenSCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Default Instance Configuration
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenDefaultInstanceConfiguration()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Use the built-in defaults. This section can be copied to its own
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # file and tailored to your local requirements. Then simply set
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # this wrapper. It will save you hand editing in your settings
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # on each new release. A sample cron(1M) entry might look like:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Note: It is not really possible to ever provided defaults for
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # these values which will run in every UNIX-like environment.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # So I have provided a set which are functional for a given
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # environment on which you can based you own configuration.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # This has been updated to support more environment variables and
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # operating systems, if you have any reasonably generic
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # improvements please feel free to submit a patch.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_CONFIG_FILE="logging.properties"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -d "${SCRIPT_DIRECTORY}/dist" -a \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen -f "${SCRIPT_DIRECTORY}/dist/source.war" \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Handle Developer Build Environments
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen else
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Handle Binary Distributions
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/${LOGGER_CONFIG_FILE}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED: Source Code/Repository Root
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (your source code or the root of all repositories)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen SRC_ROOT="${OPENGROK_INSTANCE_BASE}/src"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED: OpenGrok Generate Data Root
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (for Lucene index and hypertext cross-references)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # This area is rebuilt by "update" / "updateQuietly"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen DATA_ROOT="${OPENGROK_INSTANCE_BASE}/data"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (The user maintained source of the generated EftarFile file)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED: XML Configuration
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (the configuration used by Web/GUI interfaces)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: read only XML config, if it exists, it will be read
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -f "${READ_XML_CONFIGURATION}" ] ; then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen READ_XML_CONF="-R ${READ_XML_CONFIGURATION}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED: Logger Configuration
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED: Java Archive of OpenGrok (Installation Location)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (user building from source code will find this and other key
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # files in the "dist" directory after the build is completed)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen # REQUIRED: Exuberant CTags (http://ctags.sf.net)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED: Java Home
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen JAVA_HOME="${JAVA_HOME:-`FindJavaHome`}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen export JAVA_HOME
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED: Java Virtual Machine
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen JAVA="${JAVA:-$JAVA_HOME/bin/java}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen # DEVELOPMENT: Debug option, if enabled current indexer will listen on the port 8010 until a debugger connects
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,address=8010,suspend=y"
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Ignore these patterns as names of files or directories
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #IGNORE_PATTERNS="-i dummy"
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Enable Projects
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (Every directory in SRC_ROOT is considered a separate project)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen ENABLE_PROJECTS="-P"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Scanning Options (for Mercurial repositories)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen SCAN_FOR_REPOSITORY="-S"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ ! -z "${OPENGROK_SCAN_REPOS}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen SCAN_FOR_REPOSITORY=""
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Remote Repository Support (CVS or SVN)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (Can be very time demanding, uncomment if needed)
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen REMOTE_REPOSITORIES="-r on"
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen if [ ! -z "${OPENGROK_REMOTE_REPOS}" ]
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen then
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen REMOTE_REPOSITORIES=""
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen fi
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen # OPTIONAL: Allow Leading Wildcard Searches
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen # (default: off)
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen #LEADING_WILDCARD="-a on"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Web Site Look & Feel
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (Options: default, offwhite and polished.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Note the quoting requirements)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #SKIN='-L "default"'
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen # OPTIONAL: Set Maximum Indexed Words Per File
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen # Note, that you might run out of memory, then either increase JVM memory
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # as noted in JAVA_OPTS, or set this limit(if you don't mind opengrok not
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # indexing the rest of the file, once the limit is reached)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (default: unlimited)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #MAX_INDEXED_WORDS="-m 100000"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Configuration Address (host:port)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (conf/web.xml default is localhost:2424)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen WEBAPP_CONFIG_ADDRESS="-U localhost:2424"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: JVM Options
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #JAVA_OPTS="-server -Xmx2048m"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen JAVA_OPTS="-Xmx2048m"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Full Path to History Utilities
8e361d2906b0e44f7175a20981f8d2280645b58bTimo Sirainen HG="`Which hg`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen CVS="`Which cvs`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen SVN="`Which svn`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen SCCS="`Which sccs`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen CLEARCASE="`Which cleartool`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen GIT="`Which git`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen P4="`Which p4`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen MTN="`Which mtn`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen BZR="`Which bzr`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Override Built-in Properties
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Assumption: We should not set properties to the empty string
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen PROPERTIES="\
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Store The History Cache in Java DB (derby),
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # instead of file system (in gzipped xml files).
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Requirements:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # - derbyclient.jar - See README.txt for more details
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # - Running Derby Server - Defaults to localhost:1527
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #DERBY_HISTORY_CACHE=-D
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # DELIVERED: An update program for EftarFile
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Usage: <class> inputFile [inputFile ...] outputFile
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
3281669db44d09a087a203201248abbc81b3cc1aTimo Sirainen
8e361d2906b0e44f7175a20981f8d2280645b58bTimo Sirainen # HARDCODED: Generated EftarFile (See web/*.jsp)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Be Quiet? (set indirectly by command line arguments in the main program)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #QUIET=""
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # or alternatively, Be Verbose!
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen #VERBOSE="-v"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ ! -z "${OPENGROK_VERBOSE}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen VERBOSE="-v"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen QUIET=""
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Helper Functions - Logging
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# In general, non-interactive use like cron jobs and automated
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# installation environments should not generate unnecessary
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# progress information or warnings, as usage and configuration
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# will have generally been debugged prior to automation.
8e361d2906b0e44f7175a20981f8d2280645b58bTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenProgress()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "${@}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenWarning()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "WARNING: ${@}" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenError()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "ERROR: ${@}" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenFatalError()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "FATAL ERROR: ${@} - Aborting!" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen ${DO} exit 2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Helper Functions - Autodetection of Runtime Environment
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen#
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenWhich()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen path="`which ${1} 2>/dev/null`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -x "${path}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "${path}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen}
fad068d459cc7b04fedade4e0bb343be62e6d310Timo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenFindExuberantCTags()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen case "${OS_NAME}:${OS_VERSION}" in
fad068d459cc7b04fedade4e0bb343be62e6d310Timo Sirainen SunOS:5.10) commandName="" ;;
fad068d459cc7b04fedade4e0bb343be62e6d310Timo Sirainen SunOS:5.11) commandName="exctags" ;;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen Linux:*) commandName="ctags-exuberant" ;;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen *) commandName="" ;;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen esac
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen if [ -z "${commandName}" ]
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen then
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen Error "Unable to determine Exuberant CTags command name" \
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen "for ${OS_NAME} ${OS_VERSION}"
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen return
fad068d459cc7b04fedade4e0bb343be62e6d310Timo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen Which "${commandName}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenFindJavaHome()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen case "${OS_NAME}:${OS_VERSION}" in
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen SunOS:5.11) javaHome="/usr/jdk/latest" ;;
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen Linux:*) javaHome="/usr/lib/jvm/java-6-sun" ;;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen *) javaHome="" ;;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen esac
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen if [ -z "${javaHome}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen Error "Unable to determine Java 6 Home" \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen "for ${OS_NAME} ${OS_VERSION}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ ! -d "${javaHome}" ]
fad068d459cc7b04fedade4e0bb343be62e6d310Timo Sirainen then
fad068d459cc7b04fedade4e0bb343be62e6d310Timo Sirainen Error "Missing Java Home ${javaHome}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "${javaHome}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
fad068d459cc7b04fedade4e0bb343be62e6d310Timo Sirainen
fad068d459cc7b04fedade4e0bb343be62e6d310Timo SirainenFindApplicationServerType()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen # Use this function to determine which environment the deploy the
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # web application function into. Some users (especially
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # developers) will have many deployment environments or will wish
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # to specify directly the application server to deploy to.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Either use the environment variable OPENGROK_APP_SERVER or
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # reimplement this function in your configuration file (as
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # specified by OPENGROK_CONFIGURATION)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -n "${OPENGROK_APP_SERVER}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen echo "${OPENGROK_APP_SERVER}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # This implementation favours Tomcat, but needs a lot of work,
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # especially if Glassfish is perferrerd or it is under the control
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # of SMF (Service Management Facility)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen # Maybe a better implementation would be to call Application
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen # Server specific WAR Directory and see if they exist.
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen if [ -d "/var/tomcat6/webapps" \
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen -o -d "/var/lib/tomcat6/webapps" \
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen -o -d "/var/lib/tomcat5.5/webapps" \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "Tomcat"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
de9d79337eca11a7f9c1cd476c74dfe4f09a4bd7Timo Sirainen echo "Glassfish"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
de9d79337eca11a7f9c1cd476c74dfe4f09a4bd7Timo Sirainen fi
de9d79337eca11a7f9c1cd476c74dfe4f09a4bd7Timo Sirainen
de9d79337eca11a7f9c1cd476c74dfe4f09a4bd7Timo Sirainen # Assume Tomcat
d1baa8c6f97cdb1b3c2c44a73cc21f9dfc7a963fTimo Sirainen echo "Tomcat"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen}
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo SirainenDetermineWarDirectoryTomcat()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "${OPENGROK_WAR_TARGET_TOMCAT}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen elif [ -n "${OPENGROK_WAR_TARGET}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "${OPENGROK_WAR_TARGET}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen for prefix in \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen ${OPENGROK_TOMCAT_BASE} \
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen /var/tomcat6 \
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen /var/lib/tomcat6 \
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen /var/lib/tomcat5.5 \
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen
ad48319996942463675b53877092ab7e13a7a75aTimo Sirainen do
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -d "${prefix}/webapps" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "${prefix}/webapps"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen done
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen}
0c909e3461607eadcd66f4eac69b7f34e37fccf1Timo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenDetermineWarDirectoryGlassfish()
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen{
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ]
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo "${OPENGROK_WAR_TARGET_GLASSFISH}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen return
651fc0f1e43fef3e02e0e7b5f498973b05f641d7Timo Sirainen elif [ -n "${OPENGROK_WAR_TARGET}" ]
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen then
651fc0f1e43fef3e02e0e7b5f498973b05f641d7Timo Sirainen echo "${OPENGROK_WAR_TARGET}"
651fc0f1e43fef3e02e0e7b5f498973b05f641d7Timo Sirainen return
651fc0f1e43fef3e02e0e7b5f498973b05f641d7Timo Sirainen fi
651fc0f1e43fef3e02e0e7b5f498973b05f641d7Timo Sirainen
651fc0f1e43fef3e02e0e7b5f498973b05f641d7Timo Sirainen for prefix in \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen ${OPENGROK_GLASSFISH_BASE} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen /var/appserver \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen do
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -d "${prefix}/domains" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen if [ -z "${domainDirectory}" ]
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen then
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen domainDirectory="${prefix}/domains"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen fi
fi
done
if [ -z "${domainDirectory}" ]
then
return
fi
# User Specified Domain
if [ -n "${OPENGROK_GLASSFISH_DOMAIN}" ]
then
directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
if [ ! -d "${directory}" ]
then
FatalError "Missing Specified Glassfish Domain ${OPENGROK_GLASSFISH_DOMAIN}"
fi
echo "${directory}"
return
fi
# Arbitrary Domain Selection
firstDomain=`ls -1 ${domainDirectory} | head -1`
if [ -z "${firstDomain}" ]
then
FatalError "Failed to dynamically determine Glassfish Domain from ${domainDirectory}"
fi
echo "${domainDirectory}/${firstDomain}/autodeploy"
}
#
# Implementation
#
# The variable "DO" can usefully be set to "echo" to aid in script debugging
#
LoadStandardEnvironment()
{
# Setup a standard execution environment (if required)
OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-/pkgs/sbin/CronExecutionEnvironment.sh}"
if [ -f "${OPENGROK_STANDARD_ENV}" ]
then
Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
. "${OPENGROK_STANDARD_ENV}"
fi
}
LoadInstanceConfiguration()
{
# Note: As all functions have been defined by the time this routine
# is called, your configuration can, if desired, override functions
# in addition to setting the variables mentioned in the function
# DefaultInstanceConfiguration(), this maybe useful to override
# functionality used to determine the default deployment environment
# find dependencies or validate the configuration, for example.
if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
then
# Load the Local OpenGrok Configuration Environment
Progress "Loading ${OPENGROK_CONFIGURATION} ..."
. "${OPENGROK_CONFIGURATION}"
else
Progress "Loading the default instance configuration ..."
DefaultInstanceConfiguration
fi
}
ValidateConfiguration()
{
if [ ! -x "${EXUBERANT_CTAGS}" ]
then
FatalError "Missing Dependent Application - Exuberant CTags"
fi
if [ ! -d "${SRC_ROOT}" ]
then
FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
fi
if [ -n "${QUIET}" -a -n "${VERBOSE}" ]
then
Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose"
QUIET=""
VERBOSE="-v"
fi
}
CreateRuntimeRequirements()
{
if [ ! -d "${DATA_ROOT}" ]
then
Warning "OpenGrok Generated Data Path ${DATA_ROOT} doesn't exist"
Progress " Attempting to create generated data directory ... "
${DO} mkdir -p "${DATA_ROOT}"
fi
if [ ! -d "${DATA_ROOT}" ]
then
FatalError "OpenGrok Data Path ${DATA_ROOT} doesn't exist"
fi
if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
then
Warning "OpenGrok Generated Etc Path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist"
Progress " Attempting to create generated etc directory ... "
${DO} mkdir -p "${OPENGROK_INSTANCE_BASE}/etc"
fi
if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
then
FatalError "OpenGrok Etc Path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist"
fi
if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
then
Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
if [ ! -f "${LOGGER_CONF_SOURCE}" ]
then
Warning "Can't find distribution logging configuration" \
"(${LOGGER_CONF_SOURCE}) to install as default" \
"logging configuration (${LOGGER_CONFIG_PATH})"
else
${DO} grep -v java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
${DO} grep java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" | sed "s|opengrok%g.%u.log|${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log|g" >> "${LOGGER_CONFIG_PATH}"
${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log
fi
fi
}
StdInvocation()
{
${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
${LOGGER_PROPERTIES} \
${JAVA_DEBUG} \
-jar ${OPENGROK_JAR} \
${IGNORE_PATTERNS} ${ENABLE_PROJECTS} \
${DERBY_HISTORY_CACHE} \
${SCAN_FOR_REPOSITORY} ${REMOTE_REPOSITORIES} \
${VERBOSE} ${QUIET} \
${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
${MAX_INDEXED_WORDS} ${SKIN} ${LEADING_WILDCARD} \
${READ_XML_CONF} \
-W ${XML_CONFIGURATION} \
${WEBAPP_CONFIG_ADDRESS} \
-s ${SRC_ROOT} -d ${DATA_ROOT} \
"${@}"
}
UpdateGeneratedData()
{
StdInvocation -H
}
UpdateDescriptionCache()
{
# OPTIONAL : Update the EftarFile data
if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ]
then
${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
fi
}
OpenGrokUsage()
{
echo "Options for opengrok.jar:" 1>&2
${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?'
}
DeployWar()
{
applicationServer="`FindApplicationServerType`"
case "${applicationServer}" in
Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
*) FatalError "Unsupported Application Server ${applicationServer}" ;;
esac
if [ -z "${warTarget}" ]
then
FatalError "Unable to determine Deployment Directory for ${applicationServer}"
fi
if [ ! -f "${OPENGROK_DIST_WAR}" ]
then
FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
fi
if [ ! -d "${warTarget}" ]
then
FatalError "Missing Deployment Directory ${warTarget}"
fi
Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
${DO} cp "${OPENGROK_DIST_WAR}" "${warTarget}/"
if [ $? != 0 ]
then
FatalError "Web Application Installation FAILED"
fi
Progress
Progress "Start your application server (${applicationServer}), if it is not already"
Progress "running, or wait until it loads the just installed web application."
Progress
Progress "OpenGrok should be available on <HOST>:<PORT>/source"
Progress " where HOST and PORT are configured in ${applicationServer}."
Progress
}
#
# Main Program
#
if [ $# -eq 0 -o $# -gt 2 ]
then
Usage
fi
LoadStandardEnvironment
LoadInstanceConfiguration
case "${1}" in
deploy)
DeployWar
;;
update)
ValidateConfiguration
CreateRuntimeRequirements
UpdateGeneratedData
UpdateDescriptionCache
;;
updateQuietly)
ValidateConfiguration
CreateRuntimeRequirements
QUIET="-q"
VERBOSE=""
UpdateGeneratedData
UpdateDescriptionCache
;;
index)
if [ -n "${2}" ]
then
SRC_ROOT="${2}"
fi
ValidateConfiguration
CreateRuntimeRequirements
UpdateGeneratedData
UpdateDescriptionCache
;;
usage)
OpenGrokUsage
Usage
;;
*)
Usage
;;
esac
#
# End of File
#