OpenGrok revision d280c5e286f5b98be13237f52281ae5afdcf51b9
cd348e325366620fe047edcc849e3c9424828599Peter Bray#!/bin/sh
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco# OpenGrok Wrapper (initial setup and cron job updating)
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Operating Systems:
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Solaris 10 (SunOS 5.10)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OpenSolaris (SunOS 5.11)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Debian (Linux)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Deployment Engines
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Tomcat 6
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Glassfish
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Environment Variables :
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Environment Variables for configuring the default setup
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - EXUBERANT_CTAGS Full Path to Exuberant CTags
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - JAVA_HOME Full Path to Java Installation Root
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
cd348e325366620fe047edcc849e3c9424828599Peter Bray# Usage
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter BrayUsage()
cd348e325366620fe047edcc849e3c9424828599Peter Bray{
cd348e325366620fe047edcc849e3c9424828599Peter Bray echo 1>&2
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray echo "Usage: ${0} <deploy|update|updateQuietly|updateConfiguration|usage>" 1>&2
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray echo " ${0} index [<directory>]" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " Optional environment variables:" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " OPENGROK_CONFIGURATION - location of your configuartion" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo 1>&2
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco echo " See the code for more information on configuration options / variables" 1>&2
cd348e325366620fe047edcc849e3c9424828599Peter Bray echo 1>&2
cd348e325366620fe047edcc849e3c9424828599Peter Bray exit 1
cd348e325366620fe047edcc849e3c9424828599Peter Bray}
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Runtime Configuration
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayOS_NAME="`/bin/uname -s`"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayOS_VERSION="`/bin/uname -r`"
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray# TODO: Handle symlinks correctly (especially in ${0})
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter BraySCRIPT_DIRECTORY="`dirname ${0}`"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter BraySCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Default Instance Configuration
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayDefaultInstanceConfiguration()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Use the built-in defaults. This section can be copied to its own
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # file and tailored to your local requirements. Then simply set
cd348e325366620fe047edcc849e3c9424828599Peter Bray # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
cd348e325366620fe047edcc849e3c9424828599Peter Bray # this wrapper. It will save you hand editing in your settings
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # on each new release. A sample cron(1M) entry might look like:
cd348e325366620fe047edcc849e3c9424828599Peter Bray # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Note: It is not really possible to ever provided defaults for
cd348e325366620fe047edcc849e3c9424828599Peter Bray # these values which will run in every UNIX-like environment.
cd348e325366620fe047edcc849e3c9424828599Peter Bray # So I have provided a set which are functional for a given
cd348e325366620fe047edcc849e3c9424828599Peter Bray # environment on which you can based you own configuration.
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # This has been updated to support more environment variables and
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # operating systems, if you have any reasonably generic
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # improvements please feel free to submit a patch.
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONFIG_FILE="logging.properties"
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ -d "${SCRIPT_DIRECTORY}/dist" -a \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray -f "${SCRIPT_DIRECTORY}/dist/source.war" \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Handle Developer Build Environments
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/conf/${LOGGER_CONFIG_FILE}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray else
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Handle Binary Distributions
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/doc/${LOGGER_CONFIG_FILE}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
cd348e325366620fe047edcc849e3c9424828599Peter Bray fi
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # REQUIRED: Source Code/Repository Root
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (your source code or the root of all repositories)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SRC_ROOT="${OPENGROK_INSTANCE_BASE}/src"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # REQUIRED: OpenGrok Generate Data Root
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (for Lucene index and hypertext cross-references)
cd348e325366620fe047edcc849e3c9424828599Peter Bray # This area is rebuilt by "update" / "updateQuietly"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray DATA_ROOT="${OPENGROK_INSTANCE_BASE}/data"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (The user maintained source of the generated EftarFile file)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # REQUIRED: XML Configuration
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (the configuration used by Web/GUI interfaces)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # TODO: Verify that Logger Configuration is REQUIRED and not OPTIONAL
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # REQUIRED: Logger Configuration
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # REQUIRED: Java Archive of OpenGrok (Installation Location)
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # (user building from source code will find this and other key
cd348e325366620fe047edcc849e3c9424828599Peter Bray # files in the "dist" directory after the build is completed)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # REQUIRED: Exuberant CTags (http://ctags.sf.net)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # REQUIRED: Java Home
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray JAVA_HOME="${JAVA_HOME:-`FindJavaHome`}"
cd348e325366620fe047edcc849e3c9424828599Peter Bray export JAVA_HOME
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # REQUIRED: Java Virtual Machine
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray JAVA="${JAVA:-$JAVA_HOME/bin/java}"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Ignore these patterns as names of files or directories
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #IGNORE_PATTERNS="-i dummy"
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Enable Projects
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (Every directory in SRC_ROOT is considered a separate project)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ENABLE_PROJECTS="-P"
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # OPTIONAL: Scanning Options (for Mercurial repositories)
cd348e325366620fe047edcc849e3c9424828599Peter Bray SCAN_FOR_REPOSITORY="-S"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Remote Repository Support (CVS or SVN)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (Can be very time demanding, uncomment if needed)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #REMOTE_REPOSITORIES="-r on"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Allow Leading Wildcard Searches
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (default: off)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #LEADING_WILDCARD="-a on"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Web Site Look & Feel
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (Options: default, offwhite and polished.
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # Note the quoting requirements)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #SKIN='-L "default"'
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Increase Maximum Indexed Words Per File
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (default: 60000)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #MAX_INDEXED_WORDS="-m 100000"
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Configuration Address (host:port)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (conf/web.xml default is localhost:2424)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray WEBAPP_CONFIG_ADDRESS="-U localhost:2424"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: JVM Options
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #JAVA_OPTS="-server -Xmx1024m"
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # OPTIONAL: Full Path to History Utilities
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray HG="`Which hg`"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray CVS="`Which cvs`"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SVN="`Which svn`"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SCCS="`Which sccs`"
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
cd348e325366620fe047edcc849e3c9424828599Peter Bray # OPTIONAL: Override Built-in Properties
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Assumption: We should not set properties to the empty string
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray PROPERTIES="\
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Store The History Cache in Java DB (derby),
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # instead of file system (in gzipped xml files).
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # Requirements:
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # - derbyclient.jar - See README.txt for more details
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # - Running Derby Server - Defaults to localhost:1527
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #DERBY_HISTORY_CACHE=-D
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # DELIVERED: An update program for EftarFile
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Usage: <class> inputFile [inputFile ...] outputFile
cd348e325366620fe047edcc849e3c9424828599Peter Bray # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
cd348e325366620fe047edcc849e3c9424828599Peter Bray EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # HARDCODED: Generated EftarFile (See web/*.jsp)
cd348e325366620fe047edcc849e3c9424828599Peter Bray EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Be Quiet? (set indirectly by command line arguments in the main program)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #QUIET=""
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray # or alternatively, Be Verbose!
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #VERBOSE="-v"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Helper Functions - Logging
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# In general, non-interactive use like cron jobs and automated
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# installation environments should not generate unnecessary
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# progress information or warnings, as usage and configuration
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# will have generally been debugged prior to automation.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayProgress()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${@}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayWarning()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "WARNING: ${@}" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayError()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "ERROR: ${@}" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayFatalError()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "FATAL ERROR: ${@} - Aborting!" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${DO} exit 2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Helper Functions - Autodetection of Runtime Environment
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayWhich()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray path="`which ${1} 2>/dev/null`"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -x "${path}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${path}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayFindExuberantCTags()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray case "${OS_NAME}:${OS_VERSION}" in
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SunOS:5.10) commandName="" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SunOS:5.11) commandName="exctags" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Linux:*) commandName="ctags-exuberant" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray *) commandName="" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray esac
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${commandName}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Error "Unable to determine Exuberant CTags command name" \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray "for ${OS_NAME} ${OS_VERSION}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Which "${commandName}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayFindJavaHome()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray case "${OS_NAME}:${OS_VERSION}" in
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SunOS:5.11) javaHome="/usr/jdk/latest" ;;
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco Linux:*) javaHome="/usr/lib/jvm/java-6-sun" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray *) javaHome="" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray esac
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${javaHome}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Error "Unable to determine Java 6 Home" \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray "for ${OS_NAME} ${OS_VERSION}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ ! -d "${javaHome}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Error "Missing Java Home ${javaHome}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${javaHome}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayFindApplicationServerType()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Use this function to determine which environment the deploy the
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # web application function into. Some users (especially
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # developers) will have many deployment environments or will wish
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # to specify directly the application server to deploy to.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Either use the environment variable OPENGROK_APP_SERVER or
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # reimplement this function in your configuration file (as
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # specified by OPENGROK_CONFIGURATION)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -n "${OPENGROK_APP_SERVER}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${OPENGROK_APP_SERVER}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # This implementation favours Tomcat, but needs a lot of work,
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # especially if Glassfish is perferrerd or it is under the control
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # of SMF (Service Management Facility)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Maybe a better implementation would be to call Application
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Server specific WAR Directory and see if they exist.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -d "/var/tomcat6/webapps" \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray -o -d "/var/lib/tomcat6/webapps" \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "Tomcat"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "Glassfish"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Assume Tomcat
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "Tomcat"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayDetermineWarDirectoryTomcat()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${OPENGROK_WAR_TARGET_TOMCAT}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray elif [ -n "${OPENGROK_WAR_TARGET}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${OPENGROK_WAR_TARGET}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray for prefix in \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${OPENGROK_TOMCAT_BASE} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray /var/tomcat6 \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray /var/lib/tomcat6 \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray do
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -d "${prefix}/webapps" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${prefix}/webapps"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray done
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayDetermineWarDirectoryGlassfish()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${OPENGROK_WAR_TARGET_GLASSFISH}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray elif [ -n "${OPENGROK_WAR_TARGET}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${OPENGROK_WAR_TARGET}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray for prefix in \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${OPENGROK_GLASSFISH_BASE} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray /var/appserver \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray do
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -d "${prefix}/domains" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${domainDirectory}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray domainDirectory="${prefix}/domains"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray done
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${domainDirectory}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # User Specified Domain
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -n "${OPENGROK_GLASSFISH_DOMAIN}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ ! -d "${directory}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Specified Glassfish Domain ${OPENGROK_GLASSFISH_DOMAIN}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${directory}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray return
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Arbitrary Domain Selection
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray firstDomain=`ls -1 ${domainDirectory} | head -1`
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${firstDomain}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Failed to dynamically determine Glassfish Domain from ${domainDirectory}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${domainDirectory}/${firstDomain}/autodeploy"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Implementation
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
cd348e325366620fe047edcc849e3c9424828599Peter Bray# The variable "DO" can usefully be set to "echo" to aid in script debugging
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray#
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayLoadStandardEnvironment()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Setup a standard execution environment (if required)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-/pkgs/sbin/CronExecutionEnvironment.sh}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -f "${OPENGROK_STANDARD_ENV}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray . "${OPENGROK_STANDARD_ENV}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayLoadInstanceConfiguration()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Note: As all functions have been defined by the time this routine
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # is called, your configuration can, if desired, override functions
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # in addition to setting the variables mentioned in the function
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # DefaultInstanceConfiguration(), this maybe useful to override
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # functionality used to determine the default deployment environment
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # find dependencies or validate the configuration, for example.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Load the Local OpenGrok Configuration Environment
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Loading ${OPENGROK_CONFIGURATION} ..."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray . "${OPENGROK_CONFIGURATION}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray else
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Loading the default instance configuration ..."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray DefaultInstanceConfiguration
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayValidateConfiguration()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ ! -x "${EXUBERANT_CTAGS}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Dependent Application - Exuberant CTags"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ ! -d "${SRC_ROOT}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayCreateRuntimeRequirements()
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ ! -d "${DATA_ROOT}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Warning "OpenGrok Generated Data Path ${DATA_ROOT} doesn't exist"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " Attempting to create generated data directory ... "
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${DO} mkdir -p "${DATA_ROOT}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco if [ ! -d "${DATA_ROOT}" ]
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco then
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco FatalError "OpenGrok Data Path ${DATA_ROOT} doesn't exist"
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco fi
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco then
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco Warning "OpenGrok Generated Etc Path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist"
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco Progress " Attempting to create generated etc directory ... "
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco ${DO} mkdir -p "${OPENGROK_INSTANCE_BASE}/etc"
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco fi
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco then
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco FatalError "OpenGrok Etc Path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist"
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco fi
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco then
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ ! -f "${LOGGER_CONF_SOURCE}" ]
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray then
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray FatalError "Can't find distribution logging configuration"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray "(${LOGGER_CONF_SOURCE}) to install as default"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray "logging configuration (${LOGGER_CONFIG_PATH})"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray fi
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ${DO} cp "${LOGGER_CONF_SOURCE}" "${LOGGER_CONFIG_PATH}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # TODO: Consider automatically setting the logging directory
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # to within the instance base directory tree
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray}
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter BrayStdInvocation()
cd348e325366620fe047edcc849e3c9424828599Peter Bray{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ${LOGGER_PROPERTIES} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray -jar ${OPENGROK_JAR} \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ${IGNORE_PATTERNS} ${ENABLE_PROJECTS} \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ${DERBY_HISTORY_CACHE} \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ${SCAN_FOR_REPOSITORY} ${REMOTE_REPOSITORIES} \
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco ${VERBOSE} ${QUIET} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ${MAX_INDEXED_WORDS} ${SKIN} ${LEADING_WILDCARD} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray -s ${SRC_ROOT} -d ${DATA_ROOT} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray "${@}"
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco#? -R ${XML_CONFIGURATION} \
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco
cd348e325366620fe047edcc849e3c9424828599Peter Bray}
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter BrayUpdateGeneratedConfiguration()
cd348e325366620fe047edcc849e3c9424828599Peter Bray{
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray StdInvocation -W ${XML_CONFIGURATION} ${WEBAPP_CONFIG_ADDRESS}
cd348e325366620fe047edcc849e3c9424828599Peter Bray}
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter BrayUpdateGeneratedData()
cd348e325366620fe047edcc849e3c9424828599Peter Bray{
cd348e325366620fe047edcc849e3c9424828599Peter Bray StdInvocation -H
cd348e325366620fe047edcc849e3c9424828599Peter Bray}
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter BrayUpdateDescriptionCache()
cd348e325366620fe047edcc849e3c9424828599Peter Bray{
cd348e325366620fe047edcc849e3c9424828599Peter Bray # OPTIONAL : Update the EftarFile data
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ]
cd348e325366620fe047edcc849e3c9424828599Peter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
cd348e325366620fe047edcc849e3c9424828599Peter Bray fi
cd348e325366620fe047edcc849e3c9424828599Peter Bray}
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter BrayOpenGrokUsage()
cd348e325366620fe047edcc849e3c9424828599Peter Bray{
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray echo "Options for opengrok.jar:" 1>&2
cd348e325366620fe047edcc849e3c9424828599Peter Bray ${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?'
cd348e325366620fe047edcc849e3c9424828599Peter Bray}
cd348e325366620fe047edcc849e3c9424828599Peter Bray
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos KoscoDeployWar()
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco{
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray applicationServer="`FindApplicationServerType`"
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray case "${applicationServer}" in
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray *) FatalError "Unsupported Application Server ${applicationServer}" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray esac
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -z "${warTarget}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Unable to determine Deployment Directory for ${applicationServer}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ ! -f "${OPENGROK_DIST_WAR}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ ! -d "${warTarget}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Deployment Directory ${warTarget}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${DO} cp "${OPENGROK_DIST_WAR}" "${warTarget}/"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ $? != 0 ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Web Application Installation FAILED"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray fi
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Start your application server (${applicationServer}), if it is not already"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "running, or wait until it loads the just installed web application."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "OpenGrok should be available on <HOST>:<PORT>/source"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " where HOST and PORT are configured in ${applicationServer}."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco}
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
cd348e325366620fe047edcc849e3c9424828599Peter Bray# Main Program
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
cd348e325366620fe047edcc849e3c9424828599Peter Bray
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Koscoif [ $# -eq 0 -o $# -gt 2 ]
cd348e325366620fe047edcc849e3c9424828599Peter Braythen
cd348e325366620fe047edcc849e3c9424828599Peter Bray Usage
cd348e325366620fe047edcc849e3c9424828599Peter Brayfi
cd348e325366620fe047edcc849e3c9424828599Peter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayLoadStandardEnvironment
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
d2a02e104622a26dd90fa88f4f17188f2039809fPeter BrayLoadInstanceConfiguration
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Braycase "${1}" in
cd348e325366620fe047edcc849e3c9424828599Peter Bray
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco deploy)
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco DeployWar
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco ;;
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco
cd348e325366620fe047edcc849e3c9424828599Peter Bray update)
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco ValidateConfiguration
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco CreateRuntimeRequirements
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray UpdateGeneratedData
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray UpdateDescriptionCache
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ;;
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray updateQuietly)
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco ValidateConfiguration
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco CreateRuntimeRequirements
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray QUIET="-q"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray VERBOSE=""
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray UpdateGeneratedData
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray UpdateDescriptionCache
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ;;
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray updateConfiguration)
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco ValidateConfiguration
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco CreateRuntimeRequirements
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco UpdateGeneratedConfiguration
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco ;;
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco index)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ -n "${2}" ]
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray then
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray SRC_ROOT="${2}"
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco fi
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco ValidateConfiguration
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco CreateRuntimeRequirements
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray UpdateGeneratedConfiguration
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco UpdateGeneratedData
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco UpdateDescriptionCache
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ;;
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray usage)
cd348e325366620fe047edcc849e3c9424828599Peter Bray OpenGrokUsage
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco Usage
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ;;
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray *)
cd348e325366620fe047edcc849e3c9424828599Peter Bray Usage
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ;;
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Brayesac
cd348e325366620fe047edcc849e3c9424828599Peter Bray
cd348e325366620fe047edcc849e3c9424828599Peter Bray#
cd348e325366620fe047edcc849e3c9424828599Peter Bray# End of File
cd348e325366620fe047edcc849e3c9424828599Peter Bray#