OpenGrok revision 561ec0545f30e44833b6def5168abbd3ab5cf65a
10139N/A#!/bin/sh
10139N/A#
10139N/A# OpenGrok Wrapper (initial setup and cron job updating)
12158N/A#
10139N/A# Supported Operating Systems:
10139N/A# - Solaris 10 (SunOS 5.10)
10139N/A# - OpenSolaris (SunOS 5.11)
17185N/A# - Debian (Linux)
10139N/A#
17181N/A# Supported Deployment Engines:
17181N/A# - Tomcat 6
17181N/A# - Tomcat 5.5
10139N/A# - Glassfish
10139N/A#
10139N/A# Supported Environment Variables:
10139N/A# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
17234N/A# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
10752N/A# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
10139N/A#
10139N/A# Supported Environment Variables for configuring the default setup:
10139N/A# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
16774N/A# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
10139N/A# - EXUBERANT_CTAGS Full Path to Exuberant CTags
10139N/A# - JAVA_HOME Full Path to Java Installation Root
10318N/A# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
10943N/A# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
10139N/A# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
10139N/A# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
10139N/A# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
10139N/A# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
10139N/A# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
13922N/A# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
10139N/A# - OPENGROK_PROGRESS Shows progress in %(percentage) of working through project, it's good to have Verbose Mode enabled too, cost of this is one more traversal of the project before indexing it (*)
13922N/A# - OPENGROK_REMOTE_REPOS Disable History Cache for (remote) Repositories (*)
10139N/A# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)_
13922N/A# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go (by default 3 directories from SRC_ROOT)
10139N/A# - OPENGROK_WPREFIX Disable wildcard prefix search query support (*)
13922N/A# - OPENGROK_DERBY if set, then indexer tries to use derby as historycache (see derby command of this script)
10139N/A#
13922N/A# - READ_XML_CONFIGURATION file with read only configuration - a temp workaround for bug # 327
16686N/A#
16762N/A# Notes:
16768N/A# (*) Any Non-Empty String will enable these options
13922N/A#
16762N/A
16762N/A#
16768N/A# Usage
16522N/A#
17220N/A
17220N/AUsage()
17234N/A{
17234N/A echo 1>&2
17271N/A echo "Usage: ${0} <deploy|derby|update|updateQuietly|usage>" 1>&2
17271N/A echo " ${0} index [<directory>]" 1>&2
16168N/A echo 1>&2
10139N/A echo " Optional environment variables:" 1>&2
10139N/A echo " OPENGROK_CONFIGURATION - location of your configuration" 1>&2
10139N/A echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
10139N/A echo 1>&2
10139N/A echo " See the code for more information on configuration options / variables" 1>&2
10139N/A echo 1>&2
10139N/A exit 1
10139N/A}
10139N/A
10139N/A#
10139N/A# Runtime Configuration
10139N/A#
10139N/Aif [ -f "/bin/uname" ]
13922N/Athen
10139N/AOS_NAME="`/bin/uname -s`"
10139N/AOS_VERSION="`/bin/uname -r`"
10139N/Aelse
10139N/AOS_NAME="`/usr/bin/uname -s`"
10139N/AOS_VERSION="`/usr/bin/uname -r`"
10139N/Afi
10139N/A
10139N/A# TODO: Handle symlinks correctly (especially in ${0})
10139N/ASCRIPT_DIRECTORY="`dirname ${0}`"
10139N/ASCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
10139N/A
10139N/A#
10139N/A# Default Instance Configuration
10139N/A#
10139N/A
10139N/ADefaultInstanceConfiguration()
10139N/A{
10139N/A # Use the built-in defaults. This section can be copied to its own
10139N/A # file and tailored to your local requirements. Then simply set
10139N/A # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
10139N/A # this wrapper. It will save you hand editing in your settings
10139N/A # on each new release. A sample cron(1M) entry might look like:
10139N/A # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
10139N/A
10139N/A # Note: It is not really possible to ever provided defaults for
10139N/A # these values which will run in every UNIX-like environment.
10139N/A # So I have provided a set which are functional for a given
10139N/A # environment on which you can based you own configuration.
10139N/A
10139N/A # This has been updated to support more environment variables and
10139N/A # operating systems, if you have any reasonably generic
10139N/A # improvements please feel free to submit a patch.
10139N/A
10139N/A OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
10139N/A
10139N/A LOGGER_CONFIG_FILE="logging.properties"
10139N/A
10139N/A if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
10139N/A then
10463N/A if [ -d "${SCRIPT_DIRECTORY}/dist" -a \
10463N/A -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
10139N/A -f "${SCRIPT_DIRECTORY}/dist/source.war" \
10139N/A ]
10139N/A then
10943N/A # Handle Developer Build Environments
12754N/A OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
10943N/A LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
10318N/A else
10139N/A # Handle Binary Distributions
10139N/A OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
10139N/A LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/${LOGGER_CONFIG_FILE}"
10139N/A fi
13922N/A fi
10139N/A
10139N/A # REQUIRED: Source Code/Repository Root
13922N/A # (your source code or the root of all repositories)
10139N/A SRC_ROOT="${OPENGROK_INSTANCE_BASE}/src"
10139N/A
13922N/A # REQUIRED: OpenGrok Generate Data Root
10752N/A # (for Lucene index and hypertext cross-references)
10553N/A # This area is rebuilt by "update" / "updateQuietly"
10139N/A DATA_ROOT="${OPENGROK_INSTANCE_BASE}/data"
11239N/A
10752N/A # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
10553N/A # (The user maintained source of the generated EftarFile file)
17220N/A PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
17234N/A
17271N/A # REQUIRED: XML Configuration
10139N/A # (the configuration used by Web/GUI interfaces)
10139N/A XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
10139N/A
10139N/A # OPTIONAL: read only XML config, if it exists, it will be read
10139N/A READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
10139N/A
10139N/A if [ -f "${READ_XML_CONFIGURATION}" ] ; then
10139N/A READ_XML_CONF="-R ${READ_XML_CONFIGURATION}"
10139N/A fi
10139N/A
10139N/A # REQUIRED: Logger Configuration
10139N/A LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
10139N/A LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
10139N/A
10139N/A # REQUIRED: Java Archive of OpenGrok (Installation Location)
10139N/A OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
10139N/A
10139N/A # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
10139N/A # (user building from source code will find this and other key
12601N/A # files in the "dist" directory after the build is completed)
10318N/A OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
10318N/A
10318N/A # REQUIRED: Exuberant CTags (http://ctags.sf.net)
10318N/A EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
10318N/A
10318N/A # REQUIRED: Java Home
10318N/A JAVA_HOME="${JAVA_HOME:-`FindJavaHome`}"
10318N/A export JAVA_HOME
10318N/A
10318N/A # REQUIRED: Java Virtual Machine
10318N/A JAVA="${JAVA:-$JAVA_HOME/bin/java}"
10318N/A
10318N/A # DEVELOPMENT: Debug option, if enabled current indexer will listen on the port 8010 until a debugger connects
10139N/A #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,address=8010,suspend=y"
10960N/A
13298N/A # OPTIONAL: Ignore these patterns as names of files or directories
10139N/A #IGNORE_PATTERNS="-i dummy"
10139N/A
10553N/A # OPTIONAL: Enable Projects
10553N/A # (Every directory in SRC_ROOT is considered a separate project)
10553N/A ENABLE_PROJECTS="-P"
10139N/A
10139N/A # OPTIONAL: Scanning Options (for Mercurial repositories)
10139N/A SCAN_FOR_REPOSITORY="-S"
10139N/A if [ -n "${OPENGROK_SCAN_REPOS}" ]
17234N/A then
10139N/A SCAN_FOR_REPOSITORY=""
10139N/A fi
10139N/A
10139N/A # OPTIONAL: Remote Repository Support (CVS or SVN)
10139N/A # (Can be very time demanding, uncomment if needed)
10139N/A REMOTE_REPOSITORIES="-r on"
10139N/A if [ -n "${OPENGROK_REMOTE_REPOS}" ]
10139N/A then
10139N/A REMOTE_REPOSITORIES=""
10139N/A fi
10139N/A
13310N/A # OPTIONAL: override depth of scanning for repositories
10139N/A if [ -n "${OPENGROK_SCAN_DEPTH}" ]
10139N/A then
10139N/A SCAN_DEPTH="-z${OPENGROK_SCAN_DEPTH}"
10139N/A fi
10139N/A
10139N/A # OPTIONAL: Allow Leading Wildcard Searches
10139N/A # (default: on)
10139N/A LEADING_WILDCARD="-a on"
10139N/A if [ -n "${OPENGROK_WPREFIX}" ]
10139N/A then
10139N/A LEADING_WILDCARD=""
10139N/A fi
10139N/A
10139N/A # OPTIONAL: Web Site Look & Feel
10139N/A # (Options: default, offwhite and polished.
10139N/A # Note the quoting requirements)
10139N/A #SKIN='-L "default"'
10139N/A
10139N/A # OPTIONAL: Set Maximum Indexed Words Per File
10139N/A # Note, that you might run out of memory, then either increase JVM memory
10139N/A # as noted in JAVA_OPTS, or set this limit(if you don't mind opengrok not
10139N/A # indexing the rest of the file, once the limit is reached)
10139N/A # (default: unlimited)
10139N/A #MAX_INDEXED_WORDS="-m 100000"
10139N/A
10139N/A # OPTIONAL: Configuration Address (host:port)
10139N/A # (conf/web.xml default is localhost:2424)
10139N/A WEBAPP_CONFIG_ADDRESS="-U localhost:2424"
10139N/A
10139N/A # OPTIONAL: JVM Options
10139N/A #JAVA_OPTS="-server -Xmx2048m"
10139N/A JAVA_OPTS="-Xmx2048m"
10139N/A
10139N/A # OPTIONAL: Full Path to History Utilities
10139N/A HG="`Which hg`"
10139N/A CVS="`Which cvs`"
10139N/A SVN="`Which svn`"
10139N/A SCCS="`Which sccs`"
10139N/A CLEARCASE="`Which cleartool`"
10139N/A GIT="`Which git`"
10139N/A P4="`Which p4`"
10139N/A MTN="`Which mtn`"
10139N/A BZR="`Which bzr`"
10139N/A
10139N/A # OPTIONAL: Override Built-in Properties
10139N/A # Assumption: We should not set properties to the empty string
17271N/A PROPERTIES="\
17271N/A${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
17234N/A${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
17234N/A${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
17234N/A${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
17201N/A${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
17201N/A${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
17201N/A${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
17121N/A${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
17121N/A${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
17099N/A"
17099N/A
17099N/A # OPTIONAL: Store The History Cache in Java DB (derby),
17097N/A # instead of file system (in gzipped xml files).
17004N/A #
17004N/A # Requirements:
17004N/A # - derbyclient.jar - See README.txt for more details
16979N/A # - Running Derby Server - Defaults to localhost:1527
16979N/A #
16979N/A if [ -n "${OPENGROK_DERBY}" ]
16867N/A then
16867N/A DERBY_HISTORY_CACHE="-D"
16804N/A fi
16804N/A
16768N/A # DELIVERED: An update program for EftarFile
16768N/A # Usage: <class> inputFile [inputFile ...] outputFile
16740N/A # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
16740N/A EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
16686N/A
16686N/A # HARDCODED: Generated EftarFile (See web/*.jsp)
16686N/A EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
16686N/A
16686N/A # Be Quiet? (set indirectly by command line arguments in the main program)
16487N/A #QUIET=""
16487N/A
16487N/A # or alternatively, Be Verbose!
16487N/A #VERBOSE="-v"
16425N/A
16425N/A if [ -n "${OPENGROK_VERBOSE}" ]
16425N/A then
16425N/A VERBOSE="-v"
16423N/A QUIET=""
16423N/A fi
16420N/A
16420N/A if [ -n "${OPENGROK_PROGRESS}" ]
16420N/A then
16420N/A PROGRESS="-C"
16421N/A fi
16367N/A}
16367N/A
16175N/A#
16175N/A# Helper Functions - Logging
16134N/A#
16134N/A# In general, non-interactive use like cron jobs and automated
15880N/A# installation environments should not generate unnecessary
15880N/A# progress information or warnings, as usage and configuration
15838N/A# will have generally been debugged prior to automation.
15838N/A#
15626N/A
15626N/AProgress()
15613N/A{
15613N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
15613N/A then
15490N/A echo "${@}"
15490N/A fi
15477N/A}
15477N/A
14545N/AWarning()
14545N/A{
14499N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
14499N/A then
14499N/A echo "WARNING: ${@}" 1>&2
14493N/A fi
14493N/A}
14390N/A
14390N/AError()
14172N/A{
14172N/A echo "ERROR: ${@}" 1>&2
13910N/A}
13910N/A
13910N/AFatalError()
13910N/A{
13910N/A echo 1>&2
13910N/A echo "FATAL ERROR: ${@} - Aborting!" 1>&2
13863N/A echo 1>&2
13863N/A ${DO} exit 2
13863N/A}
13863N/A
13863N/A#
13853N/A# Helper Functions - Autodetection of Runtime Environment
13853N/A#
13853N/A
13853N/AWhich()
13853N/A{
13620N/A path="`which ${1} 2>/dev/null`"
13620N/A
13469N/A if [ -x "${path}" ]
13469N/A then
13469N/A echo "${path}"
13469N/A fi
13412N/A}
13412N/A
13324N/ALocateBinary() {
13324N/A for f in $@
13298N/A do
13310N/A file=`which $f 2>/dev/null | grep -v '^no '`
13310N/A if test -n "$file" -a -x "$file"
13310N/A then
13298N/A echo $file
12644N/A return 0
12644N/A fi
12601N/A done
12601N/A
12593N/A echo ""
12593N/A return 1
12465N/A}
12465N/A
12451N/AFindExuberantCTags()
12451N/A{
12371N/A binary=`LocateBinary ctags-exuberant exctags ctags`
12371N/A if test $? -eq 1
12346N/A then
12346N/A Error "Unable to determine Exuberant CTags command name" \
12346N/A "for ${OS_NAME} ${OS_VERSION}"
12346N/A return
12346N/A fi
12300N/A
12346N/A # Verify that this really is Exuberant Ctags
12287N/A $binary --version 2>&1 | grep "Exuberant Ctags" > /dev/null
12177N/A if test $? -ne 0
12177N/A then
12177N/A Error "Unable to determine Exuberant CTags command name" \
12177N/A "for ${OS_NAME} ${OS_VERSION}\n(${binary} is not Exuberant CTags)"
12346N/A return
12168N/A fi
12346N/A
12158N/A echo ${binary}
12027N/A}
12027N/A
12020N/AFindJavaHome()
12020N/A{
11989N/A javaHome=""
11989N/A case "${OS_NAME}:${OS_VERSION}" in
11426N/A SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
11426N/A SunOS:5.11) javaHome="/usr/jdk/latest" ;;
11406N/A Linux:*)
11406N/A if [ -f /etc/alternatives/java ]
11277N/A then
11277N/A javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `
10960N/A javaHome=`dirname $javaHome`
10960N/A javaHome=`dirname $javaHome`
10960N/A else
10951N/A for dir in /usr/lib/jvm/sun-jdk-1.6 \
10951N/A /usr/lib/jvm/sun-jre-1.6 \
10943N/A /usr/lib/jvm/java-6-sun
10943N/A do
10928N/A if [ -f ${dir}/bin/java ]
10928N/A then
10928N/A javaHome=$dir
10896N/A break;
10896N/A fi
10828N/A done
10828N/A fi
10810N/A ;;
10810N/A esac
10752N/A
10752N/A if [ -z "${javaHome}" ]
10737N/A then
10737N/A Error "Unable to determine Java 6 Home" \
10737N/A "for ${OS_NAME} ${OS_VERSION}"
10737N/A return
10732N/A fi
10732N/A
10701N/A if [ ! -d "${javaHome}" ]
10701N/A then
10701N/A Error "Missing Java Home ${javaHome}"
10687N/A return
10687N/A fi
10573N/A
10573N/A echo "${javaHome}"
10553N/A}
10553N/A
10553N/AFindApplicationServerType()
10553N/A{
10463N/A # Use this function to determine which environment the deploy the
10463N/A # web application function into. Some users (especially
10463N/A # developers) will have many deployment environments or will wish
10318N/A # to specify directly the application server to deploy to.
10318N/A
10307N/A # Either use the environment variable OPENGROK_APP_SERVER or
10307N/A # reimplement this function in your configuration file (as
10295N/A # specified by OPENGROK_CONFIGURATION)
10295N/A
10280N/A if [ -n "${OPENGROK_APP_SERVER}" ]
10280N/A then
10139N/A echo "${OPENGROK_APP_SERVER}"
10139N/A return
10139N/A fi
10139N/A
10139N/A # This implementation favours Tomcat, but needs a lot of work,
10139N/A # especially if Glassfish is perferrerd or it is under the control
10139N/A # of SMF (Service Management Facility)
10139N/A
10139N/A # Maybe a better implementation would be to call Application
10139N/A # Server specific WAR Directory and see if they exist.
10139N/A
10139N/A if [ -d "/var/tomcat6/webapps" \
10139N/A -o -d "/var/lib/tomcat6/webapps" \
10139N/A -o -d "/var/lib/tomcat5/webapps" \
10139N/A -o -d "/var/lib/tomcat5.5/webapps" \
10139N/A ]
10139N/A then
10139N/A echo "Tomcat"
10139N/A return
10139N/A fi
10139N/A
10139N/A if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
10139N/A then
10139N/A echo "Glassfish"
10139N/A return
10139N/A fi
10139N/A
10139N/A # Assume Tomcat
10139N/A echo "Tomcat"
10139N/A}
10139N/A
10139N/ADetermineWarDirectoryTomcat()
10139N/A{
10139N/A if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ]
10139N/A then
10139N/A echo "${OPENGROK_WAR_TARGET_TOMCAT}"
10139N/A return
10139N/A elif [ -n "${OPENGROK_WAR_TARGET}" ]
10139N/A then
10139N/A echo "${OPENGROK_WAR_TARGET}"
10139N/A return
10139N/A fi
10139N/A
10139N/A for prefix in \
10139N/A ${OPENGROK_TOMCAT_BASE} \
10139N/A /var/tomcat6 \
10139N/A /var/lib/tomcat6 \
10139N/A /var/lib/tomcat5 \
10139N/A /var/lib/tomcat5.5 \
10139N/A
10139N/A do
10139N/A if [ -d "${prefix}/webapps" ]
10139N/A then
10139N/A echo "${prefix}/webapps"
10139N/A return
10139N/A fi
10139N/A done
10139N/A}
10139N/A
10139N/ADetermineWarDirectoryGlassfish()
10139N/A{
10139N/A
10139N/A if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ]
10139N/A then
10139N/A echo "${OPENGROK_WAR_TARGET_GLASSFISH}"
10139N/A return
10139N/A elif [ -n "${OPENGROK_WAR_TARGET}" ]
10139N/A then
10139N/A echo "${OPENGROK_WAR_TARGET}"
10139N/A return
10139N/A fi
10139N/A
10139N/A for prefix in \
10139N/A ${OPENGROK_GLASSFISH_BASE} \
10139N/A /var/appserver \
10139N/A
10139N/A do
10139N/A if [ -d "${prefix}/domains" ]
10139N/A then
10139N/A if [ -z "${domainDirectory}" ]
10139N/A then
10139N/A domainDirectory="${prefix}/domains"
10139N/A fi
10139N/A fi
10139N/A done
10139N/A
10139N/A if [ -z "${domainDirectory}" ]
10139N/A then
10139N/A return
10139N/A fi
10139N/A
10139N/A # User Specified Domain
10139N/A if [ -n "${OPENGROK_GLASSFISH_DOMAIN}" ]
10139N/A then
10139N/A directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
10139N/A
10139N/A if [ ! -d "${directory}" ]
10139N/A then
10139N/A FatalError "Missing Specified Glassfish Domain ${OPENGROK_GLASSFISH_DOMAIN}"
10139N/A fi
10139N/A
10139N/A echo "${directory}"
10139N/A return
10139N/A fi
10139N/A
10139N/A # Arbitrary Domain Selection
10139N/A firstDomain=`ls -1 ${domainDirectory} | head -1`
10139N/A
10139N/A if [ -z "${firstDomain}" ]
10139N/A then
10139N/A FatalError "Failed to dynamically determine Glassfish Domain from ${domainDirectory}"
10139N/A fi
10139N/A
10139N/A echo "${domainDirectory}/${firstDomain}/autodeploy"
10139N/A}
10139N/A
10139N/A#
10139N/A# Implementation
10139N/A#
10139N/A# The variable "DO" can usefully be set to "echo" to aid in script debugging
10139N/A#
10139N/A
10139N/ALoadStandardEnvironment()
10139N/A{
10139N/A # Setup a standard execution environment (if required)
10139N/A
10139N/A OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-/pkgs/sbin/CronExecutionEnvironment.sh}"
10139N/A
10139N/A if [ -f "${OPENGROK_STANDARD_ENV}" ]
10139N/A then
10139N/A Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
10139N/A . "${OPENGROK_STANDARD_ENV}"
10139N/A fi
10139N/A}
10139N/A
10139N/ALoadInstanceConfiguration()
10139N/A{
10139N/A # Note: As all functions have been defined by the time this routine
10139N/A # is called, your configuration can, if desired, override functions
10139N/A # in addition to setting the variables mentioned in the function
10139N/A # DefaultInstanceConfiguration(), this maybe useful to override
10139N/A # functionality used to determine the default deployment environment
10139N/A # find dependencies or validate the configuration, for example.
10139N/A
10139N/A if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
10139N/A then
10139N/A # Load the Local OpenGrok Configuration Environment
10139N/A Progress "Loading ${OPENGROK_CONFIGURATION} ..."
10139N/A . "${OPENGROK_CONFIGURATION}"
10139N/A else
10139N/A Progress "Loading the default instance configuration ..."
10139N/A DefaultInstanceConfiguration
10139N/A fi
10139N/A}
10139N/A
10139N/AValidateConfiguration()
10139N/A{
10139N/A if [ ! -x "${EXUBERANT_CTAGS}" ]
10139N/A then
10139N/A FatalError "Missing Dependent Application - Exuberant CTags"
10139N/A fi
10139N/A
10139N/A if [ ! -d "${SRC_ROOT}" ]
10139N/A then
10139N/A FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
10139N/A fi
10139N/A
10139N/A if [ -n "${QUIET}" -a -n "${VERBOSE}" ]
10139N/A then
10139N/A Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose"
10139N/A QUIET=""
10139N/A VERBOSE="-v"
10139N/A fi
10139N/A
10139N/A if [ -n "${OPENGROK_DERBY}" ]
10139N/A then
10139N/A 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 !!!"
10139N/A fi
10139N/A
10139N/A}
10139N/A
10139N/ACreateRuntimeRequirements()
10139N/A{
10139N/A if [ ! -d "${DATA_ROOT}" ]
10139N/A then
10139N/A Warning "OpenGrok generated data path ${DATA_ROOT} doesn't exist"
10139N/A Progress " Attempting to create generated data directory ... "
10139N/A ${DO} mkdir -p "${DATA_ROOT}"
10139N/A fi
10139N/A if [ ! -d "${DATA_ROOT}" ]
10139N/A then
10139N/A FatalError "OpenGrok data path ${DATA_ROOT} doesn't exist"
10139N/A fi
10139N/A
10139N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
10139N/A then
10139N/A Warning "OpenGrok generated etc path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist"
10139N/A Progress " Attempting to create generated etc directory ... "
10139N/A ${DO} mkdir -p "${OPENGROK_INSTANCE_BASE}/etc"
10139N/A fi
10139N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
10139N/A then
10139N/A FatalError "OpenGrok etc path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist"
10139N/A fi
10139N/A
10139N/A if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
10139N/A then
10139N/A Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
10139N/A if [ ! -f "${LOGGER_CONF_SOURCE}" ]
10139N/A then
10139N/A Warning "Can't find distribution logging configuration" \
10139N/A "(${LOGGER_CONF_SOURCE}) to install as default" \
10139N/A "logging configuration (${LOGGER_CONFIG_PATH})"
10139N/A else
10139N/A ${DO} grep -v java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
10139N/A ${DO} grep java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" | sed "s|opengrok%g.%u.log|${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log|g" >> "${LOGGER_CONFIG_PATH}"
10139N/A if [ ! -d ${OPENGROK_INSTANCE_BASE}/log ]
10139N/A then
10139N/A ${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log
10139N/A fi
10139N/A fi
10139N/A fi
10139N/A
10139N/A if [ -n "${OPENGROK_DERBY}" ]
10139N/A then
10139N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/derby" ]
10139N/A then
10139N/A Warning "OpenGrok generated derby path ${OPENGROK_INSTANCE_BASE}/derby doesn't exist"
10139N/A Progress " Attempting to create generated derby directory ... "
10139N/A ${DO} mkdir -p ${OPENGROK_INSTANCE_BASE}/derby
10139N/A fi
10139N/A fi
10139N/A
10139N/A}
10139N/A
10139N/AStdInvocation()
10139N/A{
10139N/A ${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
10139N/A ${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_ADDRESS} \
-s ${SRC_ROOT} -d ${DATA_ROOT} \
"${@}"
}
UpdateGeneratedData()
{
StdInvocation -H
}
UpdateDescriptionCache()
{
# OPTIONAL : Update the EftarFile data
if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ]
then
${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
fi
}
OpenGrokUsage()
{
echo "Options for opengrok.jar:" 1>&2
${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?'
}
DeployWar()
{
applicationServer="`FindApplicationServerType`"
case "${applicationServer}" in
Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
*) FatalError "Unsupported Application Server ${applicationServer}" ;;
esac
if [ -z "${warTarget}" ]
then
FatalError "Unable to determine Deployment Directory for ${applicationServer}"
fi
if [ ! -f "${OPENGROK_DIST_WAR}" ]
then
FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
fi
if [ ! -d "${warTarget}" ]
then
FatalError "Missing Deployment Directory ${warTarget}"
fi
Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
${DO} cp -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
#
# End of File
#