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