OpenGrok revision 1393
132N/A#!/bin/sh
132N/A#
132N/A# OpenGrok Wrapper (initial setup and cron job updating)
132N/A#
132N/A# Supported Operating Systems:
132N/A# - Solaris 10 (SunOS 5.10)
132N/A# - Solaris 11 (SunOS 5.11)
132N/A# - Debian (Linux)
132N/A#
132N/A# Supported Deployment Engines:
132N/A# - Tomcat 6
132N/A# - Tomcat 5.5
132N/A# - Glassfish
132N/A#
132N/A# Supported Environment Variables:
132N/A# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
132N/A# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
132N/A# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
132N/A#
132N/A# Supported Environment Variables for configuring the default setup:
1149N/A# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
132N/A# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
132N/A# - EXUBERANT_CTAGS Full Path to Exuberant CTags
215N/A# - OPENGROK_CTAGS_OPTIONS_FILE Full path to file with extra command line
132N/A# options for CTags program (for its --options
1215N/A# switch), default is DATA_ROOT/etc/ctags.config
1215N/A# - JAVA_HOME Full Path to Java Installation Root
1318N/A# - JAVA Full Path to java binary
1176N/A# - JAVA_OPTS Java options
132N/A# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
132N/A# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
132N/A# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
132N/A# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
132N/A# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
132N/A# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish
132N/A# (contains domains)
132N/A# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
132N/A# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
132N/A# - OPENGROK_PROGRESS Shows progress in %(percentage) of working
132N/A# through project, it's good to have Verbose
132N/A# Mode enabled too, cost of this is one more
132N/A# traversal of the project before indexing it(*)
132N/A# - OPENGROK_REMOTE_REPOS_OFF Disable History Cache for (remote)
132N/A# Repositories (*)
132N/A# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)
132N/A# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go
132N/A# (by default 3 directories from SRC_ROOT)
132N/A# - OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to
132N/A# (use "none" to avoid sending it to web app)
132N/A# - OPENGROK_WPREFIX Disable wildcard prefix search query
132N/A# support (*)
132N/A# - OPENGROK_DERBY if set, then indexer tries to use derby as
132N/A# historycache (see derby command of this
132N/A# script)
132N/A# - READ_XML_CONFIGURATION file with read only configuration
132N/A# - temporary workaround for bug # 327
132N/A#
132N/A# Notes:
132N/A# (*) Any Non-Empty String will enable these options
132N/A#
132N/A
132N/A#
132N/A# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
132N/A#
132N/A
132N/A#
132N/A# Print usage to stderr and exit.
132N/A#
132N/AUsage()
132N/A{
132N/A progname=`basename $0`
132N/A
132N/A exec >&2
132N/A echo ""
132N/A echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage>"
132N/A echo " ${progname} index [<directory>]"
132N/A echo ""
132N/A echo " Optional environment variables:"
132N/A echo " OPENGROK_CONFIGURATION - location of your configuration"
132N/A echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... "
132N/A echo ""
132N/A echo " See the code for more information on configuration options /" \
132N/A "variables"
132N/A echo ""
132N/A
132N/A exit 1
132N/A}
132N/A
132N/A#
132N/A# Runtime Configuration
132N/A#
132N/Aif [ -f "/bin/uname" ]
219N/Athen
1318N/A OS_NAME="`/bin/uname -s`"
220N/A OS_VERSION="`/bin/uname -r`"
1176N/Aelse
1176N/A OS_NAME="`/usr/bin/uname -s`"
341N/A OS_VERSION="`/usr/bin/uname -r`"
341N/Afi
379N/A
411N/A# TODO: Handle symlinks correctly (especially in ${0})
487N/ASCRIPT_DIRECTORY="`dirname ${0}`"
706N/ASCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
706N/A
706N/A#
741N/A# Default Instance Configuration
741N/A#
706N/A
706N/ADefaultInstanceConfiguration()
736N/A{
487N/A # Use the built-in defaults. This section can be copied to its own
704N/A # file and tailored to your local requirements. Then simply set
487N/A # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
704N/A # this wrapper. It will save you hand editing in your settings
1215N/A # on each new release. A sample cron(1M) entry might look like:
1215N/A # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
487N/A
487N/A # Note: It is not really possible to ever provided defaults for
320N/A # these values which will run in every UNIX-like environment.
336N/A # So I have provided a set which are functional for a given
336N/A # environment on which you can based you own configuration.
336N/A
1215N/A # This has been updated to support more environment variables and
1215N/A # operating systems, if you have any reasonably generic
1369N/A # improvements please feel free to submit a patch.
336N/A
336N/A OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
336N/A
341N/A LOGGER_CONFIG_FILE="logging.properties"
487N/A
336N/A if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
336N/A then
336N/A if [ -d "${SCRIPT_DIRECTORY}/dist" -a \
379N/A -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
379N/A -f "${SCRIPT_DIRECTORY}/dist/source.war" \
487N/A ]
379N/A then
379N/A # Handle Developer Build Environments
411N/A OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
411N/A LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
487N/A else
411N/A # Handle Binary Distributions
411N/A OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
411N/A LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/"
320N/A LOGGER_CONF_SOURCE="${LOGGER_CONF_SOURCE}${LOGGER_CONFIG_FILE}"
336N/A fi
320N/A fi
336N/A
1031N/A # REQUIRED: Source Code/Repository Root
1031N/A # (your source code or the root of all repositories)
132N/A SRC_ROOT="${OPENGROK_INSTANCE_BASE}/src"
949N/A
1215N/A # REQUIRED: OpenGrok Generate Data Root
949N/A # (for Lucene index and hypertext cross-references)
949N/A # This area is rebuilt by "update" / "updateQuietly"
949N/A DATA_ROOT="${OPENGROK_INSTANCE_BASE}/data"
949N/A
949N/A # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
949N/A # (The user maintained source of the generated EftarFile file)
949N/A PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
949N/A
1272N/A # REQUIRED: XML Configuration
1272N/A # (the configuration used by Web/GUI interfaces)
1028N/A XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
1028N/A
1072N/A # OPTIONAL: read only XML config, if it exists, it will be read
1072N/A READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
1215N/A
1215N/A if [ -f "${READ_XML_CONFIGURATION}" ] ; then
949N/A READ_XML_CONF="-R ${READ_XML_CONFIGURATION}"
949N/A fi
949N/A
949N/A # REQUIRED: Logger Configuration
949N/A LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
949N/A LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
949N/A
949N/A # REQUIRED: Java Archive of OpenGrok (Installation Location)
949N/A OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
949N/A
949N/A # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
949N/A # (user building from source code will find this and other key
949N/A # files in the "dist" directory after the build is completed)
1256N/A OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
1256N/A
1275N/A # REQUIRED: Exuberant CTags (http://ctags.sf.net)
1275N/A EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
949N/A
949N/A # OPTIONAL: supply extra command line options to CTags program
132N/A if [ -n ${OPENGROK_CTAGS_OPTIONS_FILE} ]; then
132N/A CTAGS_OPTIONS_FILE="${OPENGROK_CTAGS_OPTIONS_FILE}"
230N/A elif [ -r "${OPENGROK_INSTANCE_BASE}/etc/ctags.config" ]; then
989N/A CTAGS_OPTIONS_FILE="${OPENGROK_INSTANCE_BASE}/etc/ctags.config"
989N/A fi
989N/A
989N/A # REQUIRED: Java Home
989N/A JAVA_HOME="${JAVA_HOME:-`FindJavaHome`}"
989N/A export JAVA_HOME
230N/A
230N/A # REQUIRED: Java Virtual Machine
230N/A JAVA="${JAVA:-$JAVA_HOME/bin/java}"
935N/A
935N/A # DEVELOPMENT: Debug option, if enabled current indexer will listen on the
230N/A # port 8010 until a debugger connects
230N/A #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket"
230N/A #JAVA_DEBUG="$JAVA_DEBUG,server=y,address=8010,suspend=y"
989N/A
989N/A # OPTIONAL: Ignore these patterns as names of files or directories
989N/A #IGNORE_PATTERNS="-i dummy"
989N/A
1215N/A # OPTIONAL: Enable Projects
989N/A # (Every directory in SRC_ROOT is considered a separate project)
989N/A ENABLE_PROJECTS="-P"
989N/A
989N/A # OPTIONAL: Scanning Options (for Mercurial repositories)
989N/A SCAN_FOR_REPOSITORY="-S"
989N/A if [ -n "${OPENGROK_SCAN_REPOS}" ]
989N/A then
989N/A SCAN_FOR_REPOSITORY=""
989N/A fi
1215N/A
1215N/A # OPTIONAL: Disable remote repository support (CVS or SVN) [on by default]
1215N/A REMOTE_REPOSITORIES="-r on"
989N/A if [ -n "${OPENGROK_REMOTE_REPOS_OFF}" ]
989N/A then
1215N/A REMOTE_REPOSITORIES=""
989N/A fi
989N/A
989N/A # OPTIONAL: override depth of scanning for repositories
989N/A if [ -n "${OPENGROK_SCAN_DEPTH}" ]
230N/A then
230N/A SCAN_DEPTH="-z${OPENGROK_SCAN_DEPTH}"
230N/A fi
230N/A
230N/A # OPTIONAL: Allow Leading Wildcard Searches
230N/A # (default: on)
230N/A LEADING_WILDCARD="-a on"
230N/A if [ -n "${OPENGROK_WPREFIX}" ]
301N/A then
1318N/A LEADING_WILDCARD=""
1323N/A fi
1323N/A
132N/A # OPTIONAL: Web Site Look & Feel
949N/A # (Options: default, offwhite and polished.
213N/A # Note the quoting requirements)
301N/A #SKIN='-L "default"'
741N/A
132N/A # OPTIONAL: Set Maximum Indexed Words Per File
1318N/A # Note, that you might run out of memory, then either increase JVM memory
1318N/A # as noted in JAVA_OPTS, or set this limit(if you don't mind opengrok not
1318N/A # indexing the rest of the file, once the limit is reached)
1318N/A # (default: unlimited)
1318N/A #MAX_INDEXED_WORDS="-m 100000"
132N/A
211N/A # OPTIONAL: Configuration Address (host:port)
213N/A # (conf/web.xml default is localhost:2424)
213N/A WEBAPP_CONFIG=""
213N/A if [ -n "${OPENGROK_WEBAPP_CFGADDR}" ]; then
213N/A WEBAPP_CONFIG_ADDRESS=${OPENGROK_WEBAPP_CFGADDR}
213N/A if [ "${OPENGROK_WEBAPP_CFGADDR}" == "none" ]; then
1215N/A WEBAPP_CONFIG_ADDRESS=""
213N/A fi
213N/A else
487N/A WEBAPP_CONFIG_ADDRESS="localhost:2424"
213N/A fi
213N/A
213N/A if [ -n "${WEBAPP_CONFIG_ADDRESS}" ]; then
213N/A WEBAPP_CONFIG="-U ${WEBAPP_CONFIG_ADDRESS}"
213N/A fi
213N/A
1215N/A # OPTIONAL: JVM Options
1215N/A JAVA_OPTS="${JAVA_OPTS:--Xmx2048m}"
1215N/A
1215N/A # OPTIONAL: Full Path to History Utilities
1215N/A HG="`Which hg`"
1215N/A CVS="`Which cvs`"
1215N/A SVN="`Which svn`"
1323N/A SCCS="`Which sccs`"
1323N/A CLEARCASE="`Which cleartool`"
213N/A GIT="`Which git`"
213N/A P4="`Which p4`"
213N/A MTN="`Which mtn`"
213N/A BZR="`Which bzr`"
1215N/A
1215N/A # OPTIONAL: Override Built-in Properties
845N/A # Assumption: We should not set properties to the empty string
1215N/A PROPERTIES="\
213N/A${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
213N/A${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
230N/A${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
213N/A${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
213N/A${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
211N/A${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
211N/A${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
211N/A${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
211N/A${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
211N/A"
1215N/A
1215N/A # OPTIONAL: Store The History Cache in Java DB (derby),
1215N/A # instead of file system (in gzipped xml files).
1215N/A #
1215N/A # Requirements:
1215N/A # - derbyclient.jar - See README.txt for more details
211N/A # - Running Derby Server - Defaults to localhost:1527
1318N/A #
1318N/A if [ -n "${OPENGROK_DERBY}" ]
1318N/A then
1318N/A DERBY_HISTORY_CACHE="-D"
1318N/A fi
1318N/A
1318N/A # DELIVERED: An update program for EftarFile
1318N/A # Usage: <class> inputFile [inputFile ...] outputFile
1318N/A # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
1318N/A EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
1318N/A
1318N/A # HARDCODED: Generated EftarFile (See web/*.jsp)
1318N/A EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
1318N/A
1318N/A # Be Quiet? (set indirectly by command line arguments in the main program)
1318N/A #QUIET=""
1318N/A
1369N/A # or alternatively, Be Verbose!
1318N/A #VERBOSE="-v"
1318N/A
1318N/A if [ -n "${OPENGROK_VERBOSE}" ]
1318N/A then
1318N/A VERBOSE="-v"
1318N/A QUIET=""
1318N/A fi
1319N/A
1318N/A if [ -n "${OPENGROK_PROGRESS}" ]
1319N/A then
1318N/A PROGRESS="-C"
132N/A fi
211N/A}
1215N/A
950N/A#
144N/A# Helper Functions - Logging
453N/A#
144N/A# In general, non-interactive use like cron jobs and automated
260N/A# installation environments should not generate unnecessary
260N/A# progress information or warnings, as usage and configuration
260N/A# will have generally been debugged prior to automation.
260N/A#
260N/A
260N/AProgress()
260N/A{
260N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
144N/A then
219N/A echo "${@}"
219N/A fi
1215N/A}
1215N/A
1215N/AWarning()
1215N/A{
1215N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
1215N/A then
219N/A echo "WARNING: ${@}" 1>&2
220N/A fi
220N/A}
1215N/A
220N/AError()
1215N/A{
1215N/A echo "ERROR: ${@}" 1>&2
1215N/A}
1215N/A
1215N/AFatalError()
1215N/A{
1215N/A exec >&2
1215N/A echo ""
1215N/A echo "FATAL ERROR: ${@} - Aborting!"
1215N/A echo ""
1215N/A
1215N/A ${DO} exit 2
1215N/A}
1215N/A
1215N/A#
1215N/A# Helper Functions - Autodetection of Runtime Environment
1215N/A#
1215N/A
1215N/AWhich()
1215N/A{
1215N/A path="`which ${1} 2>/dev/null`"
1215N/A
1215N/A if [ -x "${path}" ]
1215N/A then
220N/A echo "${path}"
220N/A fi
221N/A}
1215N/A
1215N/ALocateBinary() {
1215N/A for f in $@
1215N/A do
1215N/A file=`which "$f" 2>/dev/null | grep -v '^no '`
981N/A if test -n "$file" -a -x "$file"
981N/A then
1215N/A echo $file
1215N/A return 0
221N/A fi
295N/A done
336N/A
336N/A echo ""
336N/A return 1
336N/A}
341N/A
336N/AFindExuberantCTags()
336N/A{
336N/A binary=`LocateBinary ctags-exuberant exctags ctags`
336N/A if test $? -eq 1
341N/A then
336N/A Error "Unable to determine Exuberant CTags command name" \
336N/A "for ${OS_NAME} ${OS_VERSION}"
879N/A return
336N/A fi
341N/A
341N/A # Verify that this really is Exuberant Ctags
336N/A $binary --version 2>&1 | grep "Exuberant Ctags" > /dev/null
336N/A if test $? -ne 0
295N/A then
341N/A Error "Unable to determine Exuberant CTags command name" \
295N/A "for ${OS_NAME} ${OS_VERSION}\n(${binary} is not Exuberant CTags)"
295N/A return
295N/A fi
295N/A
295N/A echo ${binary}
295N/A}
295N/A
295N/AFindJavaHome()
295N/A{
301N/A javaHome=""
879N/A case "${OS_NAME}:${OS_VERSION}" in
339N/A SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
341N/A SunOS:5.11) javaHome="/usr/jdk/latest" ;;
341N/A Linux:*)
339N/A if [ -f /etc/alternatives/java ]
339N/A then
339N/A javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `
341N/A javaHome=`dirname $javaHome`
339N/A javaHome=`dirname $javaHome`
339N/A else
339N/A for dir in /usr/lib/jvm/sun-jdk-1.6 \
339N/A /usr/lib/jvm/sun-jre-1.6 \
339N/A /usr/lib/jvm/java-6-sun
339N/A do
339N/A if [ -f ${dir}/bin/java ]
339N/A then
339N/A javaHome=$dir
379N/A break;
379N/A fi
379N/A done
379N/A fi
379N/A ;;
379N/A esac
411N/A
379N/A if [ -z "${javaHome}" ]
379N/A then
379N/A Error "Unable to determine Java 6 Home" \
386N/A "for ${OS_NAME} ${OS_VERSION}"
379N/A return
1024N/A fi
379N/A
379N/A if [ ! -d "${javaHome}" ]
379N/A then
379N/A Error "Missing Java Home ${javaHome}"
411N/A return
411N/A fi
411N/A
411N/A echo "${javaHome}"
411N/A}
411N/A
411N/AFindApplicationServerType()
411N/A{
411N/A # Use this function to determine which environment the deploy the
411N/A # web application function into. Some users (especially
411N/A # developers) will have many deployment environments or will wish
411N/A # to specify directly the application server to deploy to.
411N/A
411N/A # Either use the environment variable OPENGROK_APP_SERVER or
411N/A # reimplement this function in your configuration file (as
411N/A # specified by OPENGROK_CONFIGURATION)
482N/A
411N/A if [ -n "${OPENGROK_APP_SERVER}" ]
411N/A then
411N/A echo "${OPENGROK_APP_SERVER}"
1072N/A return
1072N/A fi
1072N/A
411N/A # This implementation favours Tomcat, but needs a lot of work,
463N/A # especially if Glassfish is perferrerd or it is under the control
411N/A # of SMF (Service Management Facility)
339N/A
996N/A # Maybe a better implementation would be to call Application
1215N/A # Server specific WAR Directory and see if they exist.
996N/A
996N/A if [ -d "/var/tomcat6/webapps" \
1215N/A -o -d "/var/lib/tomcat6/webapps" \
1215N/A -o -d "/var/lib/tomcat5/webapps" \
1215N/A -o -d "/var/lib/tomcat5.5/webapps" \
1215N/A ]
1215N/A then
1215N/A echo "Tomcat"
1215N/A return
1215N/A fi
1215N/A
1215N/A if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
996N/A then
996N/A echo "Glassfish"
996N/A return
1215N/A fi
996N/A
996N/A # Assume Tomcat
1215N/A echo "Tomcat"
1215N/A}
1215N/A
1215N/ADetermineWarDirectoryTomcat()
1215N/A{
1215N/A if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ]
1215N/A then
1215N/A echo "${OPENGROK_WAR_TARGET_TOMCAT}"
1215N/A return
1215N/A elif [ -n "${OPENGROK_WAR_TARGET}" ]
996N/A then
996N/A echo "${OPENGROK_WAR_TARGET}"
336N/A return
381N/A fi
336N/A
336N/A for prefix in \
336N/A ${OPENGROK_TOMCAT_BASE} \
336N/A /var/tomcat6 \
336N/A /var/lib/tomcat6 \
336N/A /var/lib/tomcat5 \
336N/A /var/lib/tomcat5.5
336N/A do
336N/A if [ -d "${prefix}/webapps" ]
336N/A then
336N/A echo "${prefix}/webapps"
301N/A return
301N/A fi
301N/A done
301N/A}
301N/A
301N/ADetermineWarDirectoryGlassfish()
301N/A{
301N/A
301N/A if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ]
301N/A then
691N/A echo "${OPENGROK_WAR_TARGET_GLASSFISH}"
301N/A return
301N/A elif [ -n "${OPENGROK_WAR_TARGET}" ]
301N/A then
301N/A echo "${OPENGROK_WAR_TARGET}"
301N/A return
301N/A fi
448N/A
446N/A for prefix in \
448N/A ${OPENGROK_GLASSFISH_BASE} \
500N/A /var/appserver
736N/A do
706N/A if [ -d "${prefix}/domains" ]
706N/A then
807N/A if [ -z "${domainDirectory}" ]
1215N/A then
455N/A domainDirectory="${prefix}/domains"
706N/A fi
706N/A fi
455N/A done
706N/A
455N/A if [ -z "${domainDirectory}" ]
480N/A then
706N/A return
480N/A fi
480N/A
455N/A # User Specified Domain
706N/A if [ -n "${OPENGROK_GLASSFISH_DOMAIN}" ]
455N/A then
480N/A directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
480N/A
741N/A if [ ! -d "${directory}" ]
741N/A then
500N/A FatalError "Missing Specified Glassfish Domain " \
500N/A "${OPENGROK_GLASSFISH_DOMAIN}"
500N/A fi
1215N/A
1215N/A echo "${directory}"
1215N/A return
1215N/A fi
1215N/A
1215N/A # Arbitrary Domain Selection
1215N/A firstDomain=`ls -1 ${domainDirectory} | head -1`
725N/A
725N/A if [ -z "${firstDomain}" ]
1215N/A then
1215N/A FatalError "Failed to dynamically determine Glassfish Domain from " \
1215N/A "${domainDirectory}"
1215N/A fi
725N/A
1215N/A echo "${domainDirectory}/${firstDomain}/autodeploy"
1215N/A}
1215N/A
1215N/A#
1215N/A# Implementation
1215N/A#
1215N/A# The variable "DO" can usefully be set to "echo" to aid in script debugging
1215N/A#
1215N/A
1215N/ALoadStandardEnvironment()
1215N/A{
1215N/A # Setup a standard execution environment (if required)
301N/A
301N/A cronexec="/pkgs/sbin/CronExecutionEnvironment.sh"
736N/A OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-$cronexec}"
1215N/A
1215N/A if [ -f "${OPENGROK_STANDARD_ENV}" ]
1215N/A then
1215N/A Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
1215N/A . "${OPENGROK_STANDARD_ENV}"
1215N/A fi
1215N/A}
736N/A
736N/A#
736N/A# Load default configuration and then merge with user specified configuration.
736N/A#
736N/ALoadInstanceConfiguration()
736N/A{
736N/A # Note: As all functions have been defined by the time this routine
736N/A # is called, your configuration can, if desired, override functions
736N/A # in addition to setting the variables mentioned in the function
736N/A # DefaultInstanceConfiguration(), this maybe useful to override
736N/A # functionality used to determine the default deployment environment
736N/A # find dependencies or validate the configuration, for example.
741N/A
741N/A Progress "Loading the default instance configuration ..."
1215N/A DefaultInstanceConfiguration
1215N/A if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
1215N/A then
1215N/A # Load the Local OpenGrok Configuration Environment
1215N/A Progress "Loading ${OPENGROK_CONFIGURATION} ..."
736N/A . "${OPENGROK_CONFIGURATION}"
736N/A fi
336N/A}
301N/A
301N/AValidateConfiguration()
501N/A{
301N/A if [ ! -x "${EXUBERANT_CTAGS}" ]
301N/A then
301N/A FatalError "Missing Dependent Application - Exuberant CTags"
301N/A fi
301N/A
301N/A if [ ! -d "${SRC_ROOT}" ]
301N/A then
301N/A FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
301N/A fi
449N/A
624N/A if [ -n "${QUIET}" -a -n "${VERBOSE}" ]
624N/A then
624N/A Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose"
624N/A QUIET=""
624N/A VERBOSE="-v"
624N/A fi
624N/A
624N/A if [ -n "${OPENGROK_DERBY}" ]
624N/A then
624N/A Warning "CHECK: derbyclient.jar needs to be in where the rest of " \
624N/A "opengrok used jars are and in unpacked source.war in WEB-INF/lib !"
624N/A fi
624N/A}
624N/A
624N/ACreateRuntimeRequirements()
624N/A{
624N/A if [ ! -d "${DATA_ROOT}" ]
624N/A then
624N/A Warning "OpenGrok generated data path ${DATA_ROOT} doesn't exist"
624N/A Progress " Attempting to create generated data directory ... "
624N/A ${DO} mkdir -p "${DATA_ROOT}"
624N/A fi
624N/A if [ ! -d "${DATA_ROOT}" ]
801N/A then
801N/A FatalError "OpenGrok data path ${DATA_ROOT} doesn't exist"
801N/A fi
801N/A
801N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
801N/A then
801N/A Warning "OpenGrok generated etc path ${OPENGROK_INSTANCE_BASE}/etc " \
801N/A "doesn't exist"
801N/A Progress " Attempting to create generated etc directory ... "
801N/A ${DO} mkdir -p "${OPENGROK_INSTANCE_BASE}/etc"
1095N/A fi
1095N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
1215N/A then
1215N/A FatalError "OpenGrok etc path ${OPENGROK_INSTANCE_BASE}/etc " \
1099N/A "doesn't exist"
1215N/A fi
1215N/A
1215N/A if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
1095N/A then
1095N/A Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
1176N/A if [ ! -f "${LOGGER_CONF_SOURCE}" ]
1176N/A then
1215N/A Warning "Can't find distribution logging configuration" \
1215N/A "(${LOGGER_CONF_SOURCE}) to install as default" \
1215N/A "logging configuration (${LOGGER_CONFIG_PATH})"
1215N/A else
1215N/A filename="opengrok%g.%u.log"
1215N/A fullpath="${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log"
1215N/A ${DO} grep -v java.util.logging.FileHandler.pattern \
1176N/A "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
1215N/A ${DO} grep java.util.logging.FileHandler.pattern \
1215N/A "${LOGGER_CONF_SOURCE}" | \
1215N/A sed "s|$filename|$fullpath|g" >> "${LOGGER_CONFIG_PATH}"
1176N/A if [ ! -d ${OPENGROK_INSTANCE_BASE}/log ]
1215N/A then
1215N/A ${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log
1215N/A fi
1215N/A fi
1215N/A fi
1215N/A
1215N/A if [ -n "${OPENGROK_DERBY}" ]
1215N/A then
1217N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/derby" ]
1215N/A then
1215N/A Warning "OpenGrok generated derby path " \
1215N/A "${OPENGROK_INSTANCE_BASE}/derby doesn't exist"
1176N/A Progress " Attempting to create generated derby directory ... "
1215N/A ${DO} mkdir -p ${OPENGROK_INSTANCE_BASE}/derby
1215N/A fi
1215N/A fi
1215N/A}
1215N/A
1215N/AStdInvocation()
1215N/A{
1215N/A ${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
1215N/A ${LOGGER_PROPERTIES} \
1215N/A ${JAVA_DEBUG} \
1215N/A -jar ${OPENGROK_JAR} \
1215N/A ${IGNORE_PATTERNS} ${ENABLE_PROJECTS} \
1215N/A ${DERBY_HISTORY_CACHE} \
1215N/A ${SCAN_FOR_REPOSITORY} ${REMOTE_REPOSITORIES} \
1215N/A ${SCAN_DEPTH} \
1215N/A ${VERBOSE} ${QUIET} \
1215N/A ${PROGRESS} \
1176N/A ${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
1215N/A ${CTAGS_OPTIONS_FILE:+-o} ${CTAGS_OPTIONS_FILE} \
1215N/A ${MAX_INDEXED_WORDS} ${SKIN} ${LEADING_WILDCARD} \
1215N/A ${READ_XML_CONF} \
1215N/A -W ${XML_CONFIGURATION} \
1176N/A ${WEBAPP_CONFIG} \
1215N/A -s ${SRC_ROOT} -d ${DATA_ROOT} \
1215N/A "${@}"
1215N/A}
1215N/A
1176N/AUpdateGeneratedData()
1215N/A{
1215N/A StdInvocation -H
1215N/A}
1215N/A
1215N/AUpdateDescriptionCache()
1176N/A{
1215N/A # OPTIONAL : Update the EftarFile data
1215N/A
1176N/A if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ]
1215N/A then
1215N/A ${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
1176N/A ${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
1215N/A fi
1215N/A}
1215N/A
1215N/AOpenGrokUsage()
1215N/A{
1215N/A echo "Options for opengrok.jar:" 1>&2
1215N/A ${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?'
1215N/A}
1215N/A
1176N/ADeployWar()
1176N/A{
1176N/A applicationServer="`FindApplicationServerType`"
1176N/A
1176N/A case "${applicationServer}" in
1176N/A
1176N/A Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
1176N/A Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
1176N/A
1215N/A *) FatalError "Unsupported Application Server ${applicationServer}" ;;
1215N/A
1176N/A esac
1215N/A
1215N/A if [ -z "${warTarget}" ]
1176N/A then
1215N/A FatalError "Unable to determine Deployment Directory for " \
1215N/A "${applicationServer}"
1215N/A fi
1176N/A
1215N/A if [ ! -f "${OPENGROK_DIST_WAR}" ]
1176N/A then
1176N/A FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
1215N/A fi
1176N/A
1176N/A if [ ! -d "${warTarget}" ]
1176N/A then
1176N/A FatalError "Missing Deployment Directory ${warTarget}"
1176N/A fi
1215N/A
1215N/A Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
1215N/A ${DO} cp -p "${OPENGROK_DIST_WAR}" "${warTarget}/"
1176N/A if [ $? != 0 ]
1216N/A then
132N/A 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