OpenGrok revision 1e4f2633aeeca23eeb54f4007ab4f54565b499a7
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco# OpenGrok Wrapper (initial setup and cron job updating)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Operating Systems:
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Solaris 11 (SunOS 5.11)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - Solaris 12 (SunOS 5.12)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Debian (Linux)
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# Supported Deployment Engines:
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Glassfish
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# Supported Environment Variables:
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Environment Variables for configuring the default setup:
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal# - EXUBERANT_CTAGS Full Path to Exuberant CTags
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal# - OPENGROK_CTAGS_OPTIONS_FILE Full path to file with extra command line
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal# options for CTags program (for its --options
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# switch), default is DATA_ROOT/etc/ctags.config
cd71fb134e037849c77364b50940b1870c4684ceVladimir Kotal# - JAVA_HOME Full Path to Java Installation Root
cd71fb134e037849c77364b50940b1870c4684ceVladimir Kotal# - JAVA Full Path to java binary (to enable 64bit JDK)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - JAVA_OPTS Java options (e.g. for JVM memory increase
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# or enabling server JDK)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# JAVA_OPTS=-Xmx2048m is the default!
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# (contains domains)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_PROGRESS Shows progress in %(percentage) of working
b17cb0705d90907337b3528aa7b8ed1700806f26Vladimir Kotal# through project, it's good to have Verbose
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# Mode enabled too, cost of this is one more
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# traversal of the project before indexing it(*)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_GENERATE_HISTORY Influence history cache generation
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# Following values are recognized:
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# on - enabled (default)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# off - disabled for indexing and UI
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# dirbased - indexing enabled only for repos
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# which can fetch history for
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# local - for local repos only
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# uionly - enabled for UI only
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# (by default 3 directories from SRC_ROOT)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# (use "none" to avoid sending it to web app)
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# - OPENGROK_WEBAPP_CONTEXT Context URL of the OpenGrok webapp
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# (by default /source)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - FULL reindex is needed once this is used
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco# (old already indexed files won't be refreshed)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_WPREFIX Disable wildcard prefix search query
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_DERBY if set, then indexer tries to use derby as
cd348e325366620fe047edcc849e3c9424828599Peter Bray# historycache (see derby command of this
cd348e325366620fe047edcc849e3c9424828599Peter Bray# - OPENGROK_DERBY_URL Use specific URL to JavaDB, e.g.
cd348e325366620fe047edcc849e3c9424828599Peter Bray# "jdbc:derby://localhost:1528/cachedb;create=true"
cd348e325366620fe047edcc849e3c9424828599Peter Bray# (default port is 1527)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_TAG Enable parsing of revision tags into the History
43dac746513591adbd09bc4f417feb385f4fd87eVladimir Kotal# - READ_XML_CONFIGURATION file with read only configuration
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco# - temporary workaround for bug # 327
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco# - OPENGROK_FLUSH_RAM_BUFFER_SIZE="-m 16" - set RAM buffer size for flushing,
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco# default is 16MB per thread, you might try to
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco# increase it to 256MB, but do increase JVM to
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco# 4/8/16GB ! Lucene defaults to 8 threads.
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco# Increase JVM memory as noted using JAVA_OPTS
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco# - OPENGROK_LOGGER_CONFIG_PATH Set path to custom logging.properties file.
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco# - OPENGROK_SUBVERSION_USERNAME name of the user that should be used for
f21b682cd9b414738a4f5a38b56f6682e537e1d2Trond Norbye# fetching the history from subversion
f21b682cd9b414738a4f5a38b56f6682e537e1d2Trond Norbye# - OPENGROK_SUBVERSION_PASSWORD password of the user that should be used for
f21b682cd9b414738a4f5a38b56f6682e537e1d2Trond Norbye# fetching the history from subversion
cd348e325366620fe047edcc849e3c9424828599Peter Bray# (*) Any Non-Empty String will enable these options
2cf31ec93bd5d8a2efeab511ce051da51e69aedaLubos Kosco# Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
43dac746513591adbd09bc4f417feb385f4fd87eVladimir Kotal# Print usage to stdout and exit.
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage|help>"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " ${progname} indexpart <src_root> <directory1> [..]"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " ${progname} clearHistory <src_root> <repository_name>"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " OPENGROK_CONFIGURATION - location of your configuration"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... "
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " See the code for more information on configuration options /" \
cd348e325366620fe047edcc849e3c9424828599Peter Bray# Runtime Configuration
cd348e325366620fe047edcc849e3c9424828599Peter Brayif [ -x "/bin/uname" ]; then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Brayelif [ -x "/usr/bin/uname" ]; then
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco echo "Cannot determine operating system version"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# TODO: Handle symlinks correctly (especially in ${0})
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Default Instance Configuration
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Use the built-in defaults. This section can be copied to its own
5e6c91d7e77062129cd0b6ac8aaa546dff216419Lubos Kosco # file and tailored to your local requirements. Then simply set
c83dfde6b364917fa8ed28142d509a7c29a4da68Vladimir Kotal # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
c83dfde6b364917fa8ed28142d509a7c29a4da68Vladimir Kotal # this wrapper. It will save you hand editing in your settings
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # on each new release. A sample cron(1M) entry might look like:
cd348e325366620fe047edcc849e3c9424828599Peter Bray # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Note: It is not really possible to ever provided defaults for
cd348e325366620fe047edcc849e3c9424828599Peter Bray # these values which will run in every UNIX-like environment.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # So I have provided a set which are functional for a given
cd348e325366620fe047edcc849e3c9424828599Peter Bray # environment on which you can based you own configuration.
cd348e325366620fe047edcc849e3c9424828599Peter Bray # This has been updated to support more environment variables and
cd348e325366620fe047edcc849e3c9424828599Peter Bray # operating systems, if you have any reasonably generic
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # improvements please feel free to submit a patch.
0b2998be561e7bf5e3479d686a5af36f712b0d9aVladimir Kotal OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
d7c1415de39f4b07c85828f49cd1ee7a2a19eb9eLubos Kosco OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
c842732324ee4c74ede17887ad1f0dcdc4364a2cLubos Kosco LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONF_SOURCE="${LOGGER_CONF_SOURCE}${LOGGER_CONFIG_FILE}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # (your source code or the root of all repositories)
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (for Lucene index and hypertext cross-references)
cd348e325366620fe047edcc849e3c9424828599Peter Bray # This area is rebuilt by "update" / "updateQuietly"
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal # OPTIONAL: User Provided Source Path to Description Mapping
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal # (The user maintained source of the generated EftarFile file)
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal # (the configuration used by Web/GUI interfaces)
cd348e325366620fe047edcc849e3c9424828599Peter Bray XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
cd348e325366620fe047edcc849e3c9424828599Peter Bray # OPTIONAL: read only XML config, if it exists, it will be read
cd348e325366620fe047edcc849e3c9424828599Peter Bray READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
4f3c0816485669143aa54f1c6461fcb47cf5bc5cVladimir Kotal if [ -n "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then
2b024356b830395446c55f50f9f724a63612e578Lubos Kosco if [ ! -f "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray echo "File ${OPENGROK_LOGGER_CONFIG_PATH} does not exist"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONFIG_PATH=${OPENGROK_LOGGER_CONFIG_PATH}
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco # REQUIRED: Java Archive of OpenGrok (Installation Location)
c842732324ee4c74ede17887ad1f0dcdc4364a2cLubos Kosco OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
c842732324ee4c74ede17887ad1f0dcdc4364a2cLubos Kosco # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (user building from source code will find this and other key
b17cb0705d90907337b3528aa7b8ed1700806f26Vladimir Kotal # files in the "dist" directory after the build is completed)
d6ee3934a24d8ccc0e4bb478405d8e5f6a35825dLubos Kosco OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
8f8c3f4555e5aa3160f03f2e9c55ddbd3381357bLubos Kosco # REQUIRED: Exuberant CTags (http://ctags.sf.net)
d6ee3934a24d8ccc0e4bb478405d8e5f6a35825dLubos Kosco EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: supply extra command line options to CTags program
d70dc22c6dce3f498251b0873638d1fea0e644a3Lubos Kosco if [ -n "${OPENGROK_CTAGS_OPTIONS_FILE}" ]; then
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco CTAGS_OPTIONS_FILE="${OPENGROK_CTAGS_OPTIONS_FILE}"
d70dc22c6dce3f498251b0873638d1fea0e644a3Lubos Kosco elif [ -r "${OPENGROK_INSTANCE_BASE}/etc/ctags.config" ]; then
d70dc22c6dce3f498251b0873638d1fea0e644a3Lubos Kosco CTAGS_OPTIONS_FILE="${OPENGROK_INSTANCE_BASE}/etc/ctags.config"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # DEVELOPMENT: Debug option, if enabled current indexer will listen on the
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray #JAVA_DEBUG="$JAVA_DEBUG,server=y,address=8010,suspend=y"
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco # OPTIONAL: Ignore these patterns as names of files or directories
e87f836e908f8279021f79c8f7bcef98e99d126eLubos Kosco # To ignore skipping just the history cache creation for a particular
e87f836e908f8279021f79c8f7bcef98e99d126eLubos Kosco # directory and all of it's subdirectories, touch an empty
e87f836e908f8279021f79c8f7bcef98e99d126eLubos Kosco # .opengrok_skip_history file at the root of that directory
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco # (Every directory in SRC_ROOT is considered a separate project)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal # OPTIONAL: Scanning Options (for Mercurial repositories)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal # OPTIONAL: Disable remote repository support (CVS or SVN) [on by default]
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal GENERATE_HISTORY="-r ${OPENGROK_GENERATE_HISTORY}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # OPTIONAL: override depth of scanning for repositories
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ "${OPENGROK_WEBAPP_CFGADDR}" = "none" ]; then
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina # OPTIONAL: Context URL of the OpenGrok webapp
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina if [ -n "${OPENGROK_WEBAPP_CONTEXT}" ]; then
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina WEBAPP_CONTEXT="-w ${OPENGROK_WEBAPP_CONTEXT}"
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco # Assumption: We should not set properties to the empty string
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
8f8c3f4555e5aa3160f03f2e9c55ddbd3381357bLubos Kosco${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
d0767114e1a949e4a42358f5aeaa08590b87cd80Trond Norbye${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
3a5046f0538ba9fb3a9429199544a9f4b93d9a4dLubos Kosco${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
3a5046f0538ba9fb3a9429199544a9f4b93d9a4dLubos Kosco${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
3a5046f0538ba9fb3a9429199544a9f4b93d9a4dLubos Kosco${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
3a5046f0538ba9fb3a9429199544a9f4b93d9a4dLubos Kosco${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # OPTIONAL: Store The History Cache in Java DB (derby),
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # - derbyclient.jar - See README.txt for more details
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # - Running Derby Server - Defaults to localhost:1527
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray DERBY_OPTIONS="${DERBY_OPTIONS} -u ${OPENGROK_DERBY_URL}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Turn this off if you want to increase indexing performance a bit
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Usage: <class> inputFile [inputFile ...] outputFile
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
c83dfde6b364917fa8ed28142d509a7c29a4da68Vladimir Kotal # Be Quiet? (set indirectly by command line arguments in the main program)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Helper Functions - Logging
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# In general, non-interactive use like cron jobs and automated
d0767114e1a949e4a42358f5aeaa08590b87cd80Trond Norbye# installation environments should not generate unnecessary
d0767114e1a949e4a42358f5aeaa08590b87cd80Trond Norbye# progress information or warnings, as usage and configuration
d0767114e1a949e4a42358f5aeaa08590b87cd80Trond Norbye# will have generally been debugged prior to automation.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Helper Functions - Autodetection of Runtime Environment
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Search for Exuberant ctags intelligently, skipping
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray $binary --version 2>&1 | grep "Exuberant Ctags" > /dev/null
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ $? -eq 0 ]; then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ $found -eq 1 ]; then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ $found -ne 1 ]; then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Error "Unable to determine Exuberant CTags command name" \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.7.0" ;;
340e2c0d70fade14c720931c87652727b941c167Vladimir Kotal Darwin:*) javaHome=`/usr/libexec/java_home` ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Use this function to determine which environment the deploy the
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # web application function into. Some users (especially
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # developers) will have many deployment environments or will wish
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # to specify directly the application server to deploy to.
d0767114e1a949e4a42358f5aeaa08590b87cd80Trond Norbye # Either use the environment variable OPENGROK_APP_SERVER or
340e2c0d70fade14c720931c87652727b941c167Vladimir Kotal # reimplement this function in your configuration file (as
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # This implementation favours Tomcat, but needs a lot of work,
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # especially if Glassfish is perferrerd or it is under the control
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Maybe a better implementation would be to call Application
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Server specific WAR Directory and see if they exist.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
0b2998be561e7bf5e3479d686a5af36f712b0d9aVladimir Kotal directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Specified Glassfish Domain " \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Failed to dynamically determine Glassfish Domain from " \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${domainDirectory}/${firstDomain}/autodeploy"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Implementation
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# The variable "DO" can usefully be set to "echo" to aid in script debugging
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray # Setup a standard execution environment (if required)
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray cronexec="/pkgs/sbin/CronExecutionEnvironment.sh"
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-$cronexec}"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Load custom configuration and then fill remaining stuff with defaults.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Note: As all functions have been defined by the time this routine
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # is called, your configuration can, if desired, override functions
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco # in addition to setting the variables mentioned in the function
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco # DefaultInstanceConfiguration(), this maybe useful to override
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco # functionality used to determine the default deployment environment
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco # find dependencies or validate the configuration, for example.
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal # Load the Local OpenGrok Configuration Environment
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal Progress "Loading ${OPENGROK_CONFIGURATION} ..."
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco Progress "Loading the default instance configuration ..."
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco FatalError "Missing Dependent Application - Exuberant CTags"
c842732324ee4c74ede17887ad1f0dcdc4364a2cLubos Kosco FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal if [ "`uname -s`" = "SunOS" -a -d /opt/SUNWjavadb -a -d /usr/opengrok ];
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco ! -r "/var/tomcat8/webapps/source/WEB-INF/lib/derbyclient.jar" ];
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco FatalError "JavaDB on but no derbyclient.jar under" \
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal if [ ! -r "/usr/opengrok/lib/derbyclient.jar" ]; then
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal FatalError "JavaDB on but no derbyclient.jar under" \
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal Warning "CHECK: derbyclient.jar needs to be in where the rest of " \
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco "opengrok used jars are and in unpacked source.war in " \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray Warning "OpenGrok generated data path ${DATA_ROOT} doesn't exist"
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina Progress " Attempting to create generated data directory ... "
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "OpenGrok data path ${DATA_ROOT} doesn't exist"
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal Warning "OpenGrok generated etc path ${OPENGROK_INSTANCE_BASE}/etc " \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " Attempting to create generated etc directory ... "
cd348e325366620fe047edcc849e3c9424828599Peter Bray FatalError "OpenGrok etc path ${OPENGROK_INSTANCE_BASE}/etc " \
cd348e325366620fe047edcc849e3c9424828599Peter Bray if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Warning "Can't find distribution logging configuration" \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray "(${LOGGER_CONF_SOURCE}) to install as default" \
cd348e325366620fe047edcc849e3c9424828599Peter Bray fullpath="${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log"
cd348e325366620fe047edcc849e3c9424828599Peter Bray ${DO} grep -v java.util.logging.FileHandler.pattern \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
cd348e325366620fe047edcc849e3c9424828599Peter Bray ${DO} grep java.util.logging.FileHandler.pattern \
cd348e325366620fe047edcc849e3c9424828599Peter Bray sed "s|$filename|$fullpath|g" >> "${LOGGER_CONFIG_PATH}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " Attempting to create generated derby directory ... "
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal ${CTAGS_OPTIONS_FILE:+-o} ${CTAGS_OPTIONS_FILE} \
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal ${OPENGROK_FLUSH_RAM_BUFFER_SIZE} ${SKIN} ${LEADING_WILDCARD} \
c83dfde6b364917fa8ed28142d509a7c29a4da68Vladimir Kotal if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ]
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco ${EFTAR_UPDATE} "${PATH_DESC}" "${EFTAR_OUTPUT_FILE}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${DO} ${JAVA} ${JAVA_OPTS} -jar "${OPENGROK_JAR}" '-?'
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
cd348e325366620fe047edcc849e3c9424828599Peter Bray *) FatalError "Unsupported Application Server ${applicationServer}" ;;
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco FatalError "Unable to determine Deployment Directory for " \
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
cd348e325366620fe047edcc849e3c9424828599Peter Bray FatalError "Missing Deployment Directory ${warTarget}"
if [ "${OPENGROK_INSTANCE_BASE}" != '/var/opengrok' ] || [ "${WEBAPP_CONFIG_ADDRESS}" != 'localhost:2424' ]
sed -i -e 's:/var/opengrok/etc/configuration.xml:'"$XML_CONFIGURATION"':g' "${warTarget}/WEB-INF/web.xml"
SunOS:5.11)
SunOS:5.12)
mkdir -p $DATA_ROOT/derby
Linux:*)
mkdir -p $DATA_ROOT/derby