OpenGrok revision 03c01ac563d31955fc2b21cd540423434509a494
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye#!/bin/sh
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye#
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# OpenGrok Wrapper (initial setup and cron job updating)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye#
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# Supported Operating Systems:
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - Solaris 11 (SunOS 5.11)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - Solaris 12 (SunOS 5.12)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - Debian (Linux)
e7b21c8124ec55ffacc49c1e28a8685834715484Lubos Kosco#
e7b21c8124ec55ffacc49c1e28a8685834715484Lubos Kosco# Supported Deployment Engines:
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - Tomcat 8
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - Tomcat 7
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - Tomcat 6
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - Glassfish
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye#
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# Supported Environment Variables:
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal#
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal# Supported Environment Variables for configuring the default setup:
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - EXUBERANT_CTAGS Full Path to Exuberant CTags
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye# - OPENGROK_CTAGS_OPTIONS_FILE Full path to file with extra command line
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# options for CTags program (for its --options
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# switch), default is DATA_ROOT/etc/ctags.config
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - JAVA_HOME Full Path to Java Installation Root
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - JAVA Full Path to java binary (to enable 64bit JDK)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - JAVA_OPTS Java options (e.g. for JVM memory increase
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# or enabling server JDK)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# JAVA_OPTS=-Xmx2048m is the default!
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_APP_SERVER Application Server ("Tomcat", "Glassfish" or "Resin")
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_WAR_TARGET_RESIN Resin Specific WAR Target Directory
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# (contains domains)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_RESIN_BASE Base Directory for Resin (contains webapps)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_PROGRESS Shows progress in %(percentage) of working
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# through project, it's good to have Verbose
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# Mode enabled too, cost of this is one more
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# traversal of the project before indexing it(*)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_GENERATE_HISTORY Influence history cache generation
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# Following values are recognized:
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# on - enabled (default)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# off - disabled for indexing and UI
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# dirbased - indexing enabled only for repos
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# which can fetch history for
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# directory
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# local - for local repos only
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# uionly - enabled for UI only
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# (by default 3 directories from SRC_ROOT)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# (use "none" to avoid sending it to web app)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_WEBAPP_CONTEXT Context URL of the OpenGrok webapp
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# (by default /source)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - FULL reindex is needed once this is used
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# (old already indexed files won't be refreshed)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_WPREFIX Disable wildcard prefix search query
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# support (*)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_DERBY if set, then indexer tries to use derby as
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# historycache (see derby command of this
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# script)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_DERBY_URL Use specific URL to JavaDB, e.g.
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# "jdbc:derby://localhost:1528/cachedb;create=true"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# (default port is 1527)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_TAG Enable parsing of revision tags into the History
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# view
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - READ_XML_CONFIGURATION file with read only configuration
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - temporary workaround for bug # 327
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_FLUSH_RAM_BUFFER_SIZE="-m 16" - set RAM buffer size for flushing,
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# default is 16MB per thread, you might try to
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# increase it to 256MB, but do increase JVM to
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# 4/8/16GB ! Lucene defaults to 8 threads.
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# Increase JVM memory as noted using JAVA_OPTS
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_LOGGER_CONFIG_PATH Set path to custom logging.properties file.
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_SUBVERSION_USERNAME name of the user that should be used for
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# fetching the history from subversion
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# - OPENGROK_SUBVERSION_PASSWORD password of the user that should be used for
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# fetching the history from subversion
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# Notes:
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# (*) Any Non-Empty String will enable these options
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# Print usage to stdout and exit.
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.comUsage()
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com{
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com progname=`basename $0`
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com exec >&2
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo ""
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage|help>"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo " ${progname} index [<directory>]"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo " ${progname} indexpart <src_root> <directory1> [..]"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo " ${progname} clearHistory <src_root> <repository_name>"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo ""
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo " Optional environment variables:"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo " OPENGROK_CONFIGURATION - location of your configuration"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... "
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo ""
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo " See the code for more information on configuration options /" \
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com "variables"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo ""
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com exit 1
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com}
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# Runtime Configuration
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.comif [ -x "/bin/uname" ]; then
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com OS_NAME="`/bin/uname -s`"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com OS_VERSION="`/bin/uname -r`"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.comelif [ -x "/usr/bin/uname" ]; then
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com OS_NAME="`/usr/bin/uname -s`"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com OS_VERSION="`/usr/bin/uname -r`"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.comelse
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com echo "Cannot determine operating system version"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com exit 1
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.comfi
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# TODO: Handle symlinks correctly (especially in ${0})
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.comSCRIPT_DIRECTORY=`dirname "${0}"`
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.comSCRIPT_DIRECTORY=`cd "${SCRIPT_DIRECTORY}"; pwd`
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com# Default Instance Configuration
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com#
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.comDefaultInstanceConfiguration()
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com{
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # Use the built-in defaults. This section can be copied to its own
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # file and tailored to your local requirements. Then simply set
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # this wrapper. It will save you hand editing in your settings
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # on each new release. A sample cron(1M) entry might look like:
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # Note: It is not really possible to ever provided defaults for
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # these values which will run in every UNIX-like environment.
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # So I have provided a set which are functional for a given
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # environment on which you can based you own configuration.
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # This has been updated to support more environment variables and
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # operating systems, if you have any reasonably generic
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # improvements please feel free to submit a patch.
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com LOGGER_CONFIG_FILE="logging.properties"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com then
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com if [ -d "${SCRIPT_DIRECTORY}/dist" -a \
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com -f "${SCRIPT_DIRECTORY}/dist/source.war" \
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye ]
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye then
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # Handle Developer Build Environments
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye else
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # Handle Binary Distributions
d3f4f9ed01f6a0b171d0a81c630f5708e47adb7avitezslav batrla - Sun Microsystems - Prague Czech Republic OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
d3f4f9ed01f6a0b171d0a81c630f5708e47adb7avitezslav batrla - Sun Microsystems - Prague Czech Republic LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/"
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye LOGGER_CONF_SOURCE="${LOGGER_CONF_SOURCE}${LOGGER_CONFIG_FILE}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com fi
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye fi
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # REQUIRED: Source Code/Repository Root
d3f4f9ed01f6a0b171d0a81c630f5708e47adb7avitezslav batrla - Sun Microsystems - Prague Czech Republic # (your source code or the root of all repositories)
d3f4f9ed01f6a0b171d0a81c630f5708e47adb7avitezslav batrla - Sun Microsystems - Prague Czech Republic SRC_ROOT="${OPENGROK_INSTANCE_BASE}/src"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
d3f4f9ed01f6a0b171d0a81c630f5708e47adb7avitezslav batrla - Sun Microsystems - Prague Czech Republic # REQUIRED: OpenGrok Generate Data Root
d3f4f9ed01f6a0b171d0a81c630f5708e47adb7avitezslav batrla - Sun Microsystems - Prague Czech Republic # (for Lucene index and hypertext cross-references)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # This area is rebuilt by "update" / "updateQuietly"
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye DATA_ROOT="${OPENGROK_INSTANCE_BASE}/data"
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # OPTIONAL: User Provided Source Path to Description Mapping
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # (Tab Separated Value)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # (The user maintained source of the generated EftarFile file)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
5e6c91d7e77062129cd0b6ac8aaa546dff216419Lubos Kosco
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # REQUIRED: XML Configuration
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # (the configuration used by Web/GUI interfaces)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # OPTIONAL: read only XML config, if it exists, it will be read
5e6c91d7e77062129cd0b6ac8aaa546dff216419Lubos Kosco READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com if [ -f "${READ_XML_CONFIGURATION}" ] ; then
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com READ_XML_CONF="-R ${READ_XML_CONFIGURATION}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com fi
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # REQUIRED: Logger Configuration
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com if [ -n "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye if [ ! -f "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then
5e6c91d7e77062129cd0b6ac8aaa546dff216419Lubos Kosco echo "File ${OPENGROK_LOGGER_CONFIG_PATH} does not exist"
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye exit 1
2beeb43d1acdbe44396687878d0376762b696fb5Lubos Kosco fi
6ba6a49186aff8de4dc5251195b9917021b5ee69Knut Anders Hatlen LOGGER_CONFIG_PATH=${OPENGROK_LOGGER_CONFIG_PATH}
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com else
6ba6a49186aff8de4dc5251195b9917021b5ee69Knut Anders Hatlen LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye fi
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # REQUIRED: Java Archive of OpenGrok (Installation Location)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # (user building from source code will find this and other key
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye # files in the "dist" directory after the build is completed)
d20db9dd18673cf482111b9cd3ecc6823d0e45a3Trond Norbye OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # REQUIRED: Exuberant CTags (http://ctags.sf.net)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # OPTIONAL: supply extra command line options to CTags program
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com if [ -n "${OPENGROK_CTAGS_OPTIONS_FILE}" ]; then
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com CTAGS_OPTIONS_FILE="${OPENGROK_CTAGS_OPTIONS_FILE}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com elif [ -r "${OPENGROK_INSTANCE_BASE}/etc/ctags.config" ]; then
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com CTAGS_OPTIONS_FILE="${OPENGROK_INSTANCE_BASE}/etc/ctags.config"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com fi
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # REQUIRED: Java Home
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com JAVA_HOME="${JAVA_HOME:-`FindJavaHome`}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com export JAVA_HOME
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # REQUIRED: Java Virtual Machine
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com JAVA="${JAVA:-$JAVA_HOME/bin/java}"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # DEVELOPMENT: Debug option, if enabled current indexer will listen on the
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # port 8010 until a debugger connects
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com #JAVA_DEBUG="$JAVA_DEBUG,server=y,address=8010,suspend=y"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # OPTIONAL: Ignore these patterns as names of files or directories
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com #IGNORE_PATTERNS="-i dummy"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # To ignore skipping just the history cache creation for a particular
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # directory and all of it's subdirectories, touch an empty
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # .opengrok_skip_history file at the root of that directory
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # OPTIONAL: Enable Projects
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com # (Every directory in SRC_ROOT is considered a separate project)
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com ENABLE_PROJECTS="-P"
8bdb629053c6752f21668f2af5f336109439b15bkrystof.tulinger@oracle.com
9dc9150bbde9e7ccd68afb4a6eca9f4f1a928c87Trond Norbye # OPTIONAL: Scanning Options (for Mercurial repositories)
SCAN_FOR_REPOSITORY="-S"
if [ -n "${OPENGROK_SCAN_REPOS}" ]
then
SCAN_FOR_REPOSITORY=""
fi
# OPTIONAL: Disable remote repository support (CVS or SVN) [on by default]
GENERATE_HISTORY="-r on"
if [ -n "${OPENGROK_GENERATE_HISTORY}" ]
then
GENERATE_HISTORY="-r ${OPENGROK_GENERATE_HISTORY}"
fi
if [ "$OPENGROK_GENERATE_HISTORY" != "off" ]
then
GENERATE_HISTORY="${GENERATE_HISTORY} -H"
fi
# OPTIONAL: override depth of scanning for repositories
if [ -n "${OPENGROK_SCAN_DEPTH}" ]
then
SCAN_DEPTH="-z${OPENGROK_SCAN_DEPTH}"
fi
# OPTIONAL: Allow Leading Wildcard Searches
# (default: on)
LEADING_WILDCARD="-a on"
if [ -n "${OPENGROK_WPREFIX}" ]
then
LEADING_WILDCARD=""
fi
# OPTIONAL: Web Site Look & Feel
# (Options: default, offwhite and polished.
# Note the quoting requirements)
#SKIN='-L default'
# OPTIONAL: Configuration Address (host:port)
# (conf/web.xml default is localhost:2424)
WEBAPP_CONFIG=""
if [ -n "${OPENGROK_WEBAPP_CFGADDR}" ]; then
WEBAPP_CONFIG_ADDRESS=${OPENGROK_WEBAPP_CFGADDR}
if [ "${OPENGROK_WEBAPP_CFGADDR}" = "none" ]; then
WEBAPP_CONFIG_ADDRESS=""
fi
else
WEBAPP_CONFIG_ADDRESS="localhost:2424"
fi
if [ -n "${WEBAPP_CONFIG_ADDRESS}" ]; then
WEBAPP_CONFIG="-U ${WEBAPP_CONFIG_ADDRESS}"
fi
# OPTIONAL: Context URL of the OpenGrok webapp
# (default is /source)
WEBAPP_CONTEXT=""
if [ -n "${OPENGROK_WEBAPP_CONTEXT}" ]; then
WEBAPP_CONTEXT="-w ${OPENGROK_WEBAPP_CONTEXT}"
fi
# OPTIONAL: JVM Options
JAVA_OPTS="${JAVA_OPTS:--Xmx2048m}"
# OPTIONAL: Full Path to History Utilities
HG="`Which hg`"
CVS="`Which cvs`"
SVN="`Which svn`"
SCCS="`Which sccs`"
CLEARCASE="`Which cleartool`"
GIT="`Which git`"
P4="`Which p4`"
MTN="`Which mtn`"
BZR="`Which bzr`"
# OPTIONAL: Override Built-in Properties
# Assumption: We should not set properties to the empty string
PROPERTIES="\
${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
"
# OPTIONAL: Store The History Cache in Java DB (derby),
# instead of file system (in gzipped xml files).
#
# Requirements:
# - derbyclient.jar - See README.txt for more details
# - Running Derby Server - Defaults to localhost:1527
#
if [ -n "${OPENGROK_DERBY}" ]
then
DERBY_OPTIONS="-D"
if [ -n "${OPENGROK_DERBY_URL}" ]; then
DERBY_OPTIONS="${DERBY_OPTIONS} -u ${OPENGROK_DERBY_URL}"
fi
fi
# OPTIONAL: Show revision tags in History view.
# Turn this off if you want to increase indexing performance a bit
# (default: off)
if [ -n "${OPENGROK_TAG}" ]
then
HISTORY_TAGS="-G"
fi
# DELIVERED: An update program for EftarFile
# Usage: <class> inputFile [inputFile ...] outputFile
# EftarFile == An Extremely Fast Tagged Attribute Read-only File System
EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
# HARDCODED: Generated EftarFile (See web/*.jsp)
EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
# Be Quiet? (set indirectly by command line arguments in the main program)
#QUIET=""
# or alternatively, Be Verbose!
#VERBOSE="-v"
if [ -n "${OPENGROK_VERBOSE}" ]
then
VERBOSE="-v"
QUIET=""
fi
if [ -n "${OPENGROK_PROGRESS}" ]
then
PROGRESS="-C"
fi
}
#
# Helper Functions - Logging
#
# In general, non-interactive use like cron jobs and automated
# installation environments should not generate unnecessary
# progress information or warnings, as usage and configuration
# will have generally been debugged prior to automation.
#
Progress()
{
if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
then
echo "${@}"
fi
}
Warning()
{
if [ -z "${OPENGROK_NON_INTERACTIVE}" ]
then
echo "WARNING: ${@}" 1>&2
fi
}
Error()
{
echo "ERROR: ${@}" 1>&2
}
FatalError()
{
exec >&2
echo ""
echo "FATAL ERROR: ${@} - Aborting!"
echo ""
${DO} exit 2
}
#
# Helper Functions - Autodetection of Runtime Environment
#
Which()
{
path="`which ${1} 2>/dev/null`"
if [ -x "${path}" ]
then
echo "${path}"
fi
}
LocateBinary() {
for f in $@
do
file=`which "$f" 2>/dev/null | grep -v '^no '`
if test -n "$file" -a -x "$file"
then
echo $file
return 0
fi
done
echo ""
return 1
}
FindExuberantCTags()
{
#
# Search for Exuberant ctags intelligently, skipping
# over other ctags implementations.
#
binary=""
found=0
for program in ctags-exuberant exctags ctags; do
for path in `echo $PATH | tr ':' '\n'`; do
if [ -x "$path/$program" ]; then
binary="$path/$program"
# Verify that this really is Exuberant Ctags.
$binary --version 2>&1 | grep "Exuberant Ctags" > /dev/null
if [ $? -eq 0 ]; then
found=1
break
fi
fi
done
if [ $found -eq 1 ]; then
break;
fi
done
if [ $found -ne 1 ]; then
Error "Unable to determine Exuberant CTags command name" \
"for ${OS_NAME} ${OS_VERSION}"
return
fi
echo ${binary}
}
FindJavaHome()
{
javaHome=""
case "${OS_NAME}:${OS_VERSION}" in
SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.7.0" ;;
SunOS:5.11) javaHome="/usr/jdk/latest" ;;
SunOS:5.12) javaHome="/usr/jdk/latest" ;;
Darwin:*) javaHome=`/usr/libexec/java_home` ;;
Linux:*)
if [ -f /etc/alternatives/java ]
then
javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `
javaHome=`dirname $javaHome`
javaHome=`dirname $javaHome`
fi
;;
esac
if [ -z "${javaHome}" ]
then
Error "Unable to determine Java 7 Home" \
"for ${OS_NAME} ${OS_VERSION}"
return
fi
if [ ! -d "${javaHome}" ]
then
Error "Missing Java Home ${javaHome}"
return
fi
echo "${javaHome}"
}
FindApplicationServerType()
{
# Use this function to determine which environment the deploy the
# web application function into. Some users (especially
# developers) will have many deployment environments or will wish
# to specify directly the application server to deploy to.
# Either use the environment variable OPENGROK_APP_SERVER or
# reimplement this function in your configuration file (as
# specified by OPENGROK_CONFIGURATION)
if [ -n "${OPENGROK_APP_SERVER}" ]
then
echo "${OPENGROK_APP_SERVER}"
return
fi
# This implementation favours Tomcat, but needs a lot of work,
# especially if Glassfish is perferrerd or it is under the control
# of SMF (Service Management Facility)
# Maybe a better implementation would be to call Application
# Server specific WAR Directory and see if they exist.
if [ -d "/var/tomcat8/webapps" \
-o -d "/var/lib/tomcat8/webapps" \
]
then
echo "Tomcat"
return
fi
if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
then
echo "Glassfish"
return
fi
if [ -d "/etc/resin" -o -d "/usr/local/share/resin" ]
then
echo "Resin"
return
fi
# Assume Tomcat
echo "Tomcat"
}
DetermineWarDirectoryTomcat()
{
if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ]
then
echo "${OPENGROK_WAR_TARGET_TOMCAT}"
return
elif [ -n "${OPENGROK_WAR_TARGET}" ]
then
echo "${OPENGROK_WAR_TARGET}"
return
fi
for prefix in \
${OPENGROK_TOMCAT_BASE} \
/var/lib/tomcat8 \
/var/tomcat8
do
if [ -d "${prefix}/webapps" ]
then
echo "${prefix}/webapps"
return
fi
done
}
DetermineWarDirectoryGlassfish()
{
if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ]
then
echo "${OPENGROK_WAR_TARGET_GLASSFISH}"
return
elif [ -n "${OPENGROK_WAR_TARGET}" ]
then
echo "${OPENGROK_WAR_TARGET}"
return
fi
for prefix in \
${OPENGROK_GLASSFISH_BASE} \
/var/appserver
do
if [ -d "${prefix}/domains" ]
then
if [ -z "${domainDirectory}" ]
then
domainDirectory="${prefix}/domains"
fi
fi
done
if [ -z "${domainDirectory}" ]
then
return
fi
# User Specified Domain
if [ -n "${OPENGROK_GLASSFISH_DOMAIN}" ]
then
directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
if [ ! -d "${directory}" ]
then
FatalError "Missing Specified Glassfish Domain " \
"${OPENGROK_GLASSFISH_DOMAIN}"
fi
echo "${directory}"
return
fi
# Arbitrary Domain Selection
firstDomain=`ls -1 ${domainDirectory} | head -1`
if [ -z "${firstDomain}" ]
then
FatalError "Failed to dynamically determine Glassfish Domain from " \
"${domainDirectory}"
fi
echo "${domainDirectory}/${firstDomain}/autodeploy"
}
DetermineWarDirectoryResin()
{
if [ -n "${OPENGROK_WAR_TARGET_RESIN}" ]
then
echo "${OPENGROK_WAR_TARGET_RESIN}"
return
elif [ -n "${OPENGROK_WAR_TARGET}" ]
then
echo "${OPENGROK_WAR_TARGET}"
return
fi
for prefix in \
${OPENGROK_RESIN_BASE} \
/var/resin \
/opt/resin
do
if [ -d "${prefix}/webapps" ]
then
echo "${prefix}/webapps"
return
fi
done
}
#
# Implementation
#
# The variable "DO" can usefully be set to "echo" to aid in script debugging
#
LoadStandardEnvironment()
{
# Setup a standard execution environment (if required)
cronexec="/pkgs/sbin/CronExecutionEnvironment.sh"
OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-$cronexec}"
if [ -f "${OPENGROK_STANDARD_ENV}" ]
then
Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
. "${OPENGROK_STANDARD_ENV}"
fi
}
#
# Load custom configuration and then fill remaining stuff with defaults.
#
LoadInstanceConfiguration()
{
#
# Note: As all functions have been defined by the time this routine
# is called, your configuration can, if desired, override functions
# in addition to setting the variables mentioned in the function
# DefaultInstanceConfiguration(), this maybe useful to override
# functionality used to determine the default deployment environment
# find dependencies or validate the configuration, for example.
#
if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
then
# Load the Local OpenGrok Configuration Environment
Progress "Loading ${OPENGROK_CONFIGURATION} ..."
. "${OPENGROK_CONFIGURATION}"
fi
Progress "Loading the default instance configuration ..."
DefaultInstanceConfiguration
}
ValidateConfiguration()
{
if [ ! -x "${EXUBERANT_CTAGS}" ]
then
FatalError "Missing Dependent Application - Exuberant CTags"
fi
if [ ! -d "${SRC_ROOT}" ]
then
FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
fi
if [ -n "${QUIET}" -a -n "${VERBOSE}" ]
then
Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose"
QUIET=""
VERBOSE="-v"
fi
if [ -n "${OPENGROK_DERBY}" ]
then
if [ "`uname -s`" = "SunOS" -a -d /opt/SUNWjavadb -a -d /usr/opengrok ];
then
if [ -d "/var/tomcat8" -a \
! -r "/var/tomcat8/webapps/source/WEB-INF/lib/derbyclient.jar" ];
then
FatalError "JavaDB on but no derbyclient.jar under" \
"/var/tomcat8/webapps/source/WEB-INF/lib"
fi
if [ ! -r "/usr/opengrok/lib/derbyclient.jar" ]; then
FatalError "JavaDB on but no derbyclient.jar under" \
"/usr/opengrok/lib"
fi
else
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 !"
fi
fi
}
CreateRuntimeRequirements()
{
if [ ! -d "${DATA_ROOT}" ]
then
Warning "OpenGrok generated data path ${DATA_ROOT} doesn't exist"
Progress " Attempting to create generated data directory ... "
${DO} mkdir -p "${DATA_ROOT}"
fi
if [ ! -d "${DATA_ROOT}" ]
then
FatalError "OpenGrok data path ${DATA_ROOT} doesn't exist"
fi
if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
then
Warning "OpenGrok generated etc path ${OPENGROK_INSTANCE_BASE}/etc " \
"doesn't exist"
Progress " Attempting to create generated etc directory ... "
${DO} mkdir -p "${OPENGROK_INSTANCE_BASE}/etc"
fi
if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
then
FatalError "OpenGrok etc path ${OPENGROK_INSTANCE_BASE}/etc " \
"doesn't exist"
fi
if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
then
Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
if [ ! -f "${LOGGER_CONF_SOURCE}" ]
then
Warning "Can't find distribution logging configuration" \
"(${LOGGER_CONF_SOURCE}) to install as default" \
"logging configuration (${LOGGER_CONFIG_PATH})"
else
filename="opengrok%g.%u.log"
fullpath="${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log"
${DO} grep -v java.util.logging.FileHandler.pattern \
"${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
${DO} grep java.util.logging.FileHandler.pattern \
"${LOGGER_CONF_SOURCE}" | \
sed "s|$filename|$fullpath|g" >> "${LOGGER_CONFIG_PATH}"
if [ ! -d ${OPENGROK_INSTANCE_BASE}/log ]
then
${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log
fi
fi
fi
if [ -n "${OPENGROK_DERBY}" ]
then
if [ ! -d "${OPENGROK_INSTANCE_BASE}/derby" ]
then
Warning "OpenGrok generated derby path " \
"${OPENGROK_INSTANCE_BASE}/derby doesn't exist"
Progress " Attempting to create generated derby directory ... "
${DO} mkdir -p ${OPENGROK_INSTANCE_BASE}/derby
fi
fi
}
MinimalInvocation()
{
${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
${JAVA_DEBUG} \
${LOGGER_PROPERTIES} \
-jar "${OPENGROK_JAR}" \
${VERBOSE} ${QUIET} \
"${@}"
}
CommonInvocation()
{
MinimalInvocation \
${IGNORE_PATTERNS} \
${DERBY_OPTIONS} \
${HISTORY_TAGS} \
${GENERATE_HISTORY} \
${SCAN_DEPTH} \
${PROGRESS} \
${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
${CTAGS_OPTIONS_FILE:+-o} ${CTAGS_OPTIONS_FILE} \
${OPENGROK_FLUSH_RAM_BUFFER_SIZE} ${SKIN} ${LEADING_WILDCARD} \
${READ_XML_CONF} \
"${@}"
}
StdInvocation()
{
CommonInvocation \
-W ${XML_CONFIGURATION} \
${SCAN_FOR_REPOSITORY} \
${ENABLE_PROJECTS} \
${WEBAPP_CONFIG} \
${WEBAPP_CONTEXT} \
-s "${SRC_ROOT}" \
-d "${DATA_ROOT}" \
"${@}"
}
UpdateGeneratedData()
{
StdInvocation
}
UpdateDataPartial()
{
extra_args=""
for arg in "$@"; do
if [ -n "$extra_args" ]; then
extra_args="$extra_args -h $arg"
else
extra_args="-h $arg"
fi
done
CommonInvocation $extra_args "$@"
}
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`" ;;
Resin) warTarget="`DetermineWarDirectoryResin`" ;;
*) 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
# Fix for opengrok issue https://github.com/OpenGrok/OpenGrok/issues/863
# If user does not use default OPENGROK_INSTANCE_BASE or default
# WEBAPP_CONFIG_ADDRESS, then attempt to extract WEB-INF/web.xml from
# source.war using jar or zip utility, update the hardcoded values and
# then update source.war with the new WEB-INF/web.xml
if [ "${OPENGROK_INSTANCE_BASE}" != '/var/opengrok' ] || [ "${WEBAPP_CONFIG_ADDRESS}" != 'localhost:2424' ]
then
EXTRACT_COMMAND=""
COMPRESS_COMMAND=""
if [ -n "`Which jar`" ]
then
EXTRACT_COMMAND="jar -xf"
COMPRESS_COMMAND="jar -uf"
elif [ -n "`Which zip`" ] && [ -n "`Which unzip`" ]
then
EXTRACT_COMMAND="unzip"
COMPRESS_COMMAND="zip -rf"
fi
if [ -n "${EXTRACT_COMMAND}" ]
then
cd "${warTarget}"
eval "${EXTRACT_COMMAND} ${warTarget}/source.war WEB-INF/web.xml"
if [ "${OPENGROK_INSTANCE_BASE}" != '/var/opengrok' ]
then
sed -i -e 's:/var/opengrok/etc/configuration.xml:'"$XML_CONFIGURATION"':g' "${warTarget}/WEB-INF/web.xml"
fi
if [ "${WEBAPP_CONFIG_ADDRESS}" != 'localhost:2424' ]
then
sed -i -e 's/localhost:2424/'"$WEBAPP_CONFIG_ADDRESS"'/g' "${warTarget}/WEB-INF/web.xml"
fi
eval "${COMPRESS_COMMAND} ${warTarget}/source.war WEB-INF/web.xml"
rm -rf "${warTarget}/WEB-INF"
fi
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
;;
SunOS:5.12)
echo "Below might need your socket permission setup"
echo "see JDK1.7_51 release notes"
set -x
mkdir -p $DATA_ROOT/derby
java -Dderby.system.home=$DATA_ROOT/derby \
-jar /usr/jdk/instances/jdk1.7.0/db/lib/derbynet.jar start
;;
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
}
#
# Clear history index for given project.
#
ClearHistory()
{
Progress "Removing history index data for repository ${1}"
MinimalInvocation -s "${SRC_ROOT}" -d "${DATA_ROOT}" -k "${1}"
}
#
# Main Program
#
if [ $# -eq 0 ]
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 [ $# -gt 2 ]
then
Usage
fi
if [ -n "${2}" ]
then
SRC_ROOT="${2}"
fi
ValidateConfiguration
CreateRuntimeRequirements
UpdateGeneratedData
UpdateDescriptionCache
;;
indexpart)
if [ $# -ne 3 ]
then
Usage
fi
SRC_ROOT="${2}"
shift 2
ValidateConfiguration
CreateRuntimeRequirements
UpdateDataPartial $@
;;
clearHistory)
if [ $# -ne 3 ]
then
Usage
fi
SRC_ROOT="${2}"
shift 2
if [ -z "${1}" ]; then
Usage
fi
ClearHistory "${1}"
;;
usage|help)
OpenGrokUsage
Usage
;;
*)
Usage
;;
esac