OpenGrok revision f9e7e93ed37cbcb0a111b6f997bb75d567c31c0b
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# OpenGrok Wrapper (initial setup and cron job updating)
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# Supported Operating Systems:
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# - Solaris 11 (SunOS 5.11)
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# - Solaris 12 (SunOS 5.12)
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# - Debian (Linux)
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# Supported Deployment Engines:
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson# Supported Environment Variables:
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# Supported Environment Variables for configuring the default setup:
77527513f94fe78413221a63fd6d383cec32bcafAndreas Gustafsson# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
77527513f94fe78413221a63fd6d383cec32bcafAndreas Gustafsson# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# - EXUBERANT_CTAGS Full Path to Exuberant CTags
021a3183ec1db24e2b9627bdd059a121c56ab886Andreas Gustafsson# - OPENGROK_CTAGS_OPTIONS_FILE Full path to file with extra command line
021a3183ec1db24e2b9627bdd059a121c56ab886Andreas Gustafsson# options for CTags program (for its --options
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# switch), default is DATA_ROOT/etc/ctags.config
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# - JAVA_HOME Full Path to Java Installation Root
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# - JAVA Full Path to java binary (to enable 64bit JDK)
72e278abc7c73059de68017eceae7d5138ee98c1Andreas Gustafsson# - JAVA_OPTS Java options (e.g. for JVM memory increase
72e278abc7c73059de68017eceae7d5138ee98c1Andreas Gustafsson# or enabling server JDK)
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# JAVA_OPTS=-Xmx2048m is the default!
a1bb4b0e4f71fb2878050905087d279cfa87b786Andreas Gustafsson# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
a1bb4b0e4f71fb2878050905087d279cfa87b786Andreas Gustafsson# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
a1bb4b0e4f71fb2878050905087d279cfa87b786Andreas Gustafsson# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
a1bb4b0e4f71fb2878050905087d279cfa87b786Andreas Gustafsson# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
b976f9c60a09f4a098852d0653ad5df6842557a7Andreas Gustafsson# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
a1bb4b0e4f71fb2878050905087d279cfa87b786Andreas Gustafsson# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson# (contains domains)
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# - OPENGROK_PROGRESS Shows progress in %(percentage) of working
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# through project, it's good to have Verbose
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# Mode enabled too, cost of this is one more
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# traversal of the project before indexing it(*)
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# - OPENGROK_REMOTE_REPOS Influence history cache generation for remote
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson# repositories. Following values are recognized:
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson# on - enabled (default)
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# off - disabled for indexing and UI
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# dirbased - indexing enabled only for repos
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# which can fetch history for
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# uionly - enabled for UI only
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# (by default 3 directories from SRC_ROOT)
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# - OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# (use "none" to avoid sending it to web app)
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# - OPENGROK_WEBAPP_CONTEXT Context URL of the OpenGrok webapp
72e278abc7c73059de68017eceae7d5138ee98c1Andreas Gustafsson# (by default /source)
72e278abc7c73059de68017eceae7d5138ee98c1Andreas Gustafsson# - OPENGROK_WPREFIX Disable wildcard prefix search query
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson# - OPENGROK_DERBY if set, then indexer tries to use derby as
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson# historycache (see derby command of this
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson# - OPENGROK_DERBY_URL Use specific URL to JavaDB, e.g.
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson# "jdbc:derby://localhost:1528/cachedb;create=true"
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson# (default port is 1527)
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson# - OPENGROK_TAG Enable parsing of revision tags into the History
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# - READ_XML_CONFIGURATION file with read only configuration
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence# - temporary workaround for bug # 327
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson# - OPENGROK_FLUSH_RAM_BUFFER_SIZE="-m 16" - set RAM buffer size for flushing,
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence# default is 16MB per thread, you might try to
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence# increase it to 256MB, but do increase JVM to
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson# 4/8/16GB ! Lucene defaults to 8 threads.
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson# Increase JVM memory as noted using JAVA_OPTS
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence# (*) Any Non-Empty String will enable these options
1ae59f0202d4dd5f41f978804b092115c6e053eaDavid Lawrence# Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence# Print usage to stdout and exit.
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage|help>"
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence echo " ${progname} clearHistory [<repository_name>]"
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence echo " OPENGROK_CONFIGURATION - location of your configuration"
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... "
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence echo " See the code for more information on configuration options /" \
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrence# Runtime Configuration
04bdb234571448ed6194e1d4048e6512f2446f1cDavid Lawrenceif [ -x "/bin/uname" ]; then
1ae59f0202d4dd5f41f978804b092115c6e053eaDavid Lawrenceelif [ -x "/usr/bin/uname" ]; then
1ae59f0202d4dd5f41f978804b092115c6e053eaDavid Lawrence echo "Cannot determine operating system version"
1ae59f0202d4dd5f41f978804b092115c6e053eaDavid Lawrence# TODO: Handle symlinks correctly (especially in ${0})
04bdb234571448ed6194e1d4048e6512f2446f1cDavid LawrenceSCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
f5eb48652c7ec98514256b5b6e6fd7cbc22b1916Andreas Gustafsson# Default Instance Configuration
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # Use the built-in defaults. This section can be copied to its own
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # file and tailored to your local requirements. Then simply set
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson # this wrapper. It will save you hand editing in your settings
20df5357b17d31a3adc4d6f7cfdd9d4f1c5addf2Andreas Gustafsson # on each new release. A sample cron(1M) entry might look like:
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson # Note: It is not really possible to ever provided defaults for
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson # these values which will run in every UNIX-like environment.
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson # So I have provided a set which are functional for a given
021a3183ec1db24e2b9627bdd059a121c56ab886Andreas Gustafsson # environment on which you can based you own configuration.
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # This has been updated to support more environment variables and
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson # operating systems, if you have any reasonably generic
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # improvements please feel free to submit a patch.
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
021a3183ec1db24e2b9627bdd059a121c56ab886Andreas Gustafsson -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson -f "${SCRIPT_DIRECTORY}/dist/source.war" \
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/"
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson LOGGER_CONF_SOURCE="${LOGGER_CONF_SOURCE}${LOGGER_CONFIG_FILE}"
20df5357b17d31a3adc4d6f7cfdd9d4f1c5addf2Andreas Gustafsson # (your source code or the root of all repositories)
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # (for Lucene index and hypertext cross-references)
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson # This area is rebuilt by "update" / "updateQuietly"
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson DATA_ROOT="${OPENGROK_INSTANCE_BASE}/data"
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # OPTIONAL: User Provided Source Path to Description Mapping
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # (The user maintained source of the generated EftarFile file)
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
export JAVA_HOME
${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
${DO} exit 2
for f in $@
echo $file
found=0
if [ $? -eq 0 ]; then
found=1
echo ${binary}
Linux:*)
if [ -f /etc/alternatives/java ]
${OPENGROK_TOMCAT_BASE} \
if [ ! -d ${OPENGROK_INSTANCE_BASE}/log ]
${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log
${DO} mkdir -p ${OPENGROK_INSTANCE_BASE}/derby
${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
${LOGGER_PROPERTIES} \
${JAVA_DEBUG} \
-jar ${OPENGROK_JAR} \
${IGNORE_PATTERNS} ${ENABLE_PROJECTS} \
${DERBY_OPTIONS} \
${HISTORY_TAGS} \
${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} \
-W ${XML_CONFIGURATION} \
${WEBAPP_CONFIG} \
${WEBAPP_CONTEXT} \
${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
SunOS:5.11)
SunOS:5.12)
mkdir -p $DATA_ROOT/derby
Linux:*)
mkdir -p $DATA_ROOT/derby