OpenGrok revision 070831b2d3388c718b383d89fa2fd279c02f5798
0N/A#!/bin/sh
0N/A#
0N/A# OpenGrok Wrapper (initial setup and cron job updating)
0N/A#
0N/A# Supported Operating Systems:
0N/A# - Solaris 10 (SunOS 5.10)
0N/A# - Solaris 11 (SunOS 5.11)
0N/A# - Debian (Linux)
0N/A#
0N/A# Supported Deployment Engines:
0N/A# - Tomcat 6
0N/A# - Tomcat 5.5
0N/A# - Glassfish
0N/A#
0N/A# Supported Environment Variables:
0N/A# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
0N/A# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
0N/A# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
0N/A#
0N/A# Supported Environment Variables for configuring the default setup:
119N/A# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
0N/A# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
0N/A# - EXUBERANT_CTAGS Full Path to Exuberant CTags
0N/A# - JAVA_HOME Full Path to Java Installation Root
65N/A# - JAVA Full Path to java binary
125N/A# - JAVA_OPTS Java options
125N/A# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
125N/A# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
125N/A# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
58N/A# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
77N/A# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
125N/A# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish
125N/A# (contains domains)
125N/A# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
125N/A# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
261N/A# - OPENGROK_PROGRESS Shows progress in %(percentage) of working
261N/A# through project, it's good to have Verbose
312N/A# Mode enabled too, cost of this is one more
312N/A# traversal of the project before indexing it(*)
428N/A# - OPENGROK_REMOTE_REPOS Disable History Cache for (remote)
126N/A# Repositories (*)
58N/A# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)
394N/A# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go
8N/A# (by default 3 directories from SRC_ROOT)
77N/A# - OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to
0N/A# (use "none" to avoid sending it to web app)
0N/A# - OPENGROK_WPREFIX Disable wildcard prefix search query
0N/A# support (*)
0N/A# - OPENGROK_DERBY if set, then indexer tries to use derby as
0N/A# historycache (see derby command of this
0N/A# script)
434N/A# - READ_XML_CONFIGURATION file with read only configuration
439N/A# - temporary workaround for bug # 327
312N/A#
465N/A# Notes:
465N/A# (*) Any Non-Empty String will enable these options
465N/A#
312N/A
320N/A#
312N/A# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
312N/A#
312N/A#
312N/A# Print usage to stderr and exit.
65N/A#
65N/AUsage()
65N/A{
65N/A progname=`basename $0`
464N/A
0N/A exec >&2
30N/A echo 1>&2
58N/A echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage>" 1>&2
312N/A echo " ${progname} index [<directory>]" 1>&2
312N/A echo 1>&2
260N/A echo " Optional environment variables:" 1>&2
112N/A echo " OPENGROK_CONFIGURATION - location of your configuration" 1>&2
428N/A echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
376N/A echo 1>&2
376N/A echo " See the code for more information on configuration options /" \
0N/A "variables" 1>&2
11N/A echo 1>&2
0N/A exit 1
240N/A}
58N/A
58N/A#
58N/A# Runtime Configuration
58N/A#
77N/Aif [ -f "/bin/uname" ]
207N/Athen
207N/A OS_NAME="`/bin/uname -s`"
261N/A OS_VERSION="`/bin/uname -r`"
260N/Aelse
77N/A OS_NAME="`/usr/bin/uname -s`"
260N/A OS_VERSION="`/usr/bin/uname -r`"
112N/Afi
77N/A
77N/A# TODO: Handle symlinks correctly (especially in ${0})
77N/ASCRIPT_DIRECTORY="`dirname ${0}`"
77N/ASCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
260N/A
77N/A#
77N/A# Default Instance Configuration
77N/A#
0N/A
77N/ADefaultInstanceConfiguration()
111N/A{
111N/A # Use the built-in defaults. This section can be copied to its own
111N/A # file and tailored to your local requirements. Then simply set
111N/A # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
111N/A # this wrapper. It will save you hand editing in your settings
111N/A # on each new release. A sample cron(1M) entry might look like:
111N/A # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
111N/A
111N/A # Note: It is not really possible to ever provided defaults for
111N/A # these values which will run in every UNIX-like environment.
111N/A # So I have provided a set which are functional for a given
111N/A # environment on which you can based you own configuration.
77N/A
77N/A # This has been updated to support more environment variables and
77N/A # operating systems, if you have any reasonably generic
207N/A # improvements please feel free to submit a patch.
207N/A
77N/A OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
77N/A
99N/A LOGGER_CONFIG_FILE="logging.properties"
77N/A
77N/A if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
77N/A then
77N/A if [ -d "${SCRIPT_DIRECTORY}/dist" -a \
77N/A -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
77N/A -f "${SCRIPT_DIRECTORY}/dist/source.war" \
464N/A ]
77N/A then
77N/A # Handle Developer Build Environments
77N/A OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
77N/A LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
77N/A else
77N/A # Handle Binary Distributions
77N/A OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
77N/A LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/"
77N/A LOGGER_CONF_SOURCE="${LOGGER_CONF_SOURCE}${LOGGER_CONFIG_FILE}"
77N/A fi
77N/A fi
111N/A
111N/A # REQUIRED: Source Code/Repository Root
77N/A # (your source code or the root of all repositories)
77N/A SRC_ROOT="${OPENGROK_INSTANCE_BASE}/src"
77N/A
240N/A # REQUIRED: OpenGrok Generate Data Root
173N/A # (for Lucene index and hypertext cross-references)
465N/A # This area is rebuilt by "update" / "updateQuietly"
173N/A DATA_ROOT="${OPENGROK_INSTANCE_BASE}/data"
465N/A
254N/A # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
173N/A # (The user maintained source of the generated EftarFile file)
173N/A PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
173N/A
254N/A # REQUIRED: XML Configuration
173N/A # (the configuration used by Web/GUI interfaces)
173N/A XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
173N/A
253N/A # OPTIONAL: read only XML config, if it exists, it will be read
312N/A READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
465N/A
253N/A if [ -f "${READ_XML_CONFIGURATION}" ] ; then
465N/A READ_XML_CONF="-R ${READ_XML_CONFIGURATION}"
253N/A fi
253N/A
253N/A # REQUIRED: Logger Configuration
253N/A LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
253N/A LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
253N/A
312N/A # REQUIRED: Java Archive of OpenGrok (Installation Location)
312N/A OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
312N/A
253N/A # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
253N/A # (user building from source code will find this and other key
99N/A # files in the "dist" directory after the build is completed)
77N/A OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
77N/A
77N/A # REQUIRED: Exuberant CTags (http://ctags.sf.net)
77N/A EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
77N/A
0N/A # REQUIRED: Java Home
0N/A JAVA_HOME="${JAVA_HOME:-`FindJavaHome`}"
77N/A export JAVA_HOME
125N/A
77N/A # REQUIRED: Java Virtual Machine
77N/A JAVA="${JAVA:-$JAVA_HOME/bin/java}"
205N/A
205N/A # DEVELOPMENT: Debug option, if enabled current indexer will listen on the
205N/A # port 8010 until a debugger connects
112N/A #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket"
112N/A #JAVA_DEBUG="$JAVA_DEBUG,server=y,address=8010,suspend=y"
112N/A
77N/A # OPTIONAL: Ignore these patterns as names of files or directories
106N/A #IGNORE_PATTERNS="-i dummy"
465N/A
106N/A # OPTIONAL: Enable Projects
465N/A # (Every directory in SRC_ROOT is considered a separate project)
106N/A ENABLE_PROJECTS="-P"
119N/A
119N/A # OPTIONAL: Scanning Options (for Mercurial repositories)
119N/A SCAN_FOR_REPOSITORY="-S"
119N/A if [ -n "${OPENGROK_SCAN_REPOS}" ]
106N/A then
106N/A SCAN_FOR_REPOSITORY=""
106N/A fi
99N/A
99N/A # OPTIONAL: Remote Repository Support (CVS or SVN)
99N/A # (Can be very time demanding, uncomment if needed)
99N/A REMOTE_REPOSITORIES="-r on"
99N/A if [ -n "${OPENGROK_REMOTE_REPOS}" ]
99N/A then
99N/A REMOTE_REPOSITORIES=""
99N/A fi
99N/A
125N/A # OPTIONAL: override depth of scanning for repositories
465N/A if [ -n "${OPENGROK_SCAN_DEPTH}" ]
125N/A then
465N/A SCAN_DEPTH="-z${OPENGROK_SCAN_DEPTH}"
125N/A fi
125N/A
125N/A # OPTIONAL: Allow Leading Wildcard Searches
125N/A # (default: on)
125N/A LEADING_WILDCARD="-a on"
126N/A if [ -n "${OPENGROK_WPREFIX}" ]
125N/A then
125N/A LEADING_WILDCARD=""
125N/A fi
126N/A
126N/A # OPTIONAL: Web Site Look & Feel
126N/A # (Options: default, offwhite and polished.
126N/A # Note the quoting requirements)
126N/A #SKIN='-L "default"'
126N/A
126N/A # OPTIONAL: Set Maximum Indexed Words Per File
126N/A # Note, that you might run out of memory, then either increase JVM memory
126N/A # as noted in JAVA_OPTS, or set this limit(if you don't mind opengrok not
126N/A # indexing the rest of the file, once the limit is reached)
126N/A # (default: unlimited)
126N/A #MAX_INDEXED_WORDS="-m 100000"
126N/A
126N/A # OPTIONAL: Configuration Address (host:port)
126N/A # (conf/web.xml default is localhost:2424)
126N/A WEBAPP_CONFIG=""
126N/A if [ -n "${OPENGROK_WEBAPP_CFGADDR}" ]; then
126N/A WEBAPP_CONFIG_ADDRESS=${OPENGROK_WEBAPP_CFGADDR}
126N/A if [ "${OPENGROK_WEBAPP_CFGADDR}" == "none" ]; then
210N/A WEBAPP_CONFIG_ADDRESS=""
210N/A fi
210N/A else
210N/A WEBAPP_CONFIG_ADDRESS="localhost:2424"
210N/A fi
210N/A
210N/A if [ -n "${WEBAPP_CONFIG_ADDRESS}" ]; then
126N/A WEBAPP_CONFIG="-U ${WEBAPP_CONFIG_ADDRESS}"
126N/A fi
126N/A
126N/A # OPTIONAL: JVM Options
144N/A JAVA_OPTS="${JAVA_OPTS:--Xmx2048m}"
144N/A
144N/A # OPTIONAL: Full Path to History Utilities
261N/A HG="`Which hg`"
261N/A CVS="`Which cvs`"
261N/A SVN="`Which svn`"
261N/A SCCS="`Which sccs`"
261N/A CLEARCASE="`Which cleartool`"
261N/A GIT="`Which git`"
261N/A P4="`Which p4`"
261N/A MTN="`Which mtn`"
296N/A BZR="`Which bzr`"
465N/A
296N/A # OPTIONAL: Override Built-in Properties
465N/A # Assumption: We should not set properties to the empty string
296N/A PROPERTIES="\
296N/A${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
296N/A${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
296N/A${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
296N/A${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
296N/A${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
296N/A${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
293N/A${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
293N/A${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
293N/A${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
293N/A"
293N/A
77N/A # OPTIONAL: Store The History Cache in Java DB (derby),
293N/A # instead of file system (in gzipped xml files).
0N/A #
0N/A # Requirements:
0N/A # - derbyclient.jar - See README.txt for more details
77N/A # - Running Derby Server - Defaults to localhost:1527
77N/A #
205N/A if [ -n "${OPENGROK_DERBY}" ]
77N/A then
77N/A DERBY_HISTORY_CACHE="-D"
77N/A fi
77N/A
77N/A # DELIVERED: An update program for EftarFile
58N/A # Usage: <class> inputFile [inputFile ...] outputFile
312N/A # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
312N/A EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
312N/A
312N/A # HARDCODED: Generated EftarFile (See web/*.jsp)
312N/A EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
312N/A
312N/A # Be Quiet? (set indirectly by command line arguments in the main program)
312N/A #QUIET=""
312N/A
312N/A # or alternatively, Be Verbose!
428N/A #VERBOSE="-v"
312N/A
312N/A if [ -n "${OPENGROK_VERBOSE}" ]
312N/A then
312N/A VERBOSE="-v"
428N/A QUIET=""
312N/A fi
312N/A
312N/A if [ -n "${OPENGROK_PROGRESS}" ]
312N/A then
312N/A PROGRESS="-C"
312N/A fi
312N/A}
312N/A
312N/A#
312N/A# Helper Functions - Logging
312N/A#
312N/A# In general, non-interactive use like cron jobs and automated
312N/A# installation environments should not generate unnecessary
312N/A# progress information or warnings, as usage and configuration
312N/A# will have generally been debugged prior to automation.
312N/A#
457N/A
457N/AProgress()
312N/A{
58N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
312N/A then
0N/A echo "${@}"
77N/A fi
58N/A}
58N/A
58N/AWarning()
0N/A{
0N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
0N/A then
58N/A echo "WARNING: ${@}" 1>&2
0N/A fi
0N/A}
0N/A
0N/AError()
58N/A{
312N/A echo "ERROR: ${@}" 1>&2
0N/A}
58N/A
77N/AFatalError()
58N/A{
312N/A exec >&2
0N/A echo ""
0N/A echo "FATAL ERROR: ${@} - Aborting!"
77N/A echo ""
99N/A
410N/A ${DO} exit 2
0N/A}
77N/A
11N/A#
99N/A# Helper Functions - Autodetection of Runtime Environment
99N/A#
99N/A
99N/AWhich()
11N/A{
290N/A path="`which ${1} 2>/dev/null`"
11N/A
99N/A if [ -x "${path}" ]
99N/A then
99N/A echo "${path}"
11N/A fi
77N/A}
58N/A
77N/ALocateBinary() {
70N/A for f in $@
70N/A do
58N/A file=`which "$f" 2>/dev/null | grep -v '^no '`
77N/A if test -n "$file" -a -x "$file"
70N/A then
58N/A echo $file
58N/A return 0
77N/A fi
77N/A done
99N/A
99N/A echo ""
99N/A return 1
99N/A}
77N/A
77N/AFindExuberantCTags()
77N/A{
77N/A binary=`LocateBinary ctags-exuberant exctags ctags`
77N/A if test $? -eq 1
77N/A then
77N/A Error "Unable to determine Exuberant CTags command name" \
77N/A "for ${OS_NAME} ${OS_VERSION}"
77N/A return
77N/A fi
58N/A
77N/A # Verify that this really is Exuberant Ctags
77N/A $binary --version 2>&1 | grep "Exuberant Ctags" > /dev/null
77N/A if test $? -ne 0
77N/A then
77N/A Error "Unable to determine Exuberant CTags command name" \
77N/A "for ${OS_NAME} ${OS_VERSION}\n(${binary} is not Exuberant CTags)"
77N/A return
77N/A fi
77N/A
99N/A echo ${binary}
58N/A}
99N/A
99N/AFindJavaHome()
99N/A{
99N/A javaHome=""
58N/A case "${OS_NAME}:${OS_VERSION}" in
99N/A SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
99N/A SunOS:5.11) javaHome="/usr/jdk/latest" ;;
99N/A Linux:*)
99N/A if [ -f /etc/alternatives/java ]
58N/A then
112N/A javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `
58N/A javaHome=`dirname $javaHome`
203N/A javaHome=`dirname $javaHome`
456N/A else
240N/A for dir in /usr/lib/jvm/sun-jdk-1.6 \
58N/A /usr/lib/jvm/sun-jre-1.6 \
58N/A /usr/lib/jvm/java-6-sun
207N/A do
207N/A if [ -f ${dir}/bin/java ]
207N/A then
207N/A javaHome=$dir
207N/A break;
207N/A fi
207N/A done
312N/A fi
312N/A ;;
312N/A esac
312N/A
312N/A if [ -z "${javaHome}" ]
312N/A then
312N/A Error "Unable to determine Java 6 Home" \
312N/A "for ${OS_NAME} ${OS_VERSION}"
312N/A return
207N/A fi
270N/A
312N/A if [ ! -d "${javaHome}" ]
352N/A then
312N/A Error "Missing Java Home ${javaHome}"
264N/A return
270N/A fi
270N/A
270N/A echo "${javaHome}"
270N/A}
274N/A
274N/AFindApplicationServerType()
270N/A{
270N/A # Use this function to determine which environment the deploy the
297N/A # web application function into. Some users (especially
270N/A # developers) will have many deployment environments or will wish
270N/A # to specify directly the application server to deploy to.
297N/A
460N/A # Either use the environment variable OPENGROK_APP_SERVER or
460N/A # reimplement this function in your configuration file (as
460N/A # specified by OPENGROK_CONFIGURATION)
297N/A
297N/A if [ -n "${OPENGROK_APP_SERVER}" ]
274N/A then
274N/A echo "${OPENGROK_APP_SERVER}"
274N/A return
274N/A fi
274N/A
274N/A # This implementation favours Tomcat, but needs a lot of work,
274N/A # especially if Glassfish is perferrerd or it is under the control
274N/A # of SMF (Service Management Facility)
274N/A
274N/A # Maybe a better implementation would be to call Application
274N/A # Server specific WAR Directory and see if they exist.
274N/A
274N/A if [ -d "/var/tomcat6/webapps" \
274N/A -o -d "/var/lib/tomcat6/webapps" \
274N/A -o -d "/var/lib/tomcat5/webapps" \
274N/A -o -d "/var/lib/tomcat5.5/webapps" \
270N/A ]
270N/A then
270N/A echo "Tomcat"
261N/A return
270N/A fi
270N/A
270N/A if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
264N/A then
270N/A echo "Glassfish"
270N/A return
261N/A fi
270N/A
270N/A # Assume Tomcat
264N/A echo "Tomcat"
270N/A}
274N/A
270N/ADetermineWarDirectoryTomcat()
270N/A{
270N/A if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ]
270N/A then
270N/A echo "${OPENGROK_WAR_TARGET_TOMCAT}"
270N/A return
270N/A elif [ -n "${OPENGROK_WAR_TARGET}" ]
270N/A then
270N/A echo "${OPENGROK_WAR_TARGET}"
264N/A return
264N/A fi
312N/A
58N/A for prefix in \
312N/A ${OPENGROK_TOMCAT_BASE} \
312N/A /var/tomcat6 \
58N/A /var/lib/tomcat6 \
58N/A /var/lib/tomcat5 \
99N/A /var/lib/tomcat5.5
312N/A do
99N/A if [ -d "${prefix}/webapps" ]
58N/A then
58N/A echo "${prefix}/webapps"
58N/A return
58N/A fi
58N/A done
58N/A}
312N/A
312N/ADetermineWarDirectoryGlassfish()
58N/A{
58N/A
58N/A if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ]
58N/A then
58N/A echo "${OPENGROK_WAR_TARGET_GLASSFISH}"
58N/A return
58N/A elif [ -n "${OPENGROK_WAR_TARGET}" ]
58N/A then
99N/A echo "${OPENGROK_WAR_TARGET}"
312N/A return
99N/A fi
312N/A
0N/A for prefix in \
260N/A ${OPENGROK_GLASSFISH_BASE} \
260N/A /var/appserver
260N/A do
0N/A 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)
cronexec="/pkgs/sbin/CronExecutionEnvironment.sh"
OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-$cronexec}"
if [ -f "${OPENGROK_STANDARD_ENV}" ]
then
Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
. "${OPENGROK_STANDARD_ENV}"
fi
}
#
# Load default configuration and then merge with user specified configuration.
#
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.
Progress "Loading the default instance configuration ..."
DefaultInstanceConfiguration
if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
then
# Load the Local OpenGrok Configuration Environment
Progress "Loading ${OPENGROK_CONFIGURATION} ..."
. "${OPENGROK_CONFIGURATION}"
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
if [ -n "${OPENGROK_DERBY}" ]
then
Warning "CHECK: derbyclient.jar needs to be in where the rest of " \
"opengrok used jars are and in unpacked source.war in WEB-INF/lib !"
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
filename="opengrok%g.%u.log"
fullpath="${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log"
${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|$filename|$fullpath|g" >> "${LOGGER_CONFIG_PATH}"
if [ ! -d ${OPENGROK_INSTANCE_BASE}/log ]
then
${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log
fi
fi
fi
if [ -n "${OPENGROK_DERBY}" ]
then
if [ ! -d "${OPENGROK_INSTANCE_BASE}/derby" ]
then
Warning "OpenGrok generated derby path " \
"${OPENGROK_INSTANCE_BASE}/derby doesn't exist"
Progress " Attempting to create generated derby directory ... "
${DO} mkdir -p ${OPENGROK_INSTANCE_BASE}/derby
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} \
${SCAN_DEPTH} \
${VERBOSE} ${QUIET} \
${PROGRESS} \
${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
${MAX_INDEXED_WORDS} ${SKIN} ${LEADING_WILDCARD} \
${READ_XML_CONF} \
-W ${XML_CONFIGURATION} \
${WEBAPP_CONFIG} \
-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 -p "${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
}
DerbyServer()
{
case "${OS_NAME}:${OS_VERSION}" in
SunOS:5.10) Error "unsupported OS" ;;
SunOS:5.11)
/sbin/svcadm enable javadb
;;
Linux:*)
mkdir -p $DATA_ROOT/derby
java -Dderby.system.home=$DATA_ROOT/derby \
-jar /usr/lib/jvm/java-6-sun/db/lib/derbynet.jar start
;;
*) Error "unsupported OS" ;;
esac
}
#
# Main Program
#
if [ $# -eq 0 -o $# -gt 2 ]
then
Usage
fi
LoadStandardEnvironment
LoadInstanceConfiguration
case "${1}" in
deploy)
DeployWar
;;
derby)
ValidateConfiguration
CreateRuntimeRequirements
DerbyServer
;;
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