OpenGrok revision cd348e325366620fe047edcc849e3c9424828599
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch#!/bin/sh
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen# OpenGrok Wrapper (Interactive GUI, Initial Generation and Cron Job Updating)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen# Usage
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo SirainenUsage()
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen{
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen echo 1>&2
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen echo "Usage: ${0} <update|updateQuietly|updateConfiguration|usage|gui>" 1>&2
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen echo 1>&2
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen exit 1
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen}
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen# Configuration
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainenif [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainenthen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # Load the Local OpenGrok Configuration Environment
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen . "${OPENGROK_CONFIGURATION}"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainenelse
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # Use the built-in defaults. This section can be copied to its own
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # file and tailored to your local requirements. Then simply set
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # this wrapper. It will save you hand editing in your settings
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # on each new release. A sample Cron Entry might look like:
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen # Note: It is not really possible to ever provided defaults for
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # these values which will run in every UNIX-like environment.
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # So I have provided a set which are functional for a given
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # environment on which you can based you own configuration.
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # Setup a standard execution environment
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen if [ -f /pkgs/sbin/CronExecutionEnvironment.sh ]
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen then
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen . /pkgs/sbin/CronExecutionEnvironment.sh
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen fi
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # REQUIRED: Source Code/Repository Root
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # (your source code or the root of all repositories)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen SRC_ROOT="/data/opengrok/src"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # REQUIRED: OpenGrok Generate Data Root
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # (for Lucene index and hypertext cross-references)
cc4087c4d7b1b6188dc731e783cee361f1e9c185Timo Sirainen # This area is rebuilt by "update" / "updateQuietly"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen DATA_ROOT="/data/opengrok/data"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # (The user maintained source of the generated EftarFile file)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen PATH_DESC="/data/opengrok/etc/paths.tsv"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # REQUIRED: XML Configuration
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # (the configuration used by Web/GUI interfaces)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen XML_CONFIGURATION="/data/opengrok/configuration.xml"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # REQUIRED: Java Archive of OpenGrok
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # (user building from source code will find this other key
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # files in the "dist" directory after the build is completed)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen OPENGROK_JAR="/data/opengrok/opengrok.jar"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # REQUIRED: Exuberant CTags (http://ctags.sf.net)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen EXUBERANT_CTAGS="/pkgs/64-bit/release/ctags-5.7/bin/ctags"
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # REQUIRED: Java Home
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen JAVA_HOME="/usr/jdk/instances/jdk1.6.0"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen export JAVA_HOME
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
73bc59c2a56ff351ae7c4d9f52de76b1b0173995Timo Sirainen # REQUIRED: Java Virtual Machine
73bc59c2a56ff351ae7c4d9f52de76b1b0173995Timo Sirainen JAVA="${JAVA_HOME}/bin/java"
73bc59c2a56ff351ae7c4d9f52de76b1b0173995Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # OPTIONAL: Uncomment the following line if your source contains Mercurial repositories.
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen SCAN_FOR_REPOSITORY="-S"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # OPTIONAL: Override Built-in Properties
bb2b3656ef7635acc374f7fc19b25aeeb454ae95Timo Sirainen PROPERTIES="-Dorg.opensolaris.opengrok.history.Mercurial=/pkgs/bin/hg"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # OPTIONAL: JVM Options
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen #JAVA_OPTS="-server -Xmx1024m"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # DELIVERED: An update program for EftarFile
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # Usage: <class> inputFile [inputFile ...] outputFile
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # HARDCODED: Generated EftarFile (See web/*.jsp)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # Be Quiet? (set indirectly by command line arguments in the main program)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen QUIET=
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen # or alternatively, Be Verbose!
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen #VERBOSE="-v"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainenfi
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen# Implementation
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen# The variable "DO" can usefully be set to "echo" to aid in script debugging
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo SirainenStdInvocation()
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen{
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen -jar ${OPENGROK_JAR} \
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ${SCAN_FOR_REPOSITORY} ${VERBOSE} ${QUIET} \
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen -s ${SRC_ROOT} -d ${DATA_ROOT} \
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen "${@}"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen}
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo SirainenUpdateGeneratedConfiguration()
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen{
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen StdInvocation -W ${XML_CONFIGURATION}
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen}
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo SirainenUpdateGeneratedData()
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen{
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen StdInvocation -H
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen}
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo SirainenUpdateDescriptionCache()
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen{
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen # OPTIONAL : Update the EftarFile data
191eb75dd8c688dc1669492b842233decaf9caccTimo Sirainen
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen if [ -n "${PATH_DESC}" -o -s "${PATH_DESC}" ]
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen then
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen fi
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen}
191eb75dd8c688dc1669492b842233decaf9caccTimo Sirainen
191eb75dd8c688dc1669492b842233decaf9caccTimo SirainenInvokeGUI()
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen{
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} &
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen}
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo SirainenOpenGrokUsage()
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen{
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?'
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen}
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen# Main Program
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen#
75113e5fa7532ef628f273caac2feec6008992c6Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainenif [ $# -ne 1 ]
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainenthen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen Usage
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainenfi
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainencase "${1}" in
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen update)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen UpdateGeneratedData
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen UpdateDescriptionCache
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ;;
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen updateQuietly)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen QUIET="-q"
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen VERBOSE=""
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen UpdateGeneratedData
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen UpdateDescriptionCache
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ;;
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen updateConfiguration)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen UpdateGeneratedConfiguration
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ;;
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen usage)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen OpenGrokUsage
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ;;
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen gui)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen InvokeGUI
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ;;
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen *)
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen Usage
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen ;;
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainenesac
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen
6b2738c39a868ff9291867138c55029fc40cf105Timo Sirainen#
902acc26200957a1f04da3cc947211f0b9ffce05Timo Sirainen# End of File
902acc26200957a1f04da3cc947211f0b9ffce05Timo Sirainen#
902acc26200957a1f04da3cc947211f0b9ffce05Timo Sirainen