OpenGrok revision 91a4a0519a6171d9f52be4c514959c0d65c82812
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco# OpenGrok Wrapper (initial setup and cron job updating)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Operating Systems:
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - Solaris 11 (SunOS 5.11)
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# - Solaris 12 (SunOS 5.12)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Debian (Linux)
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# Supported Deployment Engines:
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Glassfish
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# Supported Environment Variables:
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter 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)
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter 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
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - 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
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal# switch), default is DATA_ROOT/etc/ctags.config
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - JAVA_HOME Full Path to Java Installation Root
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# - JAVA Full Path to java binary (to enable 64bit JDK)
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# - JAVA_OPTS Java options (e.g. for JVM memory increase
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# or enabling server JDK)
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# JAVA_OPTS=-Xmx2048m is the default!
03c01ac563d31955fc2b21cd540423434509a494Matt Lewandowsky# - OPENGROK_APP_SERVER Application Server ("Tomcat", "Glassfish" or "Resin")
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
03c01ac563d31955fc2b21cd540423434509a494Matt Lewandowsky# - OPENGROK_WAR_TARGET_RESIN Resin Specific WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# (contains domains)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
03c01ac563d31955fc2b21cd540423434509a494Matt Lewandowsky# - OPENGROK_RESIN_BASE Base Directory for Resin (contains webapps)
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_PROGRESS Shows progress in %(percentage) of working
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir 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(*)
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal# - OPENGROK_GENERATE_HISTORY Influence history cache generation
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal# Following values are recognized:
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal# on - enabled (default)
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal# off - disabled for indexing and UI
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal# dirbased - indexing enabled only for repos
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal# which can fetch history for
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal# local - for local repos only
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal# uionly - enabled for UI only
25d3d16c420712ddaa22503d2b9d1135b7c5eed2Kryštof Tulinger# - OPENGROK_ENABLE_PROJECTS Enable projects (set it to true or false)
25d3d16c420712ddaa22503d2b9d1135b7c5eed2Kryštof Tulinger# Every directory in SRC_ROOT is
25d3d16c420712ddaa22503d2b9d1135b7c5eed2Kryštof Tulinger# considered a separate project
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - 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
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# (use "none" to avoid sending it to web app)
6ce0623fa4ef95af9d77700a1c9c19ec1a919326Guillaume Smet# - OPENGROK_WEBAPP_CONTEXT Context URL of the OpenGrok webapp
6ce0623fa4ef95af9d77700a1c9c19ec1a919326Guillaume Smet# (by default /source)
56c25decc0427c204cd35856e521ddf28337e75dLubos Kosco# - FULL reindex is needed once this is used
56c25decc0427c204cd35856e521ddf28337e75dLubos 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
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# historycache (see derby command of this
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal# - OPENGROK_DERBY_URL Use specific URL to JavaDB, e.g.
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal# "jdbc:derby://localhost:1528/cachedb;create=true"
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal# (default port is 1527)
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina# - OPENGROK_TAG Enable parsing of revision tags into the History
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - READ_XML_CONFIGURATION file with read only configuration
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal# - temporary workaround for bug # 327
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# - OPENGROK_FLUSH_RAM_BUFFER_SIZE="-m 16" - set RAM buffer size for flushing,
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# default is 16MB per thread, you might try to
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# increase it to 256MB, but do increase JVM to
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# 4/8/16GB ! Lucene defaults to 8 threads.
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco# Increase JVM memory as noted using JAVA_OPTS
bc5565fc58603964988b42b6aee40e246f35d94fVladimir Kotal# - OPENGROK_LOGGER_CONFIG_PATH Set path to custom logging.properties file.
9132ad6a7ba5525fd1a6ccd4f4bcb497385c8597ralphmayr# - OPENGROK_SUBVERSION_USERNAME name of the user that should be used for
9132ad6a7ba5525fd1a6ccd4f4bcb497385c8597ralphmayr# fetching the history from subversion
9132ad6a7ba5525fd1a6ccd4f4bcb497385c8597ralphmayr# - OPENGROK_SUBVERSION_PASSWORD password of the user that should be used for
9132ad6a7ba5525fd1a6ccd4f4bcb497385c8597ralphmayr# fetching the history from subversion
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray# (*) Any Non-Empty String will enable these options
91a4a0519a6171d9f52be4c514959c0d65c82812Kryštof Tulinger# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
3b0448fdd830b8d04c6a71511e5d26a4fc3b5b80Lubos Kosco# Print usage to stdout and exit.
3a4816d2417e1abe89a913616de36f200793bea3Vladimir Kotal echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage|help>"
610915d59310c9aba810740e858ba64c5e3e6a2fVladimir Kotal echo " ${progname} indexpart <src_root> <directory1> [..]"
527d116ec0f031818982101f4475298b930d515bVladimir Kotal echo " ${progname} clearHistory <src_root> <repository_name>"
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco echo " OPENGROK_CONFIGURATION - location of your configuration"
fbf97ea1786d1e25add88bbfb91810170473bc9fLubos Kosco echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... "
f21b682cd9b414738a4f5a38b56f6682e537e1d2Trond Norbye echo " See the code for more information on configuration options /" \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Runtime Configuration
c276b1ec9722ee95a86a4a381b39c5f405fc1cc4Vladimir Kotalif [ -x "/bin/uname" ]; then
c276b1ec9722ee95a86a4a381b39c5f405fc1cc4Vladimir Kotalelif [ -x "/usr/bin/uname" ]; then
c276b1ec9722ee95a86a4a381b39c5f405fc1cc4Vladimir Kotal echo "Cannot determine operating system version"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray# TODO: Handle symlinks correctly (especially in ${0})
5a0ed1213a40c9ab7c990b442b77455ee27bc799Vladimir KotalSCRIPT_DIRECTORY=`cd "${SCRIPT_DIRECTORY}"; pwd`
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Default Instance Configuration
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Use the built-in defaults. This section can be copied to its own
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # file and tailored to your local requirements. Then simply set
cd348e325366620fe047edcc849e3c9424828599Peter Bray # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
cd348e325366620fe047edcc849e3c9424828599Peter Bray # 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.
cd348e325366620fe047edcc849e3c9424828599Peter Bray # So I have provided a set which are functional for a given
cd348e325366620fe047edcc849e3c9424828599Peter Bray # environment on which you can based you own configuration.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # This has been updated to support more environment variables and
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # operating systems, if you have any reasonably generic
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # improvements please feel free to submit a patch.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
b34561d2c3d92fac37dbced05ba6a8738e3d20e9Lubos Kosco LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
5e6c91d7e77062129cd0b6ac8aaa546dff216419Lubos Kosco OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
c83dfde6b364917fa8ed28142d509a7c29a4da68Vladimir Kotal LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/"
c83dfde6b364917fa8ed28142d509a7c29a4da68Vladimir Kotal LOGGER_CONF_SOURCE="${LOGGER_CONF_SOURCE}${LOGGER_CONFIG_FILE}"
cd348e325366620fe047edcc849e3c9424828599Peter 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"
0b2998be561e7bf5e3479d686a5af36f712b0d9aVladimir Kotal # OPTIONAL: User Provided Source Path to Description Mapping
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (The user maintained source of the generated EftarFile file)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
c842732324ee4c74ede17887ad1f0dcdc4364a2cLubos Kosco # OPTIONAL: read only XML config, if it exists, it will be read
c842732324ee4c74ede17887ad1f0dcdc4364a2cLubos Kosco READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
bc5565fc58603964988b42b6aee40e246f35d94fVladimir Kotal if [ -n "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then
bc5565fc58603964988b42b6aee40e246f35d94fVladimir Kotal if [ ! -f "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then
bc5565fc58603964988b42b6aee40e246f35d94fVladimir Kotal echo "File ${OPENGROK_LOGGER_CONFIG_PATH} does not exist"
bc5565fc58603964988b42b6aee40e246f35d94fVladimir Kotal LOGGER_CONFIG_PATH=${OPENGROK_LOGGER_CONFIG_PATH}
bc5565fc58603964988b42b6aee40e246f35d94fVladimir Kotal LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # REQUIRED: Java Archive of OpenGrok (Installation Location)
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # (user building from source code will find this and other key
cd348e325366620fe047edcc849e3c9424828599Peter Bray # files in the "dist" directory after the build is completed)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
cd348e325366620fe047edcc849e3c9424828599Peter Bray # REQUIRED: Exuberant CTags (http://ctags.sf.net)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal # OPTIONAL: supply extra command line options to CTags program
e9dbb478e3339d96ce4f0af5c6ab7e1d35ebb86dVladimir Kotal if [ -n "${OPENGROK_CTAGS_OPTIONS_FILE}" ]; then
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal CTAGS_OPTIONS_FILE="${OPENGROK_CTAGS_OPTIONS_FILE}"
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal elif [ -r "${OPENGROK_INSTANCE_BASE}/etc/ctags.config" ]; then
d961aa46ea0d50fed47802497e45226b1965b12dVladimir Kotal CTAGS_OPTIONS_FILE="${OPENGROK_INSTANCE_BASE}/etc/ctags.config"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal # DEVELOPMENT: Debug option, if enabled current indexer will listen on the
4f3c0816485669143aa54f1c6461fcb47cf5bc5cVladimir Kotal #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket"
4f3c0816485669143aa54f1c6461fcb47cf5bc5cVladimir Kotal #JAVA_DEBUG="$JAVA_DEBUG,server=y,address=8010,suspend=y"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Ignore these patterns as names of files or directories
17d95a647aba8c37d9ac34d97e4eed729aa46f67Naseer Ahmed # To ignore skipping just the history cache creation for a particular
17d95a647aba8c37d9ac34d97e4eed729aa46f67Naseer Ahmed # directory and all of it's subdirectories, touch an empty
17d95a647aba8c37d9ac34d97e4eed729aa46f67Naseer Ahmed # .opengrok_skip_history file at the root of that directory
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (Every directory in SRC_ROOT is considered a separate project)
25d3d16c420712ddaa22503d2b9d1135b7c5eed2Kryštof Tulinger OPENGROK_ENABLE_PROJECTS="${OPENGROK_ENABLE_PROJECTS:-true}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # OPTIONAL: Scanning Options (for Mercurial repositories)
b17cb0705d90907337b3528aa7b8ed1700806f26Vladimir Kotal # OPTIONAL: Disable remote repository support (CVS or SVN) [on by default]
9dc24f2da404ab474e38fc4d428e5717dc9bcee4Vladimir Kotal GENERATE_HISTORY="-r ${OPENGROK_GENERATE_HISTORY}"
d70dc22c6dce3f498251b0873638d1fea0e644a3Lubos Kosco # OPTIONAL: override depth of scanning for repositories
6c8465e3b4611cb632cba9b0572e3e3737c8c341Vladimir Kotal WEBAPP_CONFIG_ADDRESS=${OPENGROK_WEBAPP_CFGADDR}
6ce0623fa4ef95af9d77700a1c9c19ec1a919326Guillaume Smet # OPTIONAL: Context URL of the OpenGrok webapp
6ce0623fa4ef95af9d77700a1c9c19ec1a919326Guillaume Smet WEBAPP_CONTEXT="-w ${OPENGROK_WEBAPP_CONTEXT}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Assumption: We should not set properties to the empty string
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
2b024356b830395446c55f50f9f724a63612e578Lubos Kosco${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
2b024356b830395446c55f50f9f724a63612e578Lubos Kosco${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
2b024356b830395446c55f50f9f724a63612e578Lubos Kosco${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
2b024356b830395446c55f50f9f724a63612e578Lubos Kosco${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
2b024356b830395446c55f50f9f724a63612e578Lubos Kosco${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Store The History Cache in Java DB (derby),
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # - derbyclient.jar - See README.txt for more details
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # - Running Derby Server - Defaults to localhost:1527
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal DERBY_OPTIONS="${DERBY_OPTIONS} -u ${OPENGROK_DERBY_URL}"
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina # OPTIONAL: Show revision tags in History view.
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina # Turn this off if you want to increase indexing performance a bit
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Usage: <class> inputFile [inputFile ...] outputFile
cd348e325366620fe047edcc849e3c9424828599Peter Bray # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
cd348e325366620fe047edcc849e3c9424828599Peter Bray EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
cd348e325366620fe047edcc849e3c9424828599Peter Bray EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
cd348e325366620fe047edcc849e3c9424828599Peter Bray # 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
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# installation environments should not generate unnecessary
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# progress information or warnings, as usage and configuration
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# will have generally been debugged prior to automation.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Helper Functions - Autodetection of Runtime Environment
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal file=`which "$f" 2>/dev/null | grep -v '^no '`
f9e7e93ed37cbcb0a111b6f997bb75d567c31c0bVladimir Kotal # Search for Exuberant ctags intelligently, skipping
f9e7e93ed37cbcb0a111b6f997bb75d567c31c0bVladimir Kotal for program in ctags-exuberant exctags ctags; do
f9e7e93ed37cbcb0a111b6f997bb75d567c31c0bVladimir Kotal # Verify that this really is Exuberant Ctags.
f9e7e93ed37cbcb0a111b6f997bb75d567c31c0bVladimir Kotal $binary --version 2>&1 | grep "Exuberant Ctags" > /dev/null
f9e7e93ed37cbcb0a111b6f997bb75d567c31c0bVladimir Kotal if [ $? -eq 0 ]; then
f9e7e93ed37cbcb0a111b6f997bb75d567c31c0bVladimir Kotal if [ $found -eq 1 ]; then
f9e7e93ed37cbcb0a111b6f997bb75d567c31c0bVladimir Kotal if [ $found -ne 1 ]; then
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Error "Unable to determine Exuberant CTags command name" \
c276b1ec9722ee95a86a4a381b39c5f405fc1cc4Vladimir Kotal SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.7.0" ;;
c276b1ec9722ee95a86a4a381b39c5f405fc1cc4Vladimir Kotal Darwin:*) javaHome=`/usr/libexec/java_home` ;;
4e854c69a0484765dcd27b0e837898c8b6969beaTrond Norbye 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.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Either use the environment variable OPENGROK_APP_SERVER or
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # 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" ]
03c01ac563d31955fc2b21cd540423434509a494Matt Lewandowsky if [ -d "/etc/resin" -o -d "/usr/local/share/resin" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal FatalError "Missing Specified Glassfish Domain " \
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal FatalError "Failed to dynamically determine Glassfish Domain from " \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${domainDirectory}/${firstDomain}/autodeploy"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Implementation
cd348e325366620fe047edcc849e3c9424828599Peter Bray# The variable "DO" can usefully be set to "echo" to aid in script debugging
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Setup a standard execution environment (if required)
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal cronexec="/pkgs/sbin/CronExecutionEnvironment.sh"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-$cronexec}"
0b2998be561e7bf5e3479d686a5af36f712b0d9aVladimir Kotal# 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
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # in addition to setting the variables mentioned in the function
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # DefaultInstanceConfiguration(), this maybe useful to override
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # functionality used to determine the default deployment environment
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # find dependencies or validate the configuration, for example.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Load the Local OpenGrok Configuration Environment
0b2998be561e7bf5e3479d686a5af36f712b0d9aVladimir Kotal Progress "Loading the default instance configuration ..."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Dependent Application - Exuberant CTags"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
c577d2f6c082eaff9af5bc997d12f3d3bcef537cPeter Bray Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose"
2aa8eaebd2e6b6f0f0ea3ad62350626305833611Knut Anders Hatlen if [ "`uname -s`" = "SunOS" -a -d /opt/SUNWjavadb -a -d /usr/opengrok ];
00b85c9d9a85faeb07d1570f20b19343feed9239Vladimir Kotal ! -r "/var/tomcat8/webapps/source/WEB-INF/lib/derbyclient.jar" ];
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal FatalError "JavaDB on but no derbyclient.jar under" \
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal if [ ! -r "/usr/opengrok/lib/derbyclient.jar" ]; then
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal FatalError "JavaDB on but no derbyclient.jar under" \
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal Warning "CHECK: derbyclient.jar needs to be in where the rest of " \
83439b4ed8fe40097dc3f2c05168d26bd7926159Vladimir Kotal "opengrok used jars are and in unpacked source.war in " \
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco Warning "OpenGrok generated data path ${DATA_ROOT} doesn't exist"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " Attempting to create generated data directory ... "
477c09a2656e6a2c1075425ad81e61d594164fa9Lubos Kosco FatalError "OpenGrok data path ${DATA_ROOT} doesn't exist"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal Warning "OpenGrok generated etc path ${OPENGROK_INSTANCE_BASE}/etc " \
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco Progress " Attempting to create generated etc directory ... "
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal FatalError "OpenGrok etc path ${OPENGROK_INSTANCE_BASE}/etc " \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
c842732324ee4c74ede17887ad1f0dcdc4364a2cLubos Kosco Warning "Can't find distribution logging configuration" \
c842732324ee4c74ede17887ad1f0dcdc4364a2cLubos Kosco "(${LOGGER_CONF_SOURCE}) to install as default" \
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal fullpath="${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal ${DO} grep -v java.util.logging.FileHandler.pattern \
0b2998be561e7bf5e3479d686a5af36f712b0d9aVladimir Kotal "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal ${DO} grep java.util.logging.FileHandler.pattern \
0b2998be561e7bf5e3479d686a5af36f712b0d9aVladimir Kotal sed "s|$filename|$fullpath|g" >> "${LOGGER_CONFIG_PATH}"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal if [ ! -d "${OPENGROK_INSTANCE_BASE}/derby" ]
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal "${OPENGROK_INSTANCE_BASE}/derby doesn't exist"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal Progress " Attempting to create generated derby directory ... "
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal ${DO} mkdir -p ${OPENGROK_INSTANCE_BASE}/derby
bc5565fc58603964988b42b6aee40e246f35d94fVladimir Kotal ${CTAGS_OPTIONS_FILE:+-o} ${CTAGS_OPTIONS_FILE} \
bc5565fc58603964988b42b6aee40e246f35d94fVladimir Kotal ${OPENGROK_FLUSH_RAM_BUFFER_SIZE} ${SKIN} ${LEADING_WILDCARD} \
5a0ed1213a40c9ab7c990b442b77455ee27bc799Vladimir Kotal ${EFTAR_UPDATE} "${PATH_DESC}" "${EFTAR_OUTPUT_FILE}"
5a0ed1213a40c9ab7c990b442b77455ee27bc799Vladimir Kotal ${DO} ${JAVA} ${JAVA_OPTS} -jar "${OPENGROK_JAR}" '-?'
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
03c01ac563d31955fc2b21cd540423434509a494Matt Lewandowsky Resin) warTarget="`DetermineWarDirectoryResin`" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray *) FatalError "Unsupported Application Server ${applicationServer}" ;;
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal FatalError "Unable to determine Deployment Directory for " \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Deployment Directory ${warTarget}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
561ec0545f30e44833b6def5168abbd3ab5cf65aVladimir Kotal ${DO} cp -p "${OPENGROK_DIST_WAR}" "${warTarget}/"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ $? != 0 ]
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey # Fix for opengrok issue https://github.com/OpenGrok/OpenGrok/issues/863
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey # If user does not use default OPENGROK_INSTANCE_BASE or default
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey # WEBAPP_CONFIG_ADDRESS, then attempt to extract WEB-INF/web.xml from
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey # source.war using jar or zip utility, update the hardcoded values and
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey # then update source.war with the new WEB-INF/web.xml
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey if [ "${OPENGROK_INSTANCE_BASE}" != '/var/opengrok' ] || [ "${WEBAPP_CONFIG_ADDRESS}" != 'localhost:2424' ]
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey elif [ -n "`Which zip`" ] && [ -n "`Which unzip`" ]
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey eval "${EXTRACT_COMMAND} ${warTarget}/source.war WEB-INF/web.xml"
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey if [ "${OPENGROK_INSTANCE_BASE}" != '/var/opengrok' ]
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey sed -i -e 's:/var/opengrok/etc/configuration.xml:'"$XML_CONFIGURATION"':g' "${warTarget}/WEB-INF/web.xml"
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey if [ "${WEBAPP_CONFIG_ADDRESS}" != 'localhost:2424' ]
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey sed -i -e 's/localhost:2424/'"$WEBAPP_CONFIG_ADDRESS"'/g' "${warTarget}/WEB-INF/web.xml"
49bc09b5e021967c9bb83be6215448d40ac675caValery Brobbey eval "${COMPRESS_COMMAND} ${warTarget}/source.war WEB-INF/web.xml"
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal Progress "Start your application server (${applicationServer}), " \
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal Progress "running, or wait until it loads the just installed web " \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "OpenGrok should be available on <HOST>:<PORT>/source"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " where HOST and PORT are configured in ${applicationServer}."
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco echo "Below might need your socket permission setup"
983523cf73bc85cce6282cb5aa78b60f6bcd959fLubos Kosco -jar /usr/jdk/instances/jdk1.7.0/db/lib/derbynet.jar start
56d93b0c761868f813ac0bc0b5bc21a7a9fefd89Vladimir Kotal -jar /usr/lib/jvm/java-6-sun/db/lib/derbynet.jar start
f9d25a875ba43bfe59afe634cca8ad627b3a9fb8Vladimir Kotal# Clear history index for given project.
f9d25a875ba43bfe59afe634cca8ad627b3a9fb8Vladimir Kotal Progress "Removing history index data for repository ${1}"
5a0ed1213a40c9ab7c990b442b77455ee27bc799Vladimir Kotal MinimalInvocation -s "${SRC_ROOT}" -d "${DATA_ROOT}" -k "${1}"
cd348e325366620fe047edcc849e3c9424828599Peter Bray# Main Program
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ -n "${2}" ]
527d116ec0f031818982101f4475298b930d515bVladimir Kotal if [ -z "${1}" ]; then