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