OpenGrok revision 1337
1968N/A# OpenGrok Wrapper (initial setup and cron job updating) 1968N/A# Supported Operating Systems: 1968N/A# Supported Deployment Engines: 1968N/A# Supported Environment Variables: 1968N/A# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*) 1968N/A# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script) 1968N/A# - OPENGROK_CONFIGURATION User Configuration (Shell Script) 1968N/A# Supported Environment Variables for configuring the default setup: 1968N/A# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution 1968N/A# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area 1968N/A# - EXUBERANT_CTAGS Full Path to Exuberant CTags 3158N/A# - JAVA_HOME Full Path to Java Installation Root 1968N/A# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish") 1968N/A# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory 1968N/A# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory 1968N/A# - OPENGROK_WAR_TARGET Fallback WAR Target Directory 1968N/A# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps) 1968N/A# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish 1968N/A# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name 1968N/A# - OPENGROK_PROGRESS Shows progress in %(percentage) of working 1968N/A# through project, it's good to have Verbose 3031N/A# Mode enabled too, cost of this is one more 1968N/A# traversal of the project before indexing it(*) 2028N/A# - OPENGROK_REMOTE_REPOS Disable History Cache for (remote) 2028N/A# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*) 2028N/A# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go 2301N/A# (by default 3 directories from SRC_ROOT) 2028N/A# - OPENGROK_WEBAPP_CFGADDR Web app address to send configuration to 1968N/A# (use "none" to avoid sending it to web app) 1968N/A# - OPENGROK_WPREFIX Disable wildcard prefix search query 1968N/A# - OPENGROK_DERBY if set, then indexer tries to use derby as 1968N/A# historycache (see derby command of this 2028N/A# - READ_XML_CONFIGURATION file with read only configuration 2028N/A# - temporary workaround for bug # 327 2843N/A# (*) Any Non-Empty String will enable these options 1968N/A# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 1968N/A# Print usage to stderr and exit. 1968N/A echo "Usage: ${progname} <deploy|derby|update|updateQuietly|usage>" 1968N/A echo " ${progname} index [<directory>]" 2028N/A echo " Optional environment variables:" 2028N/A echo " OPENGROK_CONFIGURATION - location of your configuration" 2028N/A echo " See the code for more information on configuration options /" \ 1968N/A# TODO: Handle symlinks correctly (especially in ${0}) 1968N/A# Default Instance Configuration 2301N/A # Use the built-in defaults. This section can be copied to its own 2301N/A # file and tailored to your local requirements. Then simply set 2301N/A # this wrapper. It will save you hand editing in your settings 2301N/A # on each new release. A sample cron(1M) entry might look like: 2301N/A # Note: It is not really possible to ever provided defaults for 2301N/A # these values which will run in every UNIX-like environment. 2301N/A # So I have provided a set which are functional for a given 2301N/A # environment on which you can based you own configuration. 1968N/A # This has been updated to support more environment variables and 1968N/A # operating systems, if you have any reasonably generic 1968N/A # improvements please feel free to submit a patch. 1968N/A if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ] 1968N/A if [ -d "${SCRIPT_DIRECTORY}/dist" -a \ 1978N/A # Handle Developer Build Environments 2028N/A # Handle Binary Distributions 2864N/A # (your source code or the root of all repositories) 2864N/A # REQUIRED: OpenGrok Generate Data Root 1978N/A # (for Lucene index and hypertext cross-references) 2864N/A # This area is rebuilt by "update" / "updateQuietly" 3041N/A # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value) 3041N/A # (The user maintained source of the generated EftarFile file) 2864N/A # REQUIRED: XML Configuration 2028N/A # OPTIONAL: read only XML config, if it exists, it will be read 2301N/A if [ -f "${READ_XML_CONFIGURATION}" ] ; then 2028N/A # REQUIRED: Logger Configuration 2843N/A # REQUIRED: Java Archive of OpenGrok (Installation Location) 2028N/A # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location) 1968N/A # (user building from source code will find this and other key 1968N/A # files in the "dist" directory after the build is completed) 1968N/A # REQUIRED: Java Virtual Machine 1968N/A # DEVELOPMENT: Debug option, if enabled current indexer will listen on the port 8010 until a debugger connects 1968N/A #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,address=8010,suspend=y" 1968N/A # OPTIONAL: Ignore these patterns as names of files or directories 1968N/A #IGNORE_PATTERNS="-i dummy" 2028N/A # OPTIONAL: Enable Projects 1968N/A # (Every directory in SRC_ROOT is considered a separate project) 2301N/A # OPTIONAL: Scanning Options (for Mercurial repositories) 2301N/A if [ -n "${OPENGROK_SCAN_REPOS}" ] 2301N/A # OPTIONAL: Remote Repository Support (CVS or SVN) 2301N/A # (Can be very time demanding, uncomment if needed) 2301N/A if [ -n "${OPENGROK_REMOTE_REPOS}" ] 2301N/A # OPTIONAL: override depth of scanning for repositories 2301N/A if [ -n "${OPENGROK_SCAN_DEPTH}" ] 2301N/A # OPTIONAL: Allow Leading Wildcard Searches 2301N/A if [ -n "${OPENGROK_WPREFIX}" ] 2301N/A # OPTIONAL: Web Site Look & Feel 3171N/A # (Options: default, offwhite and polished. 2301N/A # Note the quoting requirements) 2301N/A # OPTIONAL: Set Maximum Indexed Words Per File 2301N/A # Note, that you might run out of memory, then either increase JVM memory 2301N/A # as noted in JAVA_OPTS, or set this limit(if you don't mind opengrok not 2301N/A # indexing the rest of the file, once the limit is reached) 3158N/A #MAX_INDEXED_WORDS="-m 100000" 2958N/A # OPTIONAL: Configuration Address (host:port) 2301N/A if [ -n "${OPENGROK_WEBAPP_CFGADDR}" ]; then 2301N/A if [ "${OPENGROK_WEBAPP_CFGADDR}" == "none" ]; then 3158N/A if [ -n "${WEBAPP_CONFIG_ADDRESS}" ]; then 2301N/A #JAVA_OPTS="-server -Xmx2048m" 2301N/A # OPTIONAL: Full Path to History Utilities 2028N/A # OPTIONAL: Override Built-in Properties 2028N/A # Assumption: We should not set properties to the empty string 2028N/A # OPTIONAL: Store The History Cache in Java DB (derby), 2028N/A # instead of file system (in gzipped xml files). 2028N/A # - Running Derby Server - Defaults to localhost:1527 2028N/A if [ -n "${OPENGROK_DERBY}" ] 2028N/A # DELIVERED: An update program for EftarFile 2028N/A # Usage: <class> inputFile [inputFile ...] outputFile 2028N/A # EftarFile == An Extremely Fast Tagged Attribute Read-only File System 2073N/A # HARDCODED: Generated EftarFile (See web/*.jsp) 2028N/A # Be Quiet? (set indirectly by command line arguments in the main program) 3140N/A # or alternatively, Be Verbose! 2028N/A if [ -n "${OPENGROK_VERBOSE}" ] 2028N/A if [ -n "${OPENGROK_PROGRESS}" ] 2142N/A# Helper Functions - Logging 2142N/A# In general, non-interactive use like cron jobs and automated 2142N/A# installation environments should not generate unnecessary 2142N/A# progress information or warnings, as usage and configuration 2142N/A# will have generally been debugged prior to automation. 2142N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ] 2142N/A if [ -z "${OPENGROK_NON_INTERACTIVE}" ] 2142N/A echo "FATAL ERROR: ${@} - Aborting!" 1>&2 2142N/A# Helper Functions - Autodetection of Runtime Environment 2970N/A Error "Unable to determine Exuberant CTags command name" \ 2970N/A "for ${OS_NAME} ${OS_VERSION}" 2970N/A # Verify that this really is Exuberant Ctags 2970N/A Error "Unable to determine Exuberant CTags command name" \ 2970N/A "for ${OS_NAME} ${OS_VERSION}\n(${binary} is not Exuberant CTags)" 2970N/A "for ${OS_NAME} ${OS_VERSION}" 2970N/A # Use this function to determine which environment the deploy the 2142N/A # web application function into. Some users (especially 2028N/A # developers) will have many deployment environments or will wish 2028N/A # to specify directly the application server to deploy to. 2028N/A # Either use the environment variable OPENGROK_APP_SERVER or 2028N/A # reimplement this function in your configuration file (as 2028N/A # specified by OPENGROK_CONFIGURATION) 2028N/A if [ -n "${OPENGROK_APP_SERVER}" ] 2028N/A echo "${OPENGROK_APP_SERVER}" 2028N/A # This implementation favours Tomcat, but needs a lot of work, 2028N/A # especially if Glassfish is perferrerd or it is under the control 2028N/A # of SMF (Service Management Facility) 2028N/A # Maybe a better implementation would be to call Application 2028N/A # Server specific WAR Directory and see if they exist. 2028N/A if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ] 1968N/A echo "${OPENGROK_WAR_TARGET_TOMCAT}" 2028N/A elif [ -n "${OPENGROK_WAR_TARGET}" ] 2864N/A echo "${OPENGROK_WAR_TARGET}" 2028N/A if [ -d "${prefix}/webapps" ] 2028N/A if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ] 2864N/A echo "${OPENGROK_WAR_TARGET_GLASSFISH}" 2028N/A elif [ -n "${OPENGROK_WAR_TARGET}" ] 2028N/A echo "${OPENGROK_WAR_TARGET}" 1968N/A if [ -d "${prefix}/domains" ] 2028N/A if [ -z "${domainDirectory}" ] 1968N/A if [ -z "${domainDirectory}" ] 1968N/A if [ -n "${OPENGROK_GLASSFISH_DOMAIN}" ] 1968N/A # Arbitrary Domain Selection 1968N/A FatalError "Failed to dynamically determine Glassfish Domain from ${domainDirectory}" 1968N/A echo "${domainDirectory}/${firstDomain}/autodeploy" 2510N/A# The variable "DO" can usefully be set to "echo" to aid in script debugging 1968N/A # Setup a standard execution environment (if required) 1968N/A if [ -f "${OPENGROK_STANDARD_ENV}" ] 2510N/A . "${OPENGROK_STANDARD_ENV}" 2028N/A # Note: As all functions have been defined by the time this routine 1968N/A # is called, your configuration can, if desired, override functions 1968N/A # in addition to setting the variables mentioned in the function 1968N/A # DefaultInstanceConfiguration(), this maybe useful to override 1968N/A # functionality used to determine the default deployment environment 1968N/A # find dependencies or validate the configuration, for example. 1968N/A if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ] 2510N/A # Load the Local OpenGrok Configuration Environment 1968N/A . "${OPENGROK_CONFIGURATION}" 2028N/A if [ ! -x "${EXUBERANT_CTAGS}" ] 2028N/A if [ -n "${QUIET}" -a -n "${VERBOSE}" ] 2028N/A Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose" 2132N/A if [ -n "${OPENGROK_DERBY}" ] 2132N/A Warning "OpenGrok generated data path ${DATA_ROOT} doesn't exist" 2028N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ] 2028N/A Warning "OpenGrok generated etc path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist" 2028N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ] 2310N/A if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ] 2028N/A if [ ! -f "${LOGGER_CONF_SOURCE}" ] 2028N/A "(${LOGGER_CONF_SOURCE}) to install as default" \ 2028N/A "logging configuration (${LOGGER_CONFIG_PATH})" 2028N/A if [ -n "${OPENGROK_DERBY}" ] 2028N/A if [ ! -d "${OPENGROK_INSTANCE_BASE}/derby" ] 2028N/A Warning "OpenGrok generated derby path ${OPENGROK_INSTANCE_BASE}/derby doesn't exist" 2028N/A # OPTIONAL : Update the EftarFile data 2028N/A if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ] 1968N/A FatalError "Unable to determine Deployment Directory for ${applicationServer}" 1968N/A if [ ! -f "${OPENGROK_DIST_WAR}" ] 2864N/A ${DO} cp -p "${OPENGROK_DIST_WAR}" "${warTarget}/" 2028N/A Progress "Start your application server (${applicationServer}), if it is not already" 1968N/A Progress "running, or wait until it loads the just installed web application." 2028N/A Progress " where HOST and PORT are configured in ${applicationServer}."