OpenGrok revision bc5565fc58603964988b42b6aee40e246f35d94f
f85aab2e1a371d4575eaaf03bf926c116b4c791eAndreas Gustafsson# OpenGrok Wrapper (initial setup and cron job updating)
f690123c15ce847b78eb68ba842a94c88a8e5529Michael Graff# Supported Operating Systems:
f690123c15ce847b78eb68ba842a94c88a8e5529Michael Graff# - Solaris 11 (SunOS 5.11)
f690123c15ce847b78eb68ba842a94c88a8e5529Michael Graff# - Solaris 12 (SunOS 5.12)
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# - Debian (Linux)
f85aab2e1a371d4575eaaf03bf926c116b4c791eAndreas Gustafsson# Supported Deployment Engines:
f85aab2e1a371d4575eaaf03bf926c116b4c791eAndreas Gustafsson# Supported Environment Variables:
f85aab2e1a371d4575eaaf03bf926c116b4c791eAndreas Gustafsson# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
f85aab2e1a371d4575eaaf03bf926c116b4c791eAndreas Gustafsson# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
f690123c15ce847b78eb68ba842a94c88a8e5529Michael Graff# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington# Supported Environment Variables for configuring the default setup:
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - EXUBERANT_CTAGS Full Path to Exuberant CTags
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_CTAGS_OPTIONS_FILE Full path to file with extra command line
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# options for CTags program (for its --options
6a759e38699d133302d0df120d7afcd4af721951David Lawrence# switch), default is DATA_ROOT/etc/ctags.config
79d91e915023ffa5fac1bb2f91f19210bb18407cBrian Wellington# - JAVA_HOME Full Path to Java Installation Root
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - JAVA Full Path to java binary (to enable 64bit JDK)
e8892697f98b9154cd390c13205b75d1f038fd4dBrian Wellington# - JAVA_OPTS Java options (e.g. for JVM memory increase
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence# or enabling server JDK)
364a82f7c25b62967678027043425201a5e5171aBob Halley# JAVA_OPTS=-Xmx2048m is the default!
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
90fc267992241a9d6adcae478666726d23c97326David Lawrence# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence# (contains domains)
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
e8892697f98b9154cd390c13205b75d1f038fd4dBrian Wellington# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
e8892697f98b9154cd390c13205b75d1f038fd4dBrian Wellington# - OPENGROK_PROGRESS Shows progress in %(percentage) of working
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence# through project, it's good to have Verbose
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# Mode enabled too, cost of this is one more
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# traversal of the project before indexing it(*)
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_REMOTE_REPOS Influence history cache generation for remote
49f7148b1e61fc383c7d41081ca48b1255a0c143Brian Wellington# repositories. Following values are recognized:
a67fc7e1ff1e39ebf5e58a77b2ee413615ff1ff3Brian Wellington# on - enabled (default)
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# off - disabled for indexing and UI
a67fc7e1ff1e39ebf5e58a77b2ee413615ff1ff3Brian Wellington# dirbased - indexing enabled only for repos
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# which can fetch history for
b1d234eb75e2804e09d89178a76df39c321db51bBrian Wellington# uionly - enabled for UI only
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go
b1d234eb75e2804e09d89178a76df39c321db51bBrian Wellington# (by default 3 directories from SRC_ROOT)
b1d234eb75e2804e09d89178a76df39c321db51bBrian Wellington# - OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to
7efc8c3f692fc3226c00ce8bdc1b90eb06562352David Lawrence# (use "none" to avoid sending it to web app)
b1d234eb75e2804e09d89178a76df39c321db51bBrian Wellington# - OPENGROK_WEBAPP_CONTEXT Context URL of the OpenGrok webapp
3de75141d2e042a1db4c58b397ea4fc905cecf6eBrian Wellington# (by default /source)
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# - FULL reindex is needed once this is used
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# (old already indexed files won't be refreshed)
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# - OPENGROK_WPREFIX Disable wildcard prefix search query
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# - OPENGROK_DERBY if set, then indexer tries to use derby as
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# historycache (see derby command of this
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# - OPENGROK_DERBY_URL Use specific URL to JavaDB, e.g.
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# "jdbc:derby://localhost:1528/cachedb;create=true"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# (default port is 1527)
2b71493ae644557c48a906f889ef50127f418b17Brian Wellington# - OPENGROK_TAG Enable parsing of revision tags into the History
2b71493ae644557c48a906f889ef50127f418b17Brian Wellington# - READ_XML_CONFIGURATION file with read only configuration
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington# - temporary workaround for bug # 327
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_FLUSH_RAM_BUFFER_SIZE="-m 16" - set RAM buffer size for flushing,
79d91e915023ffa5fac1bb2f91f19210bb18407cBrian Wellington# default is 16MB per thread, you might try to
417bd845e5f72c6cdefcdb5d1c53d591f9337885Brian Wellington# increase it to 256MB, but do increase JVM to
e8892697f98b9154cd390c13205b75d1f038fd4dBrian Wellington# 4/8/16GB ! Lucene defaults to 8 threads.
e8892697f98b9154cd390c13205b75d1f038fd4dBrian Wellington# Increase JVM memory as noted using JAVA_OPTS
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# - OPENGROK_LOGGER_CONFIG_PATH Set path to custom logging.properties file.
d6a2af163f61cad7ab014a9dd5dc0f35920b1ed3David Lawrence# (*) Any Non-Empty String will enable these options
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington# Print usage to stdout and exit.
b18192fd96726bf2cf553bd0e209dfe231abb1d9Brian Wellington echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage|help>"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington echo " ${progname} indexpart [<directory1> ..]"
b72b07e79bdcd81c81e2f8858b6882f6605cdfcdBrian Wellington echo " ${progname} clearHistory [<repository_name>]"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington echo " OPENGROK_CONFIGURATION - location of your configuration"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... "
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington echo " See the code for more information on configuration options /" \
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington# Runtime Configuration
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellingtonif [ -x "/bin/uname" ]; then
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellingtonelif [ -x "/usr/bin/uname" ]; then
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington echo "Cannot determine operating system version"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# TODO: Handle symlinks correctly (especially in ${0})
923d87d9f4bb3068a0db63ef54a547ec31004029David LawrenceSCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington# Default Instance Configuration
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # Use the built-in defaults. This section can be copied to its own
b8dd48ecf83142f6ee7238cbd68fec455e527fc8Mark Andrews # file and tailored to your local requirements. Then simply set
49f7148b1e61fc383c7d41081ca48b1255a0c143Brian Wellington # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # this wrapper. It will save you hand editing in your settings
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # on each new release. A sample cron(1M) entry might look like:
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # Note: It is not really possible to ever provided defaults for
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # these values which will run in every UNIX-like environment.
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # So I have provided a set which are functional for a given
a9bc95f22ef2dd4a12e79be99412c9f18b814a5dBrian Wellington # environment on which you can based you own configuration.
a67fc7e1ff1e39ebf5e58a77b2ee413615ff1ff3Brian Wellington # This has been updated to support more environment variables and
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # operating systems, if you have any reasonably generic
49f7148b1e61fc383c7d41081ca48b1255a0c143Brian Wellington # improvements please feel free to submit a patch.
b3ef06344abad0105be99b622e615dcbd87911e1Brian Wellington OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
c50936eb40263b65ebf6afe4e6556e2dc67c10e4Brian Wellington OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington LOGGER_CONF_SOURCE="${LOGGER_CONF_SOURCE}${LOGGER_CONFIG_FILE}"
2d478b7049ae12dcd610e497424d85fc46de4a02Brian Wellington # (your source code or the root of all repositories)
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # (for Lucene index and hypertext cross-references)
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # This area is rebuilt by "update" / "updateQuietly"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington # OPTIONAL: User Provided Source Path to Description Mapping
587368b24760f9a23836d1b3920567cd62cc4bffBrian Wellington # (The user maintained source of the generated EftarFile file)
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington # (the configuration used by Web/GUI interfaces)
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington # OPTIONAL: read only XML config, if it exists, it will be read
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington if [ -f "${READ_XML_CONFIGURATION}" ] ; then
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington READ_XML_CONF="-R ${READ_XML_CONFIGURATION}"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington if [ -n "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington if [ ! -f "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington echo "File ${OPENGROK_LOGGER_CONFIG_PATH} does not exist"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington LOGGER_CONFIG_PATH=${OPENGROK_LOGGER_CONFIG_PATH}
3d452d43660bf364910d664df5329609062e9b1aBrian Wellington LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
a15583c68146644225dc1c1c5279c63db4685265Brian Wellington LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # REQUIRED: Java Archive of OpenGrok (Installation Location)
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
2d478b7049ae12dcd610e497424d85fc46de4a02Brian Wellington # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
2d478b7049ae12dcd610e497424d85fc46de4a02Brian Wellington # (user building from source code will find this and other key
2d478b7049ae12dcd610e497424d85fc46de4a02Brian Wellington # files in the "dist" directory after the build is completed)
2d478b7049ae12dcd610e497424d85fc46de4a02Brian Wellington OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # REQUIRED: Exuberant CTags (http://ctags.sf.net)
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # OPTIONAL: supply extra command line options to CTags program
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington if [ -n "${OPENGROK_CTAGS_OPTIONS_FILE}" ]; then
b8dd48ecf83142f6ee7238cbd68fec455e527fc8Mark Andrews CTAGS_OPTIONS_FILE="${OPENGROK_CTAGS_OPTIONS_FILE}"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington elif [ -r "${OPENGROK_INSTANCE_BASE}/etc/ctags.config" ]; then
3d452d43660bf364910d664df5329609062e9b1aBrian Wellington CTAGS_OPTIONS_FILE="${OPENGROK_INSTANCE_BASE}/etc/ctags.config"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington # DEVELOPMENT: Debug option, if enabled current indexer will listen on the
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington #JAVA_DEBUG="$JAVA_DEBUG,server=y,address=8010,suspend=y"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # OPTIONAL: Ignore these patterns as names of files or directories
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # To ignore skipping just the history cache creation for a particular
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # directory and all of it's subdirectories, touch an empty
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # .opengrok_skip_history file at the root of that directory
2c02fd5316dc9bb03a6fd77bf5a02949a23a8e9aBrian Wellington # (Every directory in SRC_ROOT is considered a separate project)
6a285c816d1c5f82afbcc92f7f5928ce8e9f9ffaBrian Wellington # OPTIONAL: Scanning Options (for Mercurial repositories)
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # OPTIONAL: Disable remote repository support (CVS or SVN) [on by default]
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington REMOTE_REPOSITORIES="-r ${OPENGROK_REMOTE_REPOS}"
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington # OPTIONAL: override depth of scanning for repositories
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # OPTIONAL: Allow Leading Wildcard Searches
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # (Options: default, offwhite and polished.
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # OPTIONAL: Configuration Address (host:port)
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington if [ -n "${OPENGROK_WEBAPP_CFGADDR}" ]; then
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington WEBAPP_CONFIG_ADDRESS=${OPENGROK_WEBAPP_CFGADDR}
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington if [ "${OPENGROK_WEBAPP_CFGADDR}" == "none" ]; then
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington WEBAPP_CONFIG="-U ${WEBAPP_CONFIG_ADDRESS}"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # OPTIONAL: Context URL of the OpenGrok webapp
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington if [ -n "${OPENGROK_WEBAPP_CONTEXT}" ]; then
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington WEBAPP_CONTEXT="-w ${OPENGROK_WEBAPP_CONTEXT}"
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # Assumption: We should not set properties to the empty string
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # OPTIONAL: Store The History Cache in Java DB (derby),
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # instead of file system (in gzipped xml files).
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # - derbyclient.jar - See README.txt for more details
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # - Running Derby Server - Defaults to localhost:1527
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington DERBY_OPTIONS="${DERBY_OPTIONS} -u ${OPENGROK_DERBY_URL}"
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # OPTIONAL: Show revision tags in History view.
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # Turn this off if you want to increase indexing performance a bit
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # DELIVERED: An update program for EftarFile
3d452d43660bf364910d664df5329609062e9b1aBrian Wellington # Usage: <class> inputFile [inputFile ...] outputFile
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
b18192fd96726bf2cf553bd0e209dfe231abb1d9Brian Wellington # HARDCODED: Generated EftarFile (See web/*.jsp)
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # Be Quiet? (set indirectly by command line arguments in the main program)
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington# Helper Functions - Logging
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington# In general, non-interactive use like cron jobs and automated
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington# installation environments should not generate unnecessary
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington# progress information or warnings, as usage and configuration
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington# will have generally been debugged prior to automation.
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington# Helper Functions - Autodetection of Runtime Environment
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington file=`which "$f" 2>/dev/null | grep -v '^no '`
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # Search for Exuberant ctags intelligently, skipping
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington for program in ctags-exuberant exctags ctags; do
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington # Verify that this really is Exuberant Ctags.
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington $binary --version 2>&1 | grep "Exuberant Ctags" > /dev/null
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington if [ $? -eq 0 ]; then
aabfa856aaa78e3f2db9a1b727f9b72cdd6e7a08Brian Wellington if [ $found -eq 1 ]; then
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington if [ $found -ne 1 ]; then
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington Error "Unable to determine Exuberant CTags command name" \
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.7.0" ;;
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington Darwin:*) javaHome=`/usr/libexec/java_home` ;;
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # Use this function to determine which environment the deploy the
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # web application function into. Some users (especially
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # developers) will have many deployment environments or will wish
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # to specify directly the application server to deploy to.
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # Either use the environment variable OPENGROK_APP_SERVER or
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington # reimplement this function in your configuration file (as
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington # This implementation favours Tomcat, but needs a lot of work,
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington # especially if Glassfish is perferrerd or it is under the control
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington # Maybe a better implementation would be to call Application
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington # Server specific WAR Directory and see if they exist.
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ]
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington FatalError "Missing Specified Glassfish Domain " \
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington firstDomain=`ls -1 ${domainDirectory} | head -1`
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington FatalError "Failed to dynamically determine Glassfish Domain from " \
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington echo "${domainDirectory}/${firstDomain}/autodeploy"
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington# Implementation
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington# The variable "DO" can usefully be set to "echo" to aid in script debugging
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # Setup a standard execution environment (if required)
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington cronexec="/pkgs/sbin/CronExecutionEnvironment.sh"
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-$cronexec}"
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington# Load custom configuration and then fill remaining stuff with defaults.
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # Note: As all functions have been defined by the time this routine
924fbebfbe77eda7240d4638abe410234295782fBrian Wellington # is called, your configuration can, if desired, override functions
2d478b7049ae12dcd610e497424d85fc46de4a02Brian Wellington # in addition to setting the variables mentioned in the function
2d478b7049ae12dcd610e497424d85fc46de4a02Brian Wellington # DefaultInstanceConfiguration(), this maybe useful to override
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington # functionality used to determine the default deployment environment
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington # find dependencies or validate the configuration, for example.
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
417bd845e5f72c6cdefcdb5d1c53d591f9337885Brian Wellington # Load the Local OpenGrok Configuration Environment
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington Progress "Loading ${OPENGROK_CONFIGURATION} ..."
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington Progress "Loading the default instance configuration ..."
2e9fe863e176fef538f2fe4882507b4a668cbf44Brian Wellington FatalError "Missing Dependent Application - Exuberant CTags"
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
245d9f25a767be585dad02075ea2fb671f5c0b64Brian Wellington Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington if [ `uname -s` == "SunOS" -a -d /opt/SUNWjavadb -a -d /usr/opengrok ];
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington ! -r "/var/tomcat6/webapps/source/WEB-INF/lib/derbyclient.jar" ];
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington FatalError "JavaDB on but no derbyclient.jar under" \
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington if [ ! -r "/usr/opengrok/lib/derbyclient.jar" ]; then
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington FatalError "JavaDB on but no derbyclient.jar under" \
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington Warning "CHECK: derbyclient.jar needs to be in where the rest of " \
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington "opengrok used jars are and in unpacked source.war in " \
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington Warning "OpenGrok generated data path ${DATA_ROOT} doesn't exist"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington Progress " Attempting to create generated data directory ... "
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington FatalError "OpenGrok data path ${DATA_ROOT} doesn't exist"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington Warning "OpenGrok generated etc path ${OPENGROK_INSTANCE_BASE}/etc " \
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington Progress " Attempting to create generated etc directory ... "
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington ${DO} mkdir -p "${OPENGROK_INSTANCE_BASE}/etc"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ]
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington FatalError "OpenGrok etc path ${OPENGROK_INSTANCE_BASE}/etc " \
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington Warning "Can't find distribution logging configuration" \
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington "(${LOGGER_CONF_SOURCE}) to install as default" \
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington "logging configuration (${LOGGER_CONFIG_PATH})"
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington fullpath="${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log"
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington ${DO} grep -v java.util.logging.FileHandler.pattern \
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington ${DO} grep java.util.logging.FileHandler.pattern \
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington sed "s|$filename|$fullpath|g" >> "${LOGGER_CONFIG_PATH}"
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington if [ ! -d "${OPENGROK_INSTANCE_BASE}/derby" ]
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington "${OPENGROK_INSTANCE_BASE}/derby doesn't exist"
abce4875c33782ea88253a92d6f6391b3be88995Brian Wellington Progress " Attempting to create generated derby directory ... "
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington ${DO} mkdir -p ${OPENGROK_INSTANCE_BASE}/derby
b4d8cb6bf78a7735db9da12eb8c3c07782c91151Brian Wellington ${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
b20de477c21b7a493fb7f56cdb97ba8bdd573273Brian Wellington ${CTAGS_OPTIONS_FILE:+-o} ${CTAGS_OPTIONS_FILE} \
bf5582ad4b2b464539059fba2806b546ec3c5caaBrian Wellington ${OPENGROK_FLUSH_RAM_BUFFER_SIZE} ${SKIN} ${LEADING_WILDCARD} \
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ]
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington ${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington ${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?'
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington applicationServer="`FindApplicationServerType`"
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington *) FatalError "Unsupported Application Server ${applicationServer}" ;;
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington FatalError "Unable to determine Deployment Directory for " \
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington FatalError "Missing Deployment Directory ${warTarget}"
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington ${DO} cp -p "${OPENGROK_DIST_WAR}" "${warTarget}/"
f104fbbe4e868a039ed786c0087c0412ab6dd923Brian Wellington if [ $? != 0 ]
af9cc9f1337fcaac0b15698589980e3e8dec21eeBrian Wellington FatalError "Web Application Installation FAILED"
e8892697f98b9154cd390c13205b75d1f038fd4dBrian Wellington Progress "Start your application server (${applicationServer}), " \
af9cc9f1337fcaac0b15698589980e3e8dec21eeBrian Wellington Progress "running, or wait until it loads the just installed web " \
3aa0851a581f9c4e5b68256910ff98b97564363fBrian Wellington Progress "OpenGrok should be available on <HOST>:<PORT>/source"
3aa0851a581f9c4e5b68256910ff98b97564363fBrian Wellington Progress " where HOST and PORT are configured in ${applicationServer}."
af9cc9f1337fcaac0b15698589980e3e8dec21eeBrian Wellington echo "Below might need your socket permission setup"
417bd845e5f72c6cdefcdb5d1c53d591f9337885Brian Wellington java -Dderby.system.home=$DATA_ROOT/derby \
2d478b7049ae12dcd610e497424d85fc46de4a02Brian Wellington -jar /usr/jdk/instances/jdk1.7.0/db/lib/derbynet.jar start
417bd845e5f72c6cdefcdb5d1c53d591f9337885Brian Wellington java -Dderby.system.home=$DATA_ROOT/derby \
417bd845e5f72c6cdefcdb5d1c53d591f9337885Brian Wellington -jar /usr/lib/jvm/java-6-sun/db/lib/derbynet.jar start
201b17e55f32d0c92f5d0814713efc71ca11076aBrian Wellington# Clear history index for given project.
201b17e55f32d0c92f5d0814713efc71ca11076aBrian Wellington Progress "Removing history index data for repository ${1}"
4fc4813eb3bb3c4b0fbcb4b3052ef162d2a1ca04Brian Wellington# Main Program
e8892697f98b9154cd390c13205b75d1f038fd4dBrian Wellington if [ -n "${2}" ]
3fe99b84d6e61a4b3bc00fe391fa746c8e76c004Brian Wellington if [ -z "${2}" ]
417bd845e5f72c6cdefcdb5d1c53d591f9337885Brian Wellington if [ -z "${2}" ]; then