OpenGrok revision 03c01ac563d31955fc2b21cd540423434509a494
10139N/A# OpenGrok Wrapper (initial setup and cron job updating) 10139N/A# Supported Environment Variables: 10139N/A# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*) 10139N/A# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script) 10139N/A# - OPENGROK_CONFIGURATION User Configuration (Shell Script) 10139N/A# Supported Environment Variables for configuring the default setup: 10318N/A# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution 10139N/A# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area 10139N/A# - EXUBERANT_CTAGS Full Path to Exuberant CTags 10139N/A# - OPENGROK_CTAGS_OPTIONS_FILE Full path to file with extra command line 10139N/A# options for CTags program (for its --options 10139N/A# - JAVA_HOME Full Path to Java Installation Root 10139N/A# - JAVA Full Path to java binary (to enable 64bit JDK) 10139N/A# - JAVA_OPTS Java options (e.g. for JVM memory increase 10139N/A# JAVA_OPTS=-Xmx2048m is the default! 10139N/A# - OPENGROK_APP_SERVER Application Server ("Tomcat", "Glassfish" or "Resin") 10139N/A# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory 10139N/A# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory 10139N/A# - OPENGROK_WAR_TARGET_RESIN Resin Specific WAR Target Directory 10139N/A# - OPENGROK_WAR_TARGET Fallback WAR Target Directory 10139N/A# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps) 10139N/A# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish 10139N/A# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name 10139N/A# - OPENGROK_RESIN_BASE Base Directory for Resin (contains webapps) 10139N/A# - OPENGROK_PROGRESS Shows progress in %(percentage) of working 10139N/A# through project, it's good to have Verbose 10139N/A# Mode enabled too, cost of this is one more 10139N/A# traversal of the project before indexing it(*) 10139N/A# - OPENGROK_GENERATE_HISTORY Influence history cache generation 10139N/A# Following values are recognized: 10139N/A# off - disabled for indexing and UI 10139N/A# dirbased - indexing enabled only for repos 10139N/A# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*) 10139N/A# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go 10139N/A# (by default 3 directories from SRC_ROOT) 10139N/A# - OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to 10139N/A# (use "none" to avoid sending it to web app) 10139N/A# - OPENGROK_WEBAPP_CONTEXT Context URL of the OpenGrok webapp 10139N/A# - FULL reindex is needed once this is used 10139N/A# (old already indexed files won't be refreshed) 10139N/A# - OPENGROK_WPREFIX Disable wildcard prefix search query 10139N/A# - OPENGROK_DERBY if set, then indexer tries to use derby as 10139N/A# historycache (see derby command of this 10139N/A# - OPENGROK_DERBY_URL Use specific URL to JavaDB, e.g. 10139N/A# "jdbc:derby://localhost:1528/cachedb;create=true" 10139N/A# - OPENGROK_TAG Enable parsing of revision tags into the History 10139N/A# - READ_XML_CONFIGURATION file with read only configuration 10139N/A# - temporary workaround for bug # 327 10139N/A# - OPENGROK_FLUSH_RAM_BUFFER_SIZE="-m 16" - set RAM buffer size for flushing, 10139N/A# default is 16MB per thread, you might try to 10139N/A# increase it to 256MB, but do increase JVM to 10139N/A# 4/8/16GB ! Lucene defaults to 8 threads. 10139N/A# Increase JVM memory as noted using JAVA_OPTS 10139N/A# - OPENGROK_SUBVERSION_USERNAME name of the user that should be used for 10139N/A# fetching the history from subversion 10139N/A# - OPENGROK_SUBVERSION_PASSWORD password of the user that should be used for 10139N/A# fetching the history from subversion 10139N/A# (*) Any Non-Empty String will enable these options 10139N/A# Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. 10139N/A# Print usage to stdout and exit. 10139N/A echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage|help>" 10139N/A echo " ${progname} index [<directory>]" 10318N/A echo " ${progname} indexpart <src_root> <directory1> [..]" 10139N/A echo " ${progname} clearHistory <src_root> <repository_name>" 10139N/A echo " Optional environment variables:" 10139N/A echo " OPENGROK_CONFIGURATION - location of your configuration" 10139N/A echo " See the code for more information on configuration options /" \ 10139N/A echo "Cannot determine operating system version" 10139N/A# TODO: Handle symlinks correctly (especially in ${0}) 10139N/A# Default Instance Configuration 10139N/A # Use the built-in defaults. This section can be copied to its own 10139N/A # file and tailored to your local requirements. Then simply set 10139N/A # this wrapper. It will save you hand editing in your settings 10318N/A # on each new release. A sample cron(1M) entry might look like: 10318N/A # Note: It is not really possible to ever provided defaults for 10318N/A # these values which will run in every UNIX-like environment. 10318N/A # So I have provided a set which are functional for a given 10318N/A # environment on which you can based you own configuration. 10318N/A # This has been updated to support more environment variables and 10318N/A # operating systems, if you have any reasonably generic 10318N/A # improvements please feel free to submit a patch. 10139N/A if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ] 10139N/A if [ -d "${SCRIPT_DIRECTORY}/dist" -a \ 10139N/A # Handle Developer Build Environments 10139N/A # (your source code or the root of all repositories) 10139N/A # REQUIRED: OpenGrok Generate Data Root 10139N/A # (for Lucene index and hypertext cross-references) 10139N/A # This area is rebuilt by "update" / "updateQuietly" 10139N/A # OPTIONAL: User Provided Source Path to Description Mapping 10139N/A # (The user maintained source of the generated EftarFile file) 10139N/A # OPTIONAL: read only XML config, if it exists, it will be read 10139N/A if [ -f "${READ_XML_CONFIGURATION}" ] ; then 10139N/A # REQUIRED: Logger Configuration 10139N/A if [ -n "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then 10139N/A if [ ! -f "${OPENGROK_LOGGER_CONFIG_PATH}" ]; then 10139N/A echo "File ${OPENGROK_LOGGER_CONFIG_PATH} does not exist" 10139N/A # REQUIRED: Java Archive of OpenGrok (Installation Location) 10139N/A # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location) 10139N/A # (user building from source code will find this and other key 10139N/A # files in the "dist" directory after the build is completed) 10307N/A # OPTIONAL: supply extra command line options to CTags program 10295N/A if [ -n "${OPENGROK_CTAGS_OPTIONS_FILE}" ]; then 10139N/A # REQUIRED: Java Virtual Machine 10139N/A # DEVELOPMENT: Debug option, if enabled current indexer will listen on the 10139N/A # port 8010 until a debugger connects 10139N/A #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket" 10139N/A #JAVA_DEBUG="$JAVA_DEBUG,server=y,address=8010,suspend=y" 10139N/A # OPTIONAL: Ignore these patterns as names of files or directories 10139N/A # To ignore skipping just the history cache creation for a particular 10139N/A # directory and all of it's subdirectories, touch an empty 10139N/A # .opengrok_skip_history file at the root of that directory 10139N/A # (Every directory in SRC_ROOT is considered a separate project) 10139N/A # OPTIONAL: Scanning Options (for Mercurial repositories) 10139N/A if [ -n "${OPENGROK_SCAN_REPOS}" ] 10139N/A # OPTIONAL: Disable remote repository support (CVS or SVN) [on by default] 10139N/A if [ -n "${OPENGROK_GENERATE_HISTORY}" ] 10139N/A # OPTIONAL: override depth of scanning for repositories 10139N/A if [ -n "${OPENGROK_SCAN_DEPTH}" ] 10139N/A # OPTIONAL: Allow Leading Wildcard Searches 10139N/A if [ -n "${OPENGROK_WPREFIX}" ] 10139N/A # OPTIONAL: Web Site Look & Feel 10139N/A # (Options: default, offwhite and polished. 10139N/A # Note the quoting requirements) 10139N/A # OPTIONAL: Configuration Address (host:port) 10139N/A if [ -n "${OPENGROK_WEBAPP_CFGADDR}" ]; then 10139N/A if [ "${OPENGROK_WEBAPP_CFGADDR}" = "none" ]; then 10139N/A if [ -n "${WEBAPP_CONFIG_ADDRESS}" ]; then 10139N/A # OPTIONAL: Context URL of the OpenGrok webapp 10139N/A if [ -n "${OPENGROK_WEBAPP_CONTEXT}" ]; then 10139N/A # OPTIONAL: Full Path to History Utilities 10139N/A # OPTIONAL: Override Built-in Properties 10139N/A # Assumption: We should not set properties to the empty string 10139N/A # OPTIONAL: Store The History Cache in Java DB (derby), 10139N/A # instead of file system (in gzipped xml files). 10139N/A # - Running Derby Server - Defaults to localhost:1527 10139N/A if [ -n "${OPENGROK_DERBY_URL}" ]; then 10139N/A # OPTIONAL: Show revision tags in History view. 10139N/A # Turn this off if you want to increase indexing performance a bit 10139N/A # DELIVERED: An update program for EftarFile 10139N/A # Usage: <class> inputFile [inputFile ...] outputFile 10139N/A # EftarFile == An Extremely Fast Tagged Attribute Read-only File System 10139N/A # HARDCODED: Generated EftarFile (See web/*.jsp) 10139N/A # Be Quiet? (set indirectly by command line arguments in the main program) 10139N/A # or alternatively, Be Verbose! 10139N/A if [ -n "${OPENGROK_VERBOSE}" ] 10139N/A if [ -n "${OPENGROK_PROGRESS}" ] 10139N/A# In general, non-interactive use like cron jobs and automated 10139N/A# installation environments should not generate unnecessary 10139N/A# progress information or warnings, as usage and configuration 10139N/A# will have generally been debugged prior to automation. 10139N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ] 10139N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ] 10139N/A echo "FATAL ERROR: ${@} - Aborting!" 10139N/A# Helper Functions - Autodetection of Runtime Environment 10139N/A # Search for Exuberant ctags intelligently, skipping 10139N/A # over other ctags implementations. # Verify that this really is Exuberant Ctags. Error "Unable to determine Exuberant CTags command name" \ "for ${OS_NAME} ${OS_VERSION}" case "${OS_NAME}:${OS_VERSION}" in Error "Unable to determine Java 7 Home" \ "for ${OS_NAME} ${OS_VERSION}" if [ ! -d "${javaHome}" ] Error "Missing Java Home ${javaHome}" # Use this function to determine which environment the deploy the # web application function into. Some users (especially # developers) will have many deployment environments or will wish # to specify directly the application server to deploy to. # Either use the environment variable OPENGROK_APP_SERVER or # reimplement this function in your configuration file (as # specified by OPENGROK_CONFIGURATION) if [ -n "${OPENGROK_APP_SERVER}" ] echo "${OPENGROK_APP_SERVER}" # This implementation favours Tomcat, but needs a lot of work, # especially if Glassfish is perferrerd or it is under the control # of SMF (Service Management Facility) # Maybe a better implementation would be to call Application # Server specific WAR Directory and see if they exist. if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ] echo "${OPENGROK_WAR_TARGET_TOMCAT}" elif [ -n "${OPENGROK_WAR_TARGET}" ] echo "${OPENGROK_WAR_TARGET}" if [ -d "${prefix}/webapps" ] if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ] echo "${OPENGROK_WAR_TARGET_GLASSFISH}" elif [ -n "${OPENGROK_WAR_TARGET}" ] echo "${OPENGROK_WAR_TARGET}" if [ -d "${prefix}/domains" ] if [ -z "${domainDirectory}" ] if [ -z "${domainDirectory}" ] if [ -n "${OPENGROK_GLASSFISH_DOMAIN}" ] directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy" if [ ! -d "${directory}" ] FatalError "Missing Specified Glassfish Domain " \ "${OPENGROK_GLASSFISH_DOMAIN}" # Arbitrary Domain Selection if [ -z "${firstDomain}" ] FatalError "Failed to dynamically determine Glassfish Domain from " \ echo "${domainDirectory}/${firstDomain}/autodeploy" if [ -n "${OPENGROK_WAR_TARGET_RESIN}" ] echo "${OPENGROK_WAR_TARGET_RESIN}" elif [ -n "${OPENGROK_WAR_TARGET}" ] echo "${OPENGROK_WAR_TARGET}" if [ -d "${prefix}/webapps" ] # The variable "DO" can usefully be set to "echo" to aid in script debugging # Setup a standard execution environment (if required) if [ -f "${OPENGROK_STANDARD_ENV}" ] Progress "Loading ${OPENGROK_STANDARD_ENV} ..." . "${OPENGROK_STANDARD_ENV}" # Load custom configuration and then fill remaining stuff with defaults. # Note: As all functions have been defined by the time this routine # is called, your configuration can, if desired, override functions # in addition to setting the variables mentioned in the function # DefaultInstanceConfiguration(), this maybe useful to override # functionality used to determine the default deployment environment # find dependencies or validate the configuration, for example. if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ] # Load the Local OpenGrok Configuration Environment Progress "Loading ${OPENGROK_CONFIGURATION} ..." . "${OPENGROK_CONFIGURATION}" Progress "Loading the default instance configuration ..." if [ ! -x "${EXUBERANT_CTAGS}" ] FatalError "Missing Dependent Application - Exuberant CTags" if [ ! -d "${SRC_ROOT}" ] FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist" if [ -n "${QUIET}" -a -n "${VERBOSE}" ] Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose" if [ -n "${OPENGROK_DERBY}" ] "opengrok used jars are and in unpacked source.war in " \ if [ ! -d "${DATA_ROOT}" ] Warning "OpenGrok generated data path ${DATA_ROOT} doesn't exist" Progress " Attempting to create generated data directory ... " if [ ! -d "${DATA_ROOT}" ] FatalError "OpenGrok data path ${DATA_ROOT} doesn't exist" if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ] Warning "OpenGrok generated etc path ${OPENGROK_INSTANCE_BASE}/etc " \ Progress " Attempting to create generated etc directory ... " ${DO} mkdir -p "${OPENGROK_INSTANCE_BASE}/etc" if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ] FatalError "OpenGrok etc path ${OPENGROK_INSTANCE_BASE}/etc " \ if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ] Progress " Creating default ${LOGGER_CONFIG_PATH} ... " if [ ! -f "${LOGGER_CONF_SOURCE}" ] Warning "Can't find distribution logging configuration" \ "(${LOGGER_CONF_SOURCE}) to install as default" \ "logging configuration (${LOGGER_CONFIG_PATH})" "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}" "${LOGGER_CONF_SOURCE}" | \ if [ -n "${OPENGROK_DERBY}" ] if [ ! -d "${OPENGROK_INSTANCE_BASE}/derby" ] Warning "OpenGrok generated derby path " \ "${OPENGROK_INSTANCE_BASE}/derby doesn't exist" Progress " Attempting to create generated derby directory ... " # OPTIONAL : Update the EftarFile data if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ] case "${applicationServer}" in *) FatalError "Unsupported Application Server ${applicationServer}" ;; FatalError "Unable to determine Deployment Directory for " \ if [ ! -f "${OPENGROK_DIST_WAR}" ] FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}" if [ ! -d "${warTarget}" ] FatalError "Missing Deployment Directory ${warTarget}" Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..." ${DO} cp -p "${OPENGROK_DIST_WAR}" "${warTarget}/" # If user does not use default OPENGROK_INSTANCE_BASE or default # source.war using jar or zip utility, update the hardcoded values and if [ "${OPENGROK_INSTANCE_BASE}" != '/var/opengrok' ] || [ "${WEBAPP_CONFIG_ADDRESS}" != 'localhost:2424' ] if [ -n "${EXTRACT_COMMAND}" ] if [ "${WEBAPP_CONFIG_ADDRESS}" != 'localhost:2424' ] rm -rf "${warTarget}/WEB-INF" Progress "Start your application server (${applicationServer}), " \ Progress "running, or wait until it loads the just installed web " \ Progress "OpenGrok should be available on <HOST>:<PORT>/source" Progress " where HOST and PORT are configured in ${applicationServer}." case "${OS_NAME}:${OS_VERSION}" in echo "Below might need your socket permission setup" echo "see JDK1.7_51 release notes" *) Error "unsupported OS" ;; # Clear history index for given project. Progress "Removing history index data for repository ${1}"