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