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