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