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