OpenGrok revision 949
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# OpenGrok Wrapper (initial setup and cron job updating)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Supported Operating Systems:
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - Solaris 10 (SunOS 5.10)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OpenSolaris (SunOS 5.11)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - Debian (Linux)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Supported Deployment Engines:
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - Tomcat 5.5
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - Glassfish
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Supported Environment Variables:
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Supported Environment Variables for configuring the default setup:
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk# - EXUBERANT_CTAGS Full Path to Exuberant CTags
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - JAVA_HOME Full Path to Java Installation Root
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_REMOTE_REPOS Disable History Cache for (remote) Repositories (*)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)_
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# - READ_XML_CONFIGURATION file with read only configuration - a temp workaround for bug # 327
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# (*) Any Non-Empty String will enable these options
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk echo "Usage: ${0} <deploy|update|updateQuietly|usage>" 1>&2
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk echo " OPENGROK_CONFIGURATION - location of your configuration" 1>&2
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk echo " See the code for more information on configuration options / variables" 1>&2
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Runtime Configuration
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# TODO: Handle symlinks correctly (especially in ${0})
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Default Instance Configuration
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # Use the built-in defaults. This section can be copied to its own
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # file and tailored to your local requirements. Then simply set
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # this wrapper. It will save you hand editing in your settings
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # on each new release. A sample cron(1M) entry might look like:
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # Note: It is not really possible to ever provided defaults for
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # these values which will run in every UNIX-like environment.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # So I have provided a set which are functional for a given
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # environment on which you can based you own configuration.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # This has been updated to support more environment variables and
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # operating systems, if you have any reasonably generic
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # improvements please feel free to submit a patch.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/${LOGGER_CONFIG_FILE}"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # (your source code or the root of all repositories)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # (for Lucene index and hypertext cross-references)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # This area is rebuilt by "update" / "updateQuietly"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # (The user maintained source of the generated EftarFile file)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # (the configuration used by Web/GUI interfaces)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # OPTIONAL: read only XML config, if it exists, it will be read
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # REQUIRED: Java Archive of OpenGrok (Installation Location)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # (user building from source code will find this and other key
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # files in the "dist" directory after the build is completed)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # REQUIRED: Exuberant CTags (http://ctags.sf.net)
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # DEVELOPMENT: Debug option, if enabled current indexer will listen on the port 8010 until a debugger connects
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,address=8010,suspend=y"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # OPTIONAL: Ignore these patterns as names of files or directories
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # (Every directory in SRC_ROOT is considered a separate project)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # OPTIONAL: Scanning Options (for Mercurial repositories)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # OPTIONAL: Remote Repository Support (CVS or SVN)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # (Can be very time demanding, uncomment if needed)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # Note, that you might run out of memory, then either increase JVM memory
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # as noted in JAVA_OPTS, or set this limit(if you don't mind opengrok not
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # indexing the rest of the file, once the limit is reached)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # Assumption: We should not set properties to the empty string
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # OPTIONAL: Store The History Cache in Java DB (derby),
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk # instead of file system (in gzipped xml files).
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # - derbyclient.jar - See README.txt for more details
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # - Running Derby Server - Defaults to localhost:1527
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # Usage: <class> inputFile [inputFile ...] outputFile
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk # HARDCODED: Generated EftarFile (See web/*.jsp)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk # Be Quiet? (set indirectly by command line arguments in the main program)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# Helper Functions - Logging
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk# In general, non-interactive use like cron jobs and automated
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# installation environments should not generate unnecessary
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# progress information or warnings, as usage and configuration
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# will have generally been debugged prior to automation.
${DO} exit 2
${OPENGROK_TOMCAT_BASE} \
${DO} grep -v java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
${DO} grep java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" | sed "s|opengrok%g.%u.log|${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log|g" >> "${LOGGER_CONFIG_PATH}"
${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log
${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
${LOGGER_PROPERTIES} \
${JAVA_DEBUG} \
-jar ${OPENGROK_JAR} \
${IGNORE_PATTERNS} ${ENABLE_PROJECTS} \
${DERBY_HISTORY_CACHE} \
${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
${MAX_INDEXED_WORDS} ${SKIN} ${LEADING_WILDCARD} \
${READ_XML_CONF} \
-W ${XML_CONFIGURATION} \
${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}