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